π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Remove dead detect_species and fix silent crop truncation
Amrithesh Kakkoth Ente9cc9e8154298
diff --git a/mobile/apps/photos/rust/src/ml/pet/detect.rs b/mobile/apps/photos/rust/src/ml/pet/detect.rsindex 39effccde3..d337e6b987 100644--- a/mobile/apps/photos/rust/src/ml/pet/detect.rs+++ b/mobile/apps/photos/rust/src/ml/pet/detect.rs@@ -200,24 +200,6 @@ pub fn run_pet_body_detection(Ok(naive_nms_pet_body(detections, BODY_IOU_THRESHOLD))}-/// Auto-detect which species is dominant in the body detections.-///-/// Returns 0 for dog, 1 for cat based on which class has more/higher confidence detections.-pub fn detect_species(body_detections: &[PetBodyDetection]) -> u8 {- let mut dog_score: f32 = 0.0;- let mut cat_score: f32 = 0.0;-- for det in body_detections {- match det.coco_class {- COCO_DOG => dog_score += det.score,- COCO_CAT => cat_score += det.score,- _ => {}- }- }-- if cat_score > dog_score { 1 } else { 0 }-}-fn correct_for_maintained_aspect_ratio_3kp(box_xyxy: &mut [f32; 4],keypoints: &mut [[f32; 2]; 3],diff --git a/mobile/apps/photos/rust/src/ml/pet/preprocess.rs b/mobile/apps/photos/rust/src/ml/pet/preprocess.rsindex 5a6f6fb432..97d3ad76d1 100644--- a/mobile/apps/photos/rust/src/ml/pet/preprocess.rs+++ b/mobile/apps/photos/rust/src/ml/pet/preprocess.rs@@ -107,9 +107,13 @@ pub fn extract_crop(for row in y1..y2 {let row_start = ((row * img_w + x1) * 3) as usize;let row_end = ((row * img_w + x2) * 3) as usize;- if row_end <= decoded.rgb.len() {- crop.extend_from_slice(&decoded.rgb[row_start..row_end]);+ if row_end > decoded.rgb.len() || row_start > decoded.rgb.len() {+ return Err(MlError::Preprocess(format!(+ "crop row {} out of bounds: start={}, end={}, buffer_len={}",+ row, row_start, row_end, decoded.rgb.len()+ )));}+ crop.extend_from_slice(&decoded.rgb[row_start..row_end]);}Ok((crop, crop_w, crop_h))