π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Use one indexing model selection order
laurenspriem36acc38bd062
diff --git a/rust/crates/photos/src/ml/assets.rs b/rust/crates/photos/src/ml/assets.rsindex 67c65bd89c..a8758ea2dc 100644--- a/rust/crates/photos/src/ml/assets.rs+++ b/rust/crates/photos/src/ml/assets.rs@@ -44,7 +44,7 @@ fn model_asset(model: Model) -> Asset {}pub fn indexing_assets(run_faces: bool, run_clip: bool, run_pets: bool) -> Vec<Asset> {- models::enabled_indexing_models(run_faces, run_clip, run_pets)+ models::selected_indexing_models(run_faces, run_clip, run_pets).map(model_asset).collect()}@@ -56,7 +56,7 @@ pub fn indexing_model_paths(run_pets: bool,) -> ModelPaths {let mut model_paths = ModelPaths::default();- for model in models::enabled_indexing_models(run_faces, run_clip, run_pets) {+ for model in models::selected_indexing_models(run_faces, run_clip, run_pets) {*model_paths.get_mut(model) = model_path(store, model);}model_pathsdiff --git a/rust/crates/photos/src/ml/indexing.rs b/rust/crates/photos/src/ml/indexing.rsindex cd1d54239e..7f27a4a108 100644--- a/rust/crates/photos/src/ml/indexing.rs+++ b/rust/crates/photos/src/ml/indexing.rs@@ -282,7 +282,7 @@ pub fn tokenize_clip_text(text: &str, vocab_path: &str) -> MlResult<Vec<i32>> {}fn validate_request_model_paths(req: &AnalyzeImageRequest) -> MlResult<()> {- let missing = models::required_indexing_models(req.run_faces, req.run_clip, req.run_pets)+ let missing = models::selected_indexing_models(req.run_faces, req.run_clip, req.run_pets).filter(|&model| req.model_paths.get(model).trim().is_empty()).map(Model::path_label).collect::<Vec<_>>();diff --git a/rust/crates/photos/src/ml/models.rs b/rust/crates/photos/src/ml/models.rsindex 4e4acfcd50..f47ca7762a 100644--- a/rust/crates/photos/src/ml/models.rs+++ b/rust/crates/photos/src/ml/models.rs@@ -30,18 +30,6 @@ impl Model {];pub(crate) const INDEXING: [Self; 9] = [- Self::FaceDetection,- Self::FaceEmbedding,- Self::ClipImage,- Self::PetFaceDetection,- Self::PetFaceEmbeddingDog,- Self::PetFaceEmbeddingCat,- Self::PetBodyDetection,- Self::PetBodyEmbeddingDog,- Self::PetBodyEmbeddingCat,- ];-- const INDEXING_PATH_VALIDATION: [Self; 9] = [Self::FaceDetection,Self::FaceEmbedding,Self::ClipImage,@@ -148,7 +136,7 @@ impl ModelPaths {}}-pub(crate) fn enabled_indexing_models(+pub(crate) fn selected_indexing_models(run_faces: bool,run_clip: bool,run_pets: bool,@@ -158,16 +146,6 @@ pub(crate) fn enabled_indexing_models(.filter(move |&model| indexing_model_is_enabled(model, run_faces, run_clip, run_pets))}-pub(crate) fn required_indexing_models(- run_faces: bool,- run_clip: bool,- run_pets: bool,-) -> impl Iterator<Item = Model> {- Model::INDEXING_PATH_VALIDATION- .into_iter()- .filter(move |&model| indexing_model_is_enabled(model, run_faces, run_clip, run_pets))-}-fn indexing_model_is_enabled(model: Model,run_faces: bool,@@ -194,7 +172,7 @@ mod tests {use super::*;#[test]- fn model_catalog_order_and_metadata_are_stable() {+ fn model_order_and_labels_are_stable() {let expected = [(Model::FaceDetection,@@ -303,32 +281,25 @@ mod tests {for model in Model::ALL {assert_eq!(indexes.contains(&model.index()), model != Model::ClipText);}- assert_eq!(- Model::INDEXING_PATH_VALIDATION- .into_iter()- .map(Model::index)- .collect::<HashSet<_>>(),- indexes- );}#[test]- fn enabled_indexing_models_follow_request_flags() {+ fn selected_indexing_models_follow_request_flags() {assert_eq!(- enabled_indexing_models(true, false, false).collect::<Vec<_>>(),+ selected_indexing_models(true, false, false).collect::<Vec<_>>(),[Model::FaceDetection, Model::FaceEmbedding]);assert_eq!(- enabled_indexing_models(false, true, false).collect::<Vec<_>>(),+ selected_indexing_models(false, true, false).collect::<Vec<_>>(),[Model::ClipImage]);assert_eq!(- enabled_indexing_models(false, false, true).collect::<Vec<_>>(),+ selected_indexing_models(false, false, true).collect::<Vec<_>>(),[Model::PetFaceDetection,+ Model::PetBodyDetection,Model::PetFaceEmbeddingDog,Model::PetFaceEmbeddingCat,- Model::PetBodyDetection,Model::PetBodyEmbeddingDog,Model::PetBodyEmbeddingCat,]