diff --git a/backend/.env.example b/backend/.env.example new file mode 100644 index 0000000..159b8bb --- /dev/null +++ b/backend/.env.example @@ -0,0 +1 @@ +KMP_DUPLICATE_LIB_OK=TRUE diff --git a/backend/main.py b/backend/main.py index e9288d1..c97ac2b 100644 --- a/backend/main.py +++ b/backend/main.py @@ -3,9 +3,30 @@ import ai_model import os -os.environ["KMP_DUPLICATE_LIB_OK"] = "TRUE" +from pydantic import BaseModel +from typing import List, Optional +from dotenv import load_dotenv +load_dotenv() -app = FastAPI() +class Observation(BaseModel): + label: str + value: str + +class AnalysisResponse(BaseModel): + filename: str + diagnosis: str + confidence: float + risk_level: str + heatmap: Optional[str] = None + observations: List[Observation] + + + +app = FastAPI( + title="Healthway Diagnostics - Neural Retina API", + version="1.0.0", + description="EfficientNet-B0 powered Diabetic Retinopathy detection with Grad-CAM explainability." +) app.add_middleware( CORSMiddleware, allow_origins=["*"], @@ -14,7 +35,15 @@ allow_headers=["*"], ) -@app.post("/analyze") +@app.post( + "/analyze", + summary="Analyze a retinal fundus image", + response_model=AnalysisResponse, + responses={ + 400: {"description": "Invalid or non-retinal image"}, + 500: {"description": "Model inference error"} + } +) async def analyze_image(file: UploadFile = File(...)): image_bytes = await file.read()