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})