os.makedirs(save_dir, exist_ok=True) before writing uploaded file,
so the uploads/ dir is auto-created even when not present on disk.
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>