- model.py: predict_image accepts 2-D ref_emb (cluster centers);
sim = max cosine similarity to any center; thres default 0.55
- main.py: load cluster_centers.npy if present, else avg12_embedding.npy
- scripts/compute_cluster_centers.py: extract embeddings from all
training images, k-means k=5, save cluster_centers.npy
Run script once to generate cluster_centers.npy, then redeploy.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Fix 5 bugs in upload validation, inference, and file cleanup
- Bug1: Replace second-precision timestamp with uuid suffix to prevent
filename collision under concurrent requests
- Bug2: Add file extension whitelist in save_uploaded_file; raise
ValueError for unsupported types before writing to disk
- Bug3: Remove misleading comment claiming SIM_THRES default is 0.75
- Bug4: Explicitly check model output keys and raise KeyError instead
of silently falling back to positional indices
- Bug5: Call os.remove(saved_path) in preprocessing failure path to
prevent orphaned files accumulating in uploads/
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>