π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
refactor(rust): move ML into its own crate
laurenspriem693d6346ce58
diff --git a/.github/CODEOWNERS b/.github/CODEOWNERSindex 2d853e5890..c5791c31da 100644--- a/.github/CODEOWNERS+++ b/.github/CODEOWNERS@@ -1,5 +1,5 @@/.github/ @ua741 @mnvr-sudo/server/ @ua741 @mnvr-sudo/mobile/packages/ente_components/ @ashilkn @AmanRajSinghMourya-/rust/crates/photos/src/ml/ @laurenspriem @mnvr-sudo+/rust/crates/ml/ @laurenspriem @mnvr-sudo/rust/crates/image/ @laurenspriem @mnvr-sudodiff --git a/.github/workflows/desktop-lint.yml b/.github/workflows/desktop-lint.ymlindex 2113abe3a7..c07222a1ae 100644--- a/.github/workflows/desktop-lint.yml+++ b/.github/workflows/desktop-lint.yml@@ -6,8 +6,9 @@ on:- ".github/workflows/desktop-lint.yml"- "desktop/**"- "rust/bindings/napi/**"- - "rust/crates/photos/**"- "rust/crates/image/**"+ - "rust/crates/ml/**"+ - "rust/crates/photos/**"- "rust/apps/codegen/**"- "rust/Cargo.toml"- "rust/Cargo.lock"diff --git a/.github/workflows/mobile-lint.yml b/.github/workflows/mobile-lint.ymlindex 2a6e2a0101..58c0799d18 100644--- a/.github/workflows/mobile-lint.yml+++ b/.github/workflows/mobile-lint.yml@@ -14,6 +14,7 @@ on:- "rust/crates/contacts/**"- "rust/crates/core/**"- "rust/crates/image/**"+ - "rust/crates/ml/**"- "rust/crates/photos/**"workflow_dispatch:diff --git a/.github/workflows/rust-lint.yml b/.github/workflows/rust-lint.ymlindex 9d7a08b429..fd4afa4528 100644--- a/.github/workflows/rust-lint.yml+++ b/.github/workflows/rust-lint.yml@@ -45,7 +45,7 @@ jobs:- run: cargo fmt --check- - run: cargo clippy --locked --all-targets --features museum,ente-photos/ml-assets+ - run: cargo clippy --locked --all-targets --features museum,ente-ml/ml-assets- run: cargo install cargo-audit --version 0.22.2 --lockeddiff --git a/.github/workflows/rust-test.yml b/.github/workflows/rust-test.ymlindex 259935f99c..00652016e2 100644--- a/.github/workflows/rust-test.yml+++ b/.github/workflows/rust-test.yml@@ -52,7 +52,7 @@ jobs:save-if: falsecache-directories: rust/.cache- - run: cargo test --locked --features museum,ente-photos/ml-assets+ - run: cargo test --locked --features museum,ente-ml/ml-assets# postgresql_embedded downloads its binaries from GitHub.# GITHUB_TOKEN raises the API rate limit for those downloads.env:diff --git a/.github/workflows/warm-caches.yml b/.github/workflows/warm-caches.ymlindex 9ea535c09f..180e974930 100644--- a/.github/workflows/warm-caches.yml+++ b/.github/workflows/warm-caches.yml@@ -50,9 +50,9 @@ jobs:- name: Reset ML test cacherun: rm -rf .cache- - run: cargo clippy --locked --all-targets --features museum,ente-photos/ml-assets+ - run: cargo clippy --locked --all-targets --features museum,ente-ml/ml-assets- - run: cargo test --locked --features museum,ente-photos/ml-assets+ - run: cargo test --locked --features museum,ente-ml/ml-assetsenv:GITHUB_TOKEN: ${{ github.token }}diff --git a/infra/ml/playground/optimizations/benchmark_reports/20260723_ANDROID_ML_SCHEDULER_VERIFICATION_REPORT.md b/infra/ml/playground/optimizations/benchmark_reports/20260723_ANDROID_ML_SCHEDULER_VERIFICATION_REPORT.mdindex 0af193889a..0c8ae0d8b0 100644--- a/infra/ml/playground/optimizations/benchmark_reports/20260723_ANDROID_ML_SCHEDULER_VERIFICATION_REPORT.md+++ b/infra/ml/playground/optimizations/benchmark_reports/20260723_ANDROID_ML_SCHEDULER_VERIFICATION_REPORT.md@@ -142,7 +142,7 @@ Ranked by expected value for production Android indexing:with the per-image target duration; this is the sanctioned mechanism forexactly this bursty-workload/DVFS problem and replaces any affinity hack.4. **Drop the `rayon` feature from `fast_image_resize` in- `rust/crates/photos`** (keep `heic_decoder`'s own rayon parallelism for+ `rust/crates/ml`** (keep `heic_decoder`'s own rayon parallelism fordecode). The resize fan-out never pays for itself β B was net *faster*on pre-processing without it β and it stops paying the 2-5 ms barrierper dispatch. Small, safe, immediate.diff --git a/infra/ml/test/README.md b/infra/ml/test/README.mdindex af2632e7fc..10120b3ede 100644--- a/infra/ml/test/README.md+++ b/infra/ml/test/README.md@@ -2,7 +2,7 @@This directory contains the ML indexing parity framework for desktop, Android, iOS, and Python ground truth.-The desktop runner smoke-tests the desktop-specific N-API bindings and pinned ONNX Runtime library. Deep validation of the shared Rust pipeline lives in the `ente-photos` crate's `ml_indexing` integration test.+The desktop runner smoke-tests the desktop-specific N-API bindings and pinned ONNX Runtime library. Deep validation of the shared Rust pipeline lives in the `ente-ml` crate's `ml_indexing` integration test.## Layout@@ -49,14 +49,14 @@ Optional mobile reuse env vars:## Rust ML Indexing Cargo Test-The Rust-only ML indexing test lives at `rust/crates/photos/tests/ml_indexing.rs`.-It is gated by the `ente-photos/ml-assets` Cargo feature so ordinary local+The Rust-only ML indexing test lives at `rust/crates/ml/tests/ml_indexing.rs`.+It is gated by the `ente-ml/ml-assets` Cargo feature so ordinary local`cargo test --workspace` runs do not download ML assets or execute indexing.From `rust/`:```sh-cargo test -p ente-photos --test ml_indexing --features ml-assets -- --nocapture+cargo test -p ente-ml --test ml_indexing --features ml-assets -- --nocapture```By default the test downloads the external fixture manifest, fixture images,diff --git a/rust/Cargo.lock b/rust/Cargo.lockindex 14d77d5e4b..049145b737 100644--- a/rust/Cargo.lock+++ b/rust/Cargo.lock@@ -2496,20 +2496,7 @@ dependencies = [][[package]]-name = "ente-paste"-version = "0.0.0"-dependencies = [- "ente-core",- "mockito",- "serde",- "serde_json",- "thiserror 2.0.18",- "tokio",- "url",-]--[[package]]-name = "ente-photos"+name = "ente-ml"version = "0.0.0"dependencies = ["anyhow",@@ -2527,7 +2514,6 @@ dependencies = ["once_cell","ort","plsfix",- "quick-xml","regex","serde","serde_json",@@ -2539,6 +2525,27 @@ dependencies = ["usearch",]+[[package]]+name = "ente-paste"+version = "0.0.0"+dependencies = [+ "ente-core",+ "mockito",+ "serde",+ "serde_json",+ "thiserror 2.0.18",+ "tokio",+ "url",+]++[[package]]+name = "ente-photos"+version = "0.0.0"+dependencies = [+ "quick-xml",+ "tempfile",+]+[[package]]name = "ente-rs"version = "0.0.1"@@ -2664,7 +2671,7 @@ name = "ente_photos_napi"version = "0.0.0"dependencies = ["ente-assets",- "ente-photos",+ "ente-ml","log","napi","napi-build",@@ -2679,6 +2686,7 @@ dependencies = ["ente-cast","ente-frb-log","ente-image",+ "ente-ml","ente-photos","flutter_rust_bridge",]diff --git a/rust/Cargo.toml b/rust/Cargo.tomlindex 06e3417144..1c29cccf07 100644--- a/rust/Cargo.toml+++ b/rust/Cargo.toml@@ -23,6 +23,7 @@ members = ["crates/core","crates/ensu","crates/image",+ "crates/ml","crates/paste","crates/photos","crates/space",@@ -38,6 +39,7 @@ ente-core = { path = "crates/core" }ente-ensu = { path = "crates/ensu" }ente-frb-log = { path = "bindings/frb/log" }ente-image = { path = "crates/image" }+ente-ml = { path = "crates/ml" }ente-paste = { path = "crates/paste" }ente-photos = { path = "crates/photos" }ente-space = { path = "crates/space" }diff --git a/rust/README.md b/rust/README.mdindex 6a0e8344da..fde9c104ae 100644--- a/rust/README.md+++ b/rust/README.md@@ -23,5 +23,5 @@ cargo codegen frb # Regenerate bindings used by Flutter appscargo codegen napi # Regenerate bindings used by Desktop (Electron) apps# Run integration tests against a local Museum-cargo test --features museum,ente-photos/ml-assets+cargo test --features museum,ente-ml/ml-assets```diff --git a/rust/bindings/frb/photos/Cargo.toml b/rust/bindings/frb/photos/Cargo.tomlindex bcb61d5fae..76b7fa9939 100644--- a/rust/bindings/frb/photos/Cargo.toml+++ b/rust/bindings/frb/photos/Cargo.toml@@ -9,7 +9,8 @@ crate-type = ["cdylib", "staticlib"]ente-cast.workspace = trueente-frb-log.workspace = trueente-image.workspace = true-ente-photos = { workspace = true, features = ["usearch"] }+ente-ml = { workspace = true, features = ["usearch"] }+ente-photos.workspace = trueflutter_rust_bridge.workspace = true[lints.rust]diff --git a/rust/bindings/frb/photos/src/api/image_processing_api.rs b/rust/bindings/frb/photos/src/api/image_processing_api.rsindex ba1aebce32..a8f1edc350 100644--- a/rust/bindings/frb/photos/src/api/image_processing_api.rs+++ b/rust/bindings/frb/photos/src/api/image_processing_api.rs@@ -2,7 +2,7 @@ use ente_image::{decode::decode_image_from_path,image_compression::{EncodedImageFormat, encode_rgb},};-use ente_photos::ml::face::thumbnail::{+use ente_ml::face::thumbnail::{FaceBox, generate_face_thumbnails as generate_face_thumbnails_impl,};diff --git a/rust/bindings/frb/photos/src/api/ml_indexing_api.rs b/rust/bindings/frb/photos/src/api/ml_indexing_api.rsindex 5245693cac..28eaf14388 100644--- a/rust/bindings/frb/photos/src/api/ml_indexing_api.rs+++ b/rust/bindings/frb/photos/src/api/ml_indexing_api.rs@@ -1,4 +1,4 @@-use ente_photos::ml::{ModelPaths, error::MlError, indexing, types};+use ente_ml::{ModelPaths, error::MlError, indexing, types};#[derive(Clone, Debug)]pub struct RustModelPaths {diff --git a/rust/bindings/frb/photos/src/api/usearch_api.rs b/rust/bindings/frb/photos/src/api/usearch_api.rsindex 63e5341870..cecfcfe16b 100644--- a/rust/bindings/frb/photos/src/api/usearch_api.rs+++ b/rust/bindings/frb/photos/src/api/usearch_api.rs@@ -1,4 +1,4 @@-use ente_photos::ml::vector_db;+use ente_ml::vector_db;use flutter_rust_bridge::frb;type SearchMatch = (Vec<u64>, Vec<f32>);diff --git a/rust/bindings/napi/photos/Cargo.toml b/rust/bindings/napi/photos/Cargo.tomlindex 1f9c66ac0d..ed353a86c8 100644--- a/rust/bindings/napi/photos/Cargo.toml+++ b/rust/bindings/napi/photos/Cargo.toml@@ -8,7 +8,7 @@ crate-type = ["cdylib"][dependencies]# usearch requires a newer GCC than napi-cli provides.ente-assets.workspace = true-ente-photos.workspace = true+ente-ml.workspace = truelog = { workspace = true, features = ["std"] }napi = { version = "3", default-features = false, features = ["napi10", "tokio_rt"] }napi-derive = "3"diff --git a/rust/bindings/napi/photos/src/lib.rs b/rust/bindings/napi/photos/src/lib.rsindex d723c92c85..0d9926da1b 100644--- a/rust/bindings/napi/photos/src/lib.rs+++ b/rust/bindings/napi/photos/src/lib.rs@@ -1,4 +1,4 @@-use ente_photos::ml::{+use ente_ml::{ModelPaths as SharedModelPaths, assets, error::MlError, indexing as shared_indexing,types as shared_types,};diff --git a/rust/crates/ml/Cargo.toml b/rust/crates/ml/Cargo.tomlnew file mode 100644index 0000000000..80b9a56e00--- /dev/null+++ b/rust/crates/ml/Cargo.toml@@ -0,0 +1,87 @@+[package]+name = "ente-ml"+edition = "2024"++[features]+default = []+ml-assets = []+usearch = ["dep:usearch"]++[dependencies]+ente-assets.workspace = true+ente-image.workspace = true+fast_image_resize = { version = "5.5.0", features = ["image", "rayon"] }+half = "2.1"+html-escape = "0.2.13"+image = { version = "0.25.5", default-features = true }+imageproc = "0.25.0"+log.workspace = true+nalgebra = "0.33.2"+once_cell = "1.20.2"+plsfix = "0.1.8"+regex = "1.11.1"+thiserror.workspace = true+# The FRB photos bridge calls the SimSIMD symbol exported by usearch 2.21.x.+# Newer usearch releases switched that implementation to numkong symbols.+usearch = { version = "=2.21.4", optional = true }++# Cargokit sets ORT_LIB_PATH to Ente's verified iOS archive.+[target.'cfg(target_os = "ios")'.dependencies]+ort = { workspace = true, features = [+ "std",+ "ndarray",+ "half",+ "coreml",+ "api-28",+] }++[target.'cfg(target_os = "android")'.dependencies]+ash = { version = "0.38", default-features = false, features = ["loaded"] }+ort = { workspace = true, features = [+ "ndarray",+ "half",+ "api-28",+ "load-dynamic",+ "copy-dylibs",+ "webgpu",+ "xnnpack",+] }++[target.'cfg(target_os = "macos")'.dependencies]+ort = { workspace = true, features = [+ "ndarray",+ "half",+ "coreml",+ "api-28",+ "load-dynamic",+ "copy-dylibs",+] }++[target.'cfg(any(target_os = "linux", target_os = "windows"))'.dependencies]+ort = { workspace = true, features = [+ "ndarray",+ "half",+ "api-28",+ "load-dynamic",+ "copy-dylibs",+ "webgpu",+] }++[target.'cfg(not(any(target_os = "ios", target_os = "android", target_os = "macos", target_os = "linux", target_os = "windows")))'.dependencies]+ort = { workspace = true, features = [+ "ndarray",+ "half",+ "api-28",+ "load-dynamic",+ "copy-dylibs",+] }++[dev-dependencies]+anyhow = "1"+flate2 = "1.1"+serde = { version = "1", features = ["derive"] }+serde_json.workspace = true+tar = "0.4"+tempfile = "3.12"+tokio = { version = "1", features = ["macros", "rt"] }+url.workspace = truediff --git a/rust/crates/photos/examples/ml_goldens.rs b/rust/crates/ml/examples/ml_goldens.rssimilarity index 97%rename from rust/crates/photos/examples/ml_goldens.rsrename to rust/crates/ml/examples/ml_goldens.rsindex 34aa5c6e67..1522557207 100644--- a/rust/crates/photos/examples/ml_goldens.rs+++ b/rust/crates/ml/examples/ml_goldens.rs@@ -3,7 +3,7 @@mod support;use anyhow::{Context, Result, bail};-use ente_photos::ml::golden_tooling::{+use ente_ml::golden_tooling::{GoldenMetric, GoldenModelSpec, GoldenSpecInput, measure_zero_golden_separation,render_golden_data,};@@ -35,7 +35,7 @@ async fn main() -> Result<()> {}fn usage() -> &'static str {- "usage: cargo run -p ente-photos --example ml_goldens -- \+ "usage: cargo run -p ente-ml --example ml_goldens -- \<generate|validate-zero-separation>"}diff --git a/rust/crates/photos/src/ml/assets.rs b/rust/crates/ml/src/assets.rssimilarity index 100%rename from rust/crates/photos/src/ml/assets.rsrename to rust/crates/ml/src/assets.rsdiff --git a/rust/crates/photos/src/ml/clip/image.rs b/rust/crates/ml/src/clip/image.rssimilarity index 97%rename from rust/crates/photos/src/ml/clip/image.rsrename to rust/crates/ml/src/clip/image.rsindex f20dd7ae8f..73a240b4c4 100644--- a/rust/crates/photos/src/ml/clip/image.rs+++ b/rust/crates/ml/src/clip/image.rs@@ -1,4 +1,4 @@-use crate::ml::{+use crate::{error::MlResult,models::Model,onnx, preprocess,diff --git a/rust/crates/photos/src/ml/clip/mod.rs b/rust/crates/ml/src/clip/mod.rssimilarity index 98%rename from rust/crates/photos/src/ml/clip/mod.rsrename to rust/crates/ml/src/clip/mod.rsindex 3a6441e31d..6ef411754e 100644--- a/rust/crates/photos/src/ml/clip/mod.rs+++ b/rust/crates/ml/src/clip/mod.rs@@ -6,7 +6,7 @@ pub(super) use image::run_clip_image;pub(super) use text::run_clip_text_query;pub(super) use tokenizer::tokenize_clip_text;-use crate::ml::{+use crate::{error::{MlError, MlResult},postprocess::l2_normalize,types::ClipResult,diff --git a/rust/crates/photos/src/ml/clip/text.rs b/rust/crates/ml/src/clip/text.rssimilarity index 98%rename from rust/crates/photos/src/ml/clip/text.rsrename to rust/crates/ml/src/clip/text.rsindex 01e83898b1..17e255589b 100644--- a/rust/crates/photos/src/ml/clip/text.rs+++ b/rust/crates/ml/src/clip/text.rs@@ -1,4 +1,4 @@-use crate::ml::{+use crate::{clip::tokenizer,error::{MlError, MlResult},models::Model,diff --git a/rust/crates/photos/src/ml/clip/tokenizer.rs b/rust/crates/ml/src/clip/tokenizer.rssimilarity index 99%rename from rust/crates/photos/src/ml/clip/tokenizer.rsrename to rust/crates/ml/src/clip/tokenizer.rsindex d544b9bf3c..3533259415 100644--- a/rust/crates/photos/src/ml/clip/tokenizer.rs+++ b/rust/crates/ml/src/clip/tokenizer.rs@@ -9,7 +9,7 @@ use once_cell::sync::Lazy;use plsfix::fix_text;use regex::Regex;-use crate::ml::error::{MlError, MlResult};+use crate::error::{MlError, MlResult};use super::CLIP_TEXT_TOKEN_COUNT;diff --git a/rust/crates/photos/src/ml/diagnostics.rs b/rust/crates/ml/src/diagnostics.rssimilarity index 100%rename from rust/crates/photos/src/ml/diagnostics.rsrename to rust/crates/ml/src/diagnostics.rsdiff --git a/rust/crates/photos/src/ml/error.rs b/rust/crates/ml/src/error.rssimilarity index 100%rename from rust/crates/photos/src/ml/error.rsrename to rust/crates/ml/src/error.rsdiff --git a/rust/crates/photos/src/ml/face/align.rs b/rust/crates/ml/src/face/align.rssimilarity index 99%rename from rust/crates/photos/src/ml/face/align.rsrename to rust/crates/ml/src/face/align.rsindex 472523c4ae..8e002ced64 100644--- a/rust/crates/photos/src/ml/face/align.rs+++ b/rust/crates/ml/src/face/align.rs@@ -2,7 +2,7 @@ use image::{ImageBuffer, Rgb, RgbImage};use imageproc::geometric_transformations::{Interpolation, Projection, warp_into};use nalgebra::{Matrix2, Matrix3, Vector2};-use crate::ml::{+use crate::{error::{MlError, MlResult},types::{AlignmentResult, DecodedImage, FaceDetection, FaceResult, to_face_id},};@@ -405,7 +405,7 @@ fn variance_2d(matrix: &[i32], rows: usize, cols: usize) -> f32 {#[cfg(test)]mod tests {use super::run_face_alignment;- use crate::ml::{+ use crate::{error::MlError,types::{DecodedImage, Dimensions, FaceDetection},};diff --git a/rust/crates/photos/src/ml/face/detect.rs b/rust/crates/ml/src/face/detect.rssimilarity index 98%rename from rust/crates/photos/src/ml/face/detect.rsrename to rust/crates/ml/src/face/detect.rsindex 81c6e68ba8..1f7a0e7e8e 100644--- a/rust/crates/photos/src/ml/face/detect.rs+++ b/rust/crates/ml/src/face/detect.rs@@ -1,4 +1,4 @@-use crate::ml::{+use crate::{error::{MlError, MlResult},models::Model,onnx,@@ -117,7 +117,7 @@ fn postprocess_face_tensor<T: onnx::FloatTensorData>(#[cfg(test)]mod tests {- use crate::ml::postprocess::MAX_DETECTIONS_PER_IMAGE;+ use crate::postprocess::MAX_DETECTIONS_PER_IMAGE;use super::{FaceDetection, IOU_THRESHOLD, greedy_non_max_suppression};diff --git a/rust/crates/photos/src/ml/face/embed.rs b/rust/crates/ml/src/face/embed.rssimilarity index 99%rename from rust/crates/photos/src/ml/face/embed.rsrename to rust/crates/ml/src/face/embed.rsindex 48424aa9ad..ff911a2fe0 100644--- a/rust/crates/photos/src/ml/face/embed.rs+++ b/rust/crates/ml/src/face/embed.rs@@ -1,4 +1,4 @@-use crate::ml::{+use crate::{error::{MlError, MlResult},models::Model,onnx,diff --git a/rust/crates/photos/src/ml/face/mod.rs b/rust/crates/ml/src/face/mod.rssimilarity index 100%rename from rust/crates/photos/src/ml/face/mod.rsrename to rust/crates/ml/src/face/mod.rsdiff --git a/rust/crates/photos/src/ml/face/thumbnail.rs b/rust/crates/ml/src/face/thumbnail.rssimilarity index 99%rename from rust/crates/photos/src/ml/face/thumbnail.rsrename to rust/crates/ml/src/face/thumbnail.rsindex 62f6438066..8310d05aa0 100644--- a/rust/crates/photos/src/ml/face/thumbnail.rs+++ b/rust/crates/ml/src/face/thumbnail.rs@@ -7,7 +7,7 @@ use ente_image::image_compression::{EncodedImageFormat, FACE_THUMBNAIL_JPEG_QUALITY, FACE_THUMBNAIL_MIN_DIMENSION, encode_rgb,};-use crate::ml::{+use crate::{error::{MlError, MlResult},types::DecodedImage,};@@ -250,7 +250,7 @@ mod tests {FaceBox, compute_crop_rect, face_thumbnail_dimensions, generate_face_thumbnails,select_resize_filter,};- use crate::ml::{+ use crate::{error::MlError,types::{DecodedImage, Dimensions},};diff --git a/rust/crates/photos/src/ml/indexing.rs b/rust/crates/ml/src/indexing.rssimilarity index 99%rename from rust/crates/photos/src/ml/indexing.rsrename to rust/crates/ml/src/indexing.rsindex 7f27a4a108..238f3376df 100644--- a/rust/crates/photos/src/ml/indexing.rs+++ b/rust/crates/ml/src/indexing.rs@@ -1,4 +1,4 @@-use crate::ml::{+use crate::{clip::{run_clip_image, run_clip_text_query, tokenize_clip_text as tokenize_clip_text_impl},diagnostics::{AnalysisContext, AnalysisOperation, AnalysisStage, log_public_ml_error},error::{MlError, MlResult},diff --git a/rust/crates/photos/src/ml/mod.rs b/rust/crates/ml/src/lib.rssimilarity index 100%rename from rust/crates/photos/src/ml/mod.rsrename to rust/crates/ml/src/lib.rsdiff --git a/rust/crates/photos/src/ml/models.rs b/rust/crates/ml/src/models.rssimilarity index 100%rename from rust/crates/photos/src/ml/models.rsrename to rust/crates/ml/src/models.rsdiff --git a/rust/crates/photos/src/ml/onnx.rs b/rust/crates/ml/src/onnx.rssimilarity index 99%rename from rust/crates/photos/src/ml/onnx.rsrename to rust/crates/ml/src/onnx.rsindex 32db07a588..33562fb114 100644--- a/rust/crates/photos/src/ml/onnx.rs+++ b/rust/crates/ml/src/onnx.rs@@ -1,7 +1,7 @@use ort::session::Session;use std::{fmt, path::Path};-use crate::ml::error::{MlError, MlResult};+use crate::error::{MlError, MlResult};mod coreml_cache;mod golden_test;diff --git a/rust/crates/photos/src/ml/onnx/coreml_cache.rs b/rust/crates/ml/src/onnx/coreml_cache.rssimilarity index 100%rename from rust/crates/photos/src/ml/onnx/coreml_cache.rsrename to rust/crates/ml/src/onnx/coreml_cache.rsdiff --git a/rust/crates/photos/src/ml/onnx/golden_test/data.rs b/rust/crates/ml/src/onnx/golden_test/data.rssimilarity index 99%rename from rust/crates/photos/src/ml/onnx/golden_test/data.rsrename to rust/crates/ml/src/onnx/golden_test/data.rsindex 269dda66b0..b5fd979011 100644--- a/rust/crates/photos/src/ml/onnx/golden_test/data.rs+++ b/rust/crates/ml/src/onnx/golden_test/data.rs@@ -1,7 +1,7 @@// Generated golden-test data. Do not edit by hand.//// Regenerate with:-// cargo run -p ente-photos --example ml_goldens -- generate+// cargo run -p ente-ml --example ml_goldens -- generate//// TODO: Pet models have no golden entries because they are CPU-only. Add// entries before moving them off CPU (see `MlRuntime::new` in runtime.rs).diff --git a/rust/crates/photos/src/ml/onnx/golden_test/mod.rs b/rust/crates/ml/src/onnx/golden_test/mod.rssimilarity index 100%rename from rust/crates/photos/src/ml/onnx/golden_test/mod.rsrename to rust/crates/ml/src/onnx/golden_test/mod.rsdiff --git a/rust/crates/photos/src/ml/onnx/golden_test/tooling.rs b/rust/crates/ml/src/onnx/golden_test/tooling.rssimilarity index 99%rename from rust/crates/photos/src/ml/onnx/golden_test/tooling.rsrename to rust/crates/ml/src/onnx/golden_test/tooling.rsindex c798054fea..2a230facba 100644--- a/rust/crates/photos/src/ml/onnx/golden_test/tooling.rs+++ b/rust/crates/ml/src/onnx/golden_test/tooling.rs@@ -3,7 +3,7 @@ use std::path::Path;use ort::value::ValueType;-use crate::ml::{clip, onnx};+use crate::{clip, onnx};pub use super::GoldenMetric;use super::data::GOLDEN_ENTRIES;@@ -14,7 +14,7 @@ const GENERATED_FILE_HEADER: &str = "\// Generated golden-test data. Do not edit by hand.//// Regenerate with:-// cargo run -p ente-photos --example ml_goldens -- generate+// cargo run -p ente-ml --example ml_goldens -- generate//// TODO: Pet models have no golden entries because they are CPU-only. Add// entries before moving them off CPU (see `MlRuntime::new` in runtime.rs).diff --git a/rust/crates/photos/src/ml/onnx/providers.rs b/rust/crates/ml/src/onnx/providers.rssimilarity index 99%rename from rust/crates/photos/src/ml/onnx/providers.rsrename to rust/crates/ml/src/onnx/providers.rsindex 670a34237e..228e4752f5 100644--- a/rust/crates/photos/src/ml/onnx/providers.rs+++ b/rust/crates/ml/src/onnx/providers.rs@@ -39,7 +39,7 @@ use super::golden_test;use super::model_file_label;#[cfg(any(target_os = "android", target_os = "linux", target_os = "windows"))]use super::webgpu;-use crate::ml::error::MlResult;+use crate::error::MlResult;#[cfg(any(target_os = "ios", target_os = "macos"))]const ENABLE_PERSISTENT_COREML_CACHE: bool = true;diff --git a/rust/crates/photos/src/ml/onnx/tensor.rs b/rust/crates/ml/src/onnx/tensor.rssimilarity index 99%rename from rust/crates/photos/src/ml/onnx/tensor.rsrename to rust/crates/ml/src/onnx/tensor.rsindex 08e2f54394..129ef19b6b 100644--- a/rust/crates/photos/src/ml/onnx/tensor.rs+++ b/rust/crates/ml/src/onnx/tensor.rs@@ -6,7 +6,7 @@ use ort::{value::{Tensor, TensorElementType, TensorRef, ValueType},};-use crate::ml::error::{MlError, MlResult};+use crate::error::{MlError, MlResult};use super::{SessionRunError, SessionRunResult, golden_test};diff --git a/rust/crates/photos/src/ml/onnx/webgpu.rs b/rust/crates/ml/src/onnx/webgpu.rssimilarity index 100%rename from rust/crates/photos/src/ml/onnx/webgpu.rsrename to rust/crates/ml/src/onnx/webgpu.rsdiff --git a/rust/crates/photos/src/ml/pet/align.rs b/rust/crates/ml/src/pet/align.rssimilarity index 99%rename from rust/crates/photos/src/ml/pet/align.rsrename to rust/crates/ml/src/pet/align.rsindex d98709903b..f033454cb6 100644--- a/rust/crates/photos/src/ml/pet/align.rs+++ b/rust/crates/ml/src/pet/align.rs@@ -1,4 +1,4 @@-use crate::ml::{+use crate::{error::MlResult,types::{DecodedImage, PetAlignmentResult, PetFaceDetection, PetFaceResult, to_face_id},};diff --git a/rust/crates/photos/src/ml/pet/detect.rs b/rust/crates/ml/src/pet/detect.rssimilarity index 99%rename from rust/crates/photos/src/ml/pet/detect.rsrename to rust/crates/ml/src/pet/detect.rsindex 8695c83751..a38354f3b3 100644--- a/rust/crates/photos/src/ml/pet/detect.rs+++ b/rust/crates/ml/src/pet/detect.rs@@ -1,4 +1,4 @@-use crate::ml::{+use crate::{error::{MlError, MlResult},models::Model,onnx,@@ -287,7 +287,7 @@ fn winning_pet_body_class<T: onnx::FloatTensorData>(#[cfg(test)]mod tests {- use crate::ml::postprocess::{MAX_DETECTIONS_PER_IMAGE, greedy_non_max_suppression};+ use crate::postprocess::{MAX_DETECTIONS_PER_IMAGE, greedy_non_max_suppression};use super::{BODY_IOU_THRESHOLD, BODY_MIN_SCORE, COCO_CAT, COCO_DOG, PET_FACE_IOU_THRESHOLD,diff --git a/rust/crates/photos/src/ml/pet/embed.rs b/rust/crates/ml/src/pet/embed.rssimilarity index 99%rename from rust/crates/photos/src/ml/pet/embed.rsrename to rust/crates/ml/src/pet/embed.rsindex e4c914e3f6..9a4818d462 100644--- a/rust/crates/photos/src/ml/pet/embed.rs+++ b/rust/crates/ml/src/pet/embed.rs@@ -1,4 +1,4 @@-use crate::ml::{+use crate::{error::{MlError, MlResult},models::Model,onnx,diff --git a/rust/crates/photos/src/ml/pet/mod.rs b/rust/crates/ml/src/pet/mod.rssimilarity index 100%rename from rust/crates/photos/src/ml/pet/mod.rsrename to rust/crates/ml/src/pet/mod.rsdiff --git a/rust/crates/photos/src/ml/pet/preprocess.rs b/rust/crates/ml/src/pet/preprocess.rssimilarity index 99%rename from rust/crates/photos/src/ml/pet/preprocess.rsrename to rust/crates/ml/src/pet/preprocess.rsindex ac467dbdd5..4bfde7ee54 100644--- a/rust/crates/photos/src/ml/pet/preprocess.rs+++ b/rust/crates/ml/src/pet/preprocess.rs@@ -1,4 +1,4 @@-use crate::ml::{+use crate::{error::{MlError, MlResult},types::DecodedImage,};@@ -317,7 +317,7 @@ mod tests {};use super::{PixelCrop, RgbCropResizer};- use crate::ml::types::{DecodedImage, Dimensions};+ use crate::types::{DecodedImage, Dimensions};#[test]fn crop_resize_matches_a_materialized_crop() {diff --git a/rust/crates/photos/src/ml/postprocess.rs b/rust/crates/ml/src/postprocess.rssimilarity index 100%rename from rust/crates/photos/src/ml/postprocess.rsrename to rust/crates/ml/src/postprocess.rsdiff --git a/rust/crates/photos/src/ml/preprocess.rs b/rust/crates/ml/src/preprocess.rssimilarity index 99%rename from rust/crates/photos/src/ml/preprocess.rsrename to rust/crates/ml/src/preprocess.rsindex 1b45c8c38a..91bd4912d8 100644--- a/rust/crates/photos/src/ml/preprocess.rs+++ b/rust/crates/ml/src/preprocess.rs@@ -3,7 +3,7 @@ use fast_image_resize::{images::{Image as FirImage, ImageRef as FirImageRef},};-use crate::ml::{+use crate::{clip::CLIP_IMAGE_INPUT_SIZE,error::{MlError, MlResult},onnx::PreparedF32Input,@@ -202,7 +202,7 @@ mod tests {};use super::{YOLO_INPUT_SIZE, YoloInput, preprocess_clip, preprocess_yolo};- use crate::ml::{+ use crate::{clip::CLIP_IMAGE_INPUT_SIZE,error::{MlError, MlResult},onnx::PreparedF32Input,diff --git a/rust/crates/photos/src/ml/runtime.rs b/rust/crates/ml/src/runtime.rssimilarity index 99%rename from rust/crates/photos/src/ml/runtime.rsrename to rust/crates/ml/src/runtime.rsindex 70a9d81fec..913b9d7a76 100644--- a/rust/crates/photos/src/ml/runtime.rs+++ b/rust/crates/ml/src/runtime.rs@@ -5,7 +5,7 @@ use std::{use once_cell::sync::Lazy;-use crate::ml::{+use crate::{error::{MlError, MlResult},models::{Model, ModelPaths},onnx,diff --git a/rust/crates/photos/src/ml/types.rs b/rust/crates/ml/src/types.rssimilarity index 100%rename from rust/crates/photos/src/ml/types.rsrename to rust/crates/ml/src/types.rsdiff --git a/rust/crates/photos/src/ml/vector_db.rs b/rust/crates/ml/src/vector_db.rssimilarity index 100%rename from rust/crates/photos/src/ml/vector_db.rsrename to rust/crates/ml/src/vector_db.rsdiff --git a/rust/crates/photos/tests/ml_indexing.rs b/rust/crates/ml/tests/ml_indexing.rssimilarity index 100%rename from rust/crates/photos/tests/ml_indexing.rsrename to rust/crates/ml/tests/ml_indexing.rsdiff --git a/rust/crates/photos/tests/support/ml_indexing.rs b/rust/crates/ml/tests/support/ml_indexing.rssimilarity index 99%rename from rust/crates/photos/tests/support/ml_indexing.rsrename to rust/crates/ml/tests/support/ml_indexing.rsindex 8aba5f83c9..b6ce3f78b8 100644--- a/rust/crates/photos/tests/support/ml_indexing.rs+++ b/rust/crates/ml/tests/support/ml_indexing.rs@@ -6,7 +6,7 @@ use std::{use anyhow::{Context, Result, bail};use ente_assets::{Asset, AssetFile, AssetStore, download};-use ente_photos::ml::{+use ente_ml::{ModelPaths,error::MlError,indexing::{@@ -401,7 +401,7 @@ impl GoldenTestAssets {}pub(crate) fn golden_data_path() -> Result<PathBuf> {- Ok(PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("src/ml/onnx/golden_test/data.rs"))+ Ok(PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("src/onnx/golden_test/data.rs"))}}diff --git a/rust/crates/photos/tests/support/mod.rs b/rust/crates/ml/tests/support/mod.rssimilarity index 100%rename from rust/crates/photos/tests/support/mod.rsrename to rust/crates/ml/tests/support/mod.rsdiff --git a/rust/crates/photos/Cargo.toml b/rust/crates/photos/Cargo.tomlindex 95c1e71ef2..eb175ac2da 100644--- a/rust/crates/photos/Cargo.toml+++ b/rust/crates/photos/Cargo.toml@@ -2,86 +2,8 @@name = "ente-photos"edition = "2024"-[features]-default = []-ml-assets = []-[dependencies]-ente-assets.workspace = true-ente-image.workspace = true-fast_image_resize = { version = "5.5.0", features = ["image", "rayon"] }-half = "2.1"-html-escape = "0.2.13"-image = { version = "0.25.5", default-features = true }-imageproc = "0.25.0"-log.workspace = true-nalgebra = "0.33.2"-once_cell = "1.20.2"-plsfix = "0.1.8"quick-xml = "0.41"-regex = "1.11.1"-thiserror.workspace = true-# The FRB photos bridge calls the SimSIMD symbol exported by usearch 2.21.x.-# Newer usearch releases switched that implementation to numkong symbols.-usearch = { version = "=2.21.4", optional = true }--# Cargokit sets ORT_LIB_PATH to Ente's verified iOS archive.-[target.'cfg(target_os = "ios")'.dependencies]-ort = { workspace = true, features = [- "std",- "ndarray",- "half",- "coreml",- "api-28",-] }--[target.'cfg(target_os = "android")'.dependencies]-ash = { version = "0.38", default-features = false, features = ["loaded"] }-ort = { workspace = true, features = [- "ndarray",- "half",- "api-28",- "load-dynamic",- "copy-dylibs",- "webgpu",- "xnnpack",-] }--[target.'cfg(target_os = "macos")'.dependencies]-ort = { workspace = true, features = [- "ndarray",- "half",- "coreml",- "api-28",- "load-dynamic",- "copy-dylibs",-] }--[target.'cfg(any(target_os = "linux", target_os = "windows"))'.dependencies]-ort = { workspace = true, features = [- "ndarray",- "half",- "api-28",- "load-dynamic",- "copy-dylibs",- "webgpu",-] }--[target.'cfg(not(any(target_os = "ios", target_os = "android", target_os = "macos", target_os = "linux", target_os = "windows")))'.dependencies]-ort = { workspace = true, features = [- "ndarray",- "half",- "api-28",- "load-dynamic",- "copy-dylibs",-] }[dev-dependencies]-anyhow = "1"-flate2 = "1.1"-serde = { version = "1", features = ["derive"] }-serde_json.workspace = true-tar = "0.4"tempfile = "3.12"-tokio = { version = "1", features = ["macros", "rt"] }-url.workspace = truediff --git a/rust/crates/photos/src/lib.rs b/rust/crates/photos/src/lib.rsindex 032470eb92..156da6c8ed 100644--- a/rust/crates/photos/src/lib.rs+++ b/rust/crates/photos/src/lib.rs@@ -1,4 +1,3 @@-pub mod ml;pub mod motion_photo;pub use motion_photo::{