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