K0nkere / DL_Dice-detection-project

DnD dice detection with CNN and transfer learning / Project for ML Bookcamp
0 stars 0 forks source link

How to: Fast API implementation #7

Open K0nkere opened 1 year ago

K0nkere commented 1 year ago

class Img(BaseModel): url: Optional[str] = None class Config: schema_extra = { "example": { "url": "https://test_url.jpg" }
}

app = FastAPI()

@app.get("/ping") def ping(): return {"message": "PONG"}

@app.post("/predict") def predict(image: Img):

pred = model.predict(X)

result = {
  'Healthy': float(pred[0][0]),
  'Rust': float(pred[0][2]),
}

return result