Pulmora AI is an educational chest X-ray analysis app built with Next.js, FastAPI, and PyTorch.
I built it as a full-stack ML project that goes beyond a static demo page. A user can upload a chest X-ray, send it to a live backend, get a real model prediction, and inspect a Grad-CAM heatmap that shows which regions influenced the result.
- Live demo: https://pulmora-ai.vercel.app/
- Backend API: https://pulmora-ai-1.onrender.com/
- Health check: https://pulmora-ai-1.onrender.com/health
- GitHub repository: https://github.com/ANSHUL-REAL/pulmora-ai
- trained PyTorch model for
NormalvsPneumoniaclassification - Grad-CAM heatmap generation for visual explainability
- Next.js frontend with upload, results, and metrics views
- FastAPI backend for inference and metadata
- live deployment on Vercel and Render
Pulmora AI is intended for educational and portfolio use only. It is not a medical device and must not be used for clinical diagnosis or treatment decisions.
- accepts a chest X-ray upload
- validates file type and size
- runs model inference on the backend
- returns prediction confidence
- generates a Grad-CAM heatmap
- displays model metrics and project context in the UI
frontend/- Next.js App Router frontendbackend/- FastAPI inference and metrics APImodel/- model metadata and checkpoint locationdocs/- PRD and SRS
cd frontend
npm install
npm run devSet NEXT_PUBLIC_API_URL in frontend/.env.local if the backend is not running on http://127.0.0.1:8000.
cd backend
python -m venv .venv
.venv\Scripts\Activate.ps1
pip install -r requirements.txt
uvicorn app.main:app --reloadSet MODEL_CHECKPOINT_PATH to your .pt or .pth file before using real inference.
- The backend keeps uploads in memory only.
- Metrics are loaded from
model/metrics.sample.jsonby default. - The app is for educational use only and does not provide clinical diagnosis.
Place a dataset in this structure:
dataset-root/
train/
NORMAL/
PNEUMONIA/
val/
NORMAL/
PNEUMONIA/
If val/ is missing, the training script creates a deterministic validation split from train/.
Run training from the repo root:
python model\train_model.py --dataset-root D:\path\to\dataset-root --epochs 8This writes:
model/checkpoint.pthmodel/metrics.generated.json
Once those files exist, the backend can serve real predictions and real metrics instead of sample metadata.
This repo is set up for a portfolio-friendly split deployment:
frontend/on Vercelbackend/on Rendermodel/checkpoint.pthcommitted in the repo so the live backend can load the trained model
From the repo root:
git init
git add .
git commit -m "Pulmora AI initial commit"
git branch -M main
git remote add origin https://github.com/YOUR-USERNAME/pulmora-ai.git
git push -u origin mainCreate a Render Web Service from the repo root with:
- Root Directory: leave empty
- Build Command:
pip install -r backend/requirements.txt- Start Command:
cd backend && uvicorn app.main:app --host 0.0.0.0 --port $PORTSet these environment variables in Render:
MODEL_CHECKPOINT_PATH=/opt/render/project/src/model/checkpoint.pth
ALLOW_ORIGINS=https://YOUR-FRONTEND.vercel.app
If you also want preview deployments later, add them as a comma-separated list in ALLOW_ORIGINS.
Import the same repo into Vercel with:
- Framework: Next.js
- Root Directory:
frontend
Set this environment variable in Vercel:
NEXT_PUBLIC_API_URL=https://YOUR-BACKEND.onrender.com
- Push the repo to GitHub
- Deploy the backend on Render
- Copy the Render backend URL
- Add that URL to the Vercel
NEXT_PUBLIC_API_URLvariable - Deploy the frontend on Vercel
- Copy the Vercel frontend URL
- Add that URL to Render
ALLOW_ORIGINS - Redeploy the backend
- Good fit for a portfolio project, demo, and recruiter walkthrough
- Real trained model inference when
model/checkpoint.pthis present - Cold starts and slow first requests are normal on free Render tiers
- Educational only: not a clinical or production medical system