Spaces:
Sleeping
Sleeping
File size: 542 Bytes
6b7260e |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
from fastapi import FastAPI, UploadFile, File, HTTPException
from PIL import Image
from predict_helper import predict_damage
app = FastAPI(
title="Car Damage Detection API",
version="1.0"
)
@app.get("/")
def health():
return {"status": "API is running"}
@app.post("/predict_damage")
async def predict(image: UploadFile = File(...)):
try:
img = Image.open(image.file)
except Exception:
raise HTTPException(status_code=400, detail="Invalid image file")
result = predict_damage(img)
return result
|