Skip to content
Open
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions backend/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
KMP_DUPLICATE_LIB_OK=TRUE
35 changes: 32 additions & 3 deletions backend/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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=["*"],
Expand All @@ -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()

Expand Down