AdarshDRC commited on
Commit
ea211d5
·
1 Parent(s): 6a1ae64

feat : camera

Browse files
Files changed (1) hide show
  1. src/api/search.py +8 -2
src/api/search.py CHANGED
@@ -350,6 +350,12 @@ async def search_by_face(
350
  user_id=user_id or "anonymous", ip=ip)
351
  raise HTTPException(400, "No face detected in provided images")
352
 
 
 
 
 
 
 
353
  # Fuse embeddings: front weighted higher
354
  weights = {"front": 0.5, "left": 0.25, "right": 0.25}
355
  arcface_vectors = []
@@ -379,7 +385,7 @@ async def search_by_face(
379
  fused_adaface = fused_adaface / (np.linalg.norm(fused_adaface) + 1e-7)
380
  has_adaface = True
381
 
382
- # Build synthetic face vector dict for query
383
  fv = {
384
  "face_idx": 0,
385
  "det_score": float(np.mean(det_scores)),
@@ -388,7 +394,7 @@ async def search_by_face(
388
  "adaface_vector": fused_adaface.tolist() if has_adaface else None,
389
  "bbox": [0, 0, 0, 0],
390
  "face_width_px": 0,
391
- "face_crop": "",
392
  }
393
 
394
  inference_ms = round((time.perf_counter() - start) * 1000)
 
350
  user_id=user_id or "anonymous", ip=ip)
351
  raise HTTPException(400, "No face detected in provided images")
352
 
353
+ # Get front face crop for results display (use if available, fallback to any angle)
354
+ front_face_crop = (
355
+ face_vectors_by_angle.get("front", {}).get("face_crop", "") or
356
+ next((v.get("face_crop", "") for v in face_vectors_by_angle.values() if v.get("face_crop")), "")
357
+ )
358
+
359
  # Fuse embeddings: front weighted higher
360
  weights = {"front": 0.5, "left": 0.25, "right": 0.25}
361
  arcface_vectors = []
 
385
  fused_adaface = fused_adaface / (np.linalg.norm(fused_adaface) + 1e-7)
386
  has_adaface = True
387
 
388
+ # Build synthetic face vector dict for query (include front face crop for UI display)
389
  fv = {
390
  "face_idx": 0,
391
  "det_score": float(np.mean(det_scores)),
 
394
  "adaface_vector": fused_adaface.tolist() if has_adaface else None,
395
  "bbox": [0, 0, 0, 0],
396
  "face_width_px": 0,
397
+ "face_crop": front_face_crop,
398
  }
399
 
400
  inference_ms = round((time.perf_counter() - start) * 1000)