INNER CODE UNIT · Python
file_path
virajmavani/semi-auto-image-annotation-tool · web/backend/main.py:246
file_path = (UPLOAD_DIR / filename).resolve()
if not file_path.is_relative_to(UPLOAD_DIR.resolve()):
raise HTTPException(status_code=400, detail="Invalid filename")
if not file_path.exists():
raise HTTPException(status_code=404, detail="Image not found")
return FileResponse(file_path)
@app.post("/api/detect")
async def detect_objects(request: DetectionRequest):
"""Run object detection on an image"""
async with _model_lock:
model = current_model
if model is None:
raise HTTPException(status_code=500, detail="Model not loaded")
try: