Gopal05's picture
Update README.md
12e3308 verified
|
Raw History Blame Contribute Delete
3.31 kB
---
license: mit
title: Radiology Report Generation System
sdk: docker
emoji: 🏒
colorFrom: blue
colorTo: green
---
# Radiology AI Report Generation System v2.0
AI-powered radiology report generation using BLIP-2 vision + Phi-2 LLM fine-tuned on real radiology reports.
## What it does
- Upload any radiology image (X-ray, CT, MRI, Ultrasound, PET, Mammography, etc.)
- BLIP-2 reads the actual image and describes what it sees
- Phi-2 (fine-tuned on 227,835 real radiology reports) generates a structured report
- Outputs: FINDINGS, IMPRESSION, RECOMMENDATIONS + UMLS/ICD-10/SNOMED CT codes
## Requirements
- Windows 10/11
- Python 3.10
- NVIDIA GPU with 8GB+ VRAM (RTX 4060 or better)
- CUDA 12.8
- 20GB free disk space (for models)
---
## Quick Start
### Step 1 β€” Setup (run once)
```
Double-click: setup.bat
```
This creates venv, installs all dependencies, verifies GPU.
### Step 2 β€” Fine-tune (run once, ~35 minutes)
```
Double-click: run_training.bat
```
Downloads unsloth/Radiology_mini (227,835 real reports) and fine-tunes Phi-2.
### Step 3 β€” Start the system
Terminal 1:
```
run_backend.bat
```
Terminal 2:
```
run_frontend.bat
```
### Step 4 β€” Use the system
Open browser: http://localhost:7860
---
## Manual commands (if .bat files don't work)
```bash
cd D:\radiology_ai_system
venv\Scripts\activate
# Backend
set USE_4BIT=true
set ENABLE_VISION_CAPTION=true
uvicorn backend.main:app --reload --host 0.0.0.0 --port 8000
# Frontend (new terminal)
venv\Scripts\activate
python frontend/ui.py
# Fine-tuning (Git Bash)
python training/train_unsloth.py --max_steps 300
```
---
## Project Structure
```
radiology_ai_system/
β”œβ”€β”€ backend/
β”‚ β”œβ”€β”€ main.py # FastAPI endpoints
β”‚ β”œβ”€β”€ model_loader.py # BLIP-2 + Phi-2 loading
β”‚ β”œβ”€β”€ preprocessing.py # Image preprocessing (9 modalities)
β”‚ β”œβ”€β”€ report_generator.py # Report generation + parsing
β”‚ β”œβ”€β”€ validation_module.py # Report quality scoring
β”‚ └── medical_coding.py # UMLS/ICD-10/SNOMED CT
β”œβ”€β”€ frontend/
β”‚ └── ui.py # Gradio UI
β”œβ”€β”€ training/
β”‚ β”œβ”€β”€ train_unsloth.py # Fine-tuning on Radiology_mini
β”‚ β”œβ”€β”€ prepare_dataset.py # Dataset preparation
β”‚ └── evaluate_model.py # Model evaluation
β”œβ”€β”€ models/
β”‚ β”œβ”€β”€ slm_model/ # Phi-2 cached here
β”‚ β”‚ └── lora_adapter/ # Fine-tuned LoRA adapter saved here
β”‚ └── vision_encoder/ # BLIP-2 cached here
β”œβ”€β”€ setup.bat # One-time setup
β”œβ”€β”€ run_backend.bat # Start backend
β”œβ”€β”€ run_frontend.bat # Start frontend
β”œβ”€β”€ run_training.bat # Fine-tune model
└── requirements.txt
```
---
## VRAM Usage
| Component | VRAM |
|---------------|--------|
| Phi-2 (4-bit) | ~2.0GB |
| BLIP-2 | ~3.5GB |
| Total | ~5.5GB |
| Available | 8.6GB βœ… |
---
## API Endpoints
- POST /api/generate-report β€” Generate report from image
- GET /api/report/{id} β€” Get stored report
- GET /api/export/pdf/{id} β€” Download PDF
- GET /api/export/json/{id} β€” Download JSON
- GET /api/health β€” System health
- GET /docs β€” Swagger UI (http://localhost:8000/docs)