YAML Metadata Warning:empty or missing yaml metadata in repo card
Check out the documentation for more information.
π₯ MedGPT β Medical Visual Question Answering
AI-powered medical image analysis with visual explanations
Features β’ Architecture β’ Installation β’ Usage β’ Results β’ Datasets
β¨ Features
- Vision-Language AI β Powered by Qwen3-VL-8B fine-tuned on 150K+ medical VQA samples
- Grad-CAM Heatmaps β Visual explanations showing where the model focuses
- Multi-Modality β X-ray, CT, MRI, Ultrasound, and Pathology slides
- React + Vite Frontend β Modern, responsive web interface with glassmorphism design
- FastAPI Backend β GPU-accelerated inference with REST API
- Dashboard β Interactive training curves, accuracy charts, and metrics visualizations
ποΈ Architecture
MedGPT/
βββ frontend/ # React + Vite frontend
β βββ src/
β β βββ pages/ # Home, Analyze, Dashboard, About
β β βββ components/ # Navbar, Footer
β β βββ styles/ # Global CSS design system
β βββ dist/ # Production build
βββ backend/ # FastAPI server
β βββ server.py # API endpoints + React SPA serving
βββ models/ # Model definitions
β βββ medgpt.py # MedGPT model class
β βββ explainability.py # Grad-CAM implementation
βββ training/ # Training pipeline
β βββ train.py # Pre-training + fine-tuning script
β βββ evaluate.py # Evaluation metrics
β βββ visualize.py # Generate training curves & charts
βββ inference/ # Inference utilities
β βββ predict.py # CLI prediction tool
βββ data/ # Datasets
β βββ prepare_data.py # Download & preprocess datasets
β βββ dataset.py # PyTorch dataset classes
β βββ processed/ # Processed JSON splits
βββ configs/
β βββ config.yaml # All configuration settings
βββ checkpoints/ # Trained model checkpoints
β βββ finetune/
β βββ best_model/ # Best LoRA adapter
βββ results/ # Evaluation results & visualizations
βββ figures/ # Training curves, charts, heatmaps
π Results
| Metric | Score |
|---|---|
| Overall Accuracy | 78.5% |
| Yes/No Accuracy | 87.1% |
| Open-ended Accuracy | 73.9% |
| BLEU-1 | 82.8% |
| ROUGE-L | 80.6% |
| Token F1 | 81.2% |
Training Details
| Parameter | Value |
|---|---|
| Base Model | Qwen3-VL-8B-Instruct |
| Fine-tuning Method | LoRA (rank=64, alpha=128) |
| Trainable Parameters | 210M / 9B (2.3%) |
| Precision | bfloat16 |
| Training Epochs | 3 |
| Hardware | NVIDIA H200 (141GB VRAM) |
| Training Time | ~5.6 hours |
π¦ Datasets
| Dataset | Samples | Stage |
|---|---|---|
| PMC-VQA | ~140K | Pre-training |
| VQA-RAD | ~3.5K | Fine-tuning |
| SLAKE | ~14K | Fine-tuning |
| PathVQA | ~32K | Fine-tuning |
π Installation
Prerequisites
- Python 3.10+
- NVIDIA GPU with 24GB+ VRAM (48GB+ recommended)
- Node.js 18+ (for frontend)
Setup
# Clone from HuggingFace
git lfs install
git clone https://huggingface.co/bhargavvz/MedGPT
cd MedGPT
# Install Python dependencies
pip install -r requirements.txt
# Download datasets
python data/prepare_data.py --datasets all --output_dir data/processed --validate
# Build frontend
cd frontend && npm install && npm run build && cd ..
π» Usage
Web Application
# Start the server (API + React frontend on port 8000)
python backend/server.py
# Open: http://localhost:8000
CLI Inference
python inference/predict.py \
--image path/to/xray.jpg \
--question "What abnormality is visible?" \
--adapter_path checkpoints/finetune/best_model
Training
# Full pipeline (pre-training + fine-tuning)
python training/train.py --stage all
# Fine-tuning only
python training/train.py --stage finetune
Evaluation
python training/evaluate.py \
--adapter_path checkpoints/finetune/best_model \
--test_file data/processed/finetune_test.json \
--output_file results/eval_results.json
Generate Visualizations
python training/visualize.py --output_dir results/figures
π³ Docker
docker compose up -d
# Access at http://localhost:8000
π API Endpoints
| Method | Endpoint | Description |
|---|---|---|
GET |
/api/health |
Health check & model status |
POST |
/api/predict |
Image + question β answer + heatmap |
POST |
/api/load |
Load/reload model |
GET |
/api/metrics |
Evaluation results |
GET |
/api/training-history |
Training loss curves |
π Tech Stack
- Model: Qwen3-VL-8B + LoRA
- Backend: FastAPI + Uvicorn
- Frontend: React + Vite + Framer Motion + Recharts
- Training: PyTorch + HuggingFace Transformers
- Explainability: Grad-CAM
- Deployment: Docker + NVIDIA CUDA
β οΈ Disclaimer
MedGPT is a research and educational tool. It is NOT intended for clinical diagnosis or medical decision-making. Always consult qualified healthcare professionals for medical advice.
π License
This project is for educational and research purposes only.
Built with β€οΈ by Bhargav
Inference Providers NEW
This model isn't deployed by any Inference Provider. π Ask for provider support