DHEIVER's picture
Update app.py
160b840
raw
history blame
608 Bytes
from fastapi import FastAPI, File, UploadFile
from predict_glaucoma import predict_glaucoma
import tempfile
app = FastAPI()
@app.post("/predict/")
async def predict(file: UploadFile = File(...)):
model_path = "final_model.h5"
# Salve a imagem em um arquivo temporário
with tempfile.NamedTemporaryFile(suffix=".jpg") as tmp_file:
tmp_file.write(await file.read())
tmp_file.flush()
# Faça a previsão usando a função 'predict_glaucoma'
prediction = predict_glaucoma(tmp_file.name, model_path)
return {"probabilidade_de_glaucoma": prediction * 100}