Spaces:
Build error
Build error
| from fastapi import FastAPI, File, UploadFile | |
| from predict_glaucoma import predict_glaucoma | |
| import tempfile | |
| app = FastAPI() | |
| 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} | |