File size: 498 Bytes
329a25c |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
from fastapi import FastAPI, UploadFile, File
from fastapi.responses import JSONResponse
from PIL import Image
import io
app = FastAPI()
@app.get("/")
def root():
return {"message": "API is running"}
@app.post("/predict")
async def predict(img: UploadFile = File(...)):
image = Image.open(io.BytesIO(await img.read()))
# Run your ML model here
result = "Anomaly: Shadowing" # Replace this with your prediction logic
return JSONResponse(content={"result": result})
|