Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 29 additions & 2 deletions backend/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,28 @@
import ai_model
import os

from pydantic import BaseModel
from typing import List, Optional

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]

os.environ["KMP_DUPLICATE_LIB_OK"] = "TRUE"

app = FastAPI()
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=["*"],
Expand All @@ -14,7 +33,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()

Expand Down