INNER CODE UNIT · Python
get_image
virajmavani/semi-auto-image-annotation-tool · web/backend/main.py:243
async def get_image(filename: str):
"""Get uploaded image"""
validate_filename(filename)
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: