InfoMeds.AI helps patients understand their medical reports and prescriptions through Explainable AI (XAI). It reads uploaded lab reports and handwritten prescriptions with OCR, analyzes them with fine-tuned clinical transformer models, and explains the results in plain language. It also tracks a patient's health over time.
- Input: Upload a medical report image (JPG/PNG).
- OCR: EasyOCR for text detection and Microsoft TrOCR for handwriting, with GPT-4o Vision as an advanced pipeline for difficult handwritten documents.
- NLP / Deep Learning:
- BioBERT multi-task model (fine-tuned from
Bio_ClinicalBERT): named-entity recognition and dosage tagging. - Hybrid lab classifier: labels each parameter High, Low or Normal.
- LLM summary: a patient-friendly clinical summary. If the cloud AI is unavailable, a rule-based engine takes over.
- BioBERT multi-task model (fine-tuned from
- Education: each parameter card explains what the biomarker is (e.g. "Neutrophils: soldiers against bacteria").
- Extracts the patient, date and medications (dosage, frequency, duration) from handwritten prescriptions.
- Checks for dosage clashes and keeps a list of scanned prescriptions.
- Medication Scheduler builds a daily schedule from the extracted medicines.
- Medical Archive: stores every report and lets you reopen any past analysis.
- Trend analysis: compares new results with earlier ones (e.g. "Hemoglobin improved from 11.2 to 13.5").
- Record mapping: links related reports and generates a correlation analysis across them.
- Personalized dashboard with a 0–100 Health Score based on the latest findings.
- AI Chat Assistant that answers questions using the context of a report.
- PDF export of analysis results.
| Layer | Technologies |
|---|---|
| Frontend | React 19 (Vite), Tailwind CSS + custom CSS |
| Backend | FastAPI, Uvicorn, SQLite (patient_history.db) |
| Auth | JWT (python-jose), bcrypt password hashing |
| AI / ML | PyTorch, Hugging Face Transformers (Bio_ClinicalBERT), EasyOCR, TrOCR, OpenAI GPT-4o |
| Reports | ReportLab (PDF) |
- Python 3.11
- Node.js v20.19+
- An OpenAI API key, needed for GPT-4o OCR and summaries
- Optional: an NVIDIA GPU with CUDA, for training
git clone https://github.com/kartz404/XAI_MedicalAnalysis.git
cd XAI_MedicalAnalysiscd backend
python -m venv venv
venv\Scripts\activate # Windows (macOS/Linux: source venv/bin/activate)
pip install -r requirements.txt
copy .env.example .env # macOS/Linux: cp .env.example .envEdit backend/.env:
| Variable | Description |
|---|---|
OPENAI_API_KEY |
Required. Used by the OCR and LLM services |
GEMINI_API_KEY |
Optional. Reserved for the Gemini integration |
.envis git-ignored. Never commit API keys.
The trained weights are about 430 MB each, over GitHub's 100 MB file limit. Get them from the project authors, or train them yourself (see below), and place them here:
backend/models/saved/biobert_multitask.pth
backend/models/saved/hybrid_lab_classifier.pth
cd ../frontend
npm installTerminal 1: Backend
cd backend
venv\Scripts\activate
python -m uvicorn main:app --reloadAPI: http://127.0.0.1:8000. Interactive docs: http://127.0.0.1:8000/docs.
The first start takes a while because it loads BioBERT, EasyOCR and TrOCR.
Terminal 2: Frontend
cd frontend
npm run devOpen http://localhost:5173, register an account and start uploading reports.
cd backend
venv\Scripts\python.exe scripts/generate_data.py # synthetic dataset with simulated OCR noise
venv\Scripts\python.exe scripts/train.py # fine-tune BioBERT multi-task heads
venv\Scripts\python.exe scripts/train_hybrid.py # train the hybrid lab classifier| Method | Endpoint | Purpose |
|---|---|---|
| POST | /register, /token |
Sign up / log in (JWT) |
| GET / PUT | /users/me, /users/profile |
Profile |
| POST | /analyze |
Analyze a lab report image |
| POST | /scan-prescription |
Extract a handwritten prescription |
| GET | /history, /reports/{id}, /prescriptions |
Archive |
| POST | /chat |
Context-aware AI assistant |
| POST | /generate-pdf |
Export results as PDF |
| POST / GET | /map-records, /mapped-records, /mapped-records/{id}/generate-correlation |
Record mapping & correlation |
The full schema is at /docs while the backend is running.
├── backend/
│ ├── main.py # FastAPI app & routes
│ ├── database.py # SQLite access
│ ├── models/ # BioBERT multi-task, hybrid classifier, LSTM definitions
│ ├── services/ # OCR, NLP, BioBERT, LSTM, LLM, auth services
│ ├── scripts/ # Data generation, training and API test scripts
│ ├── data/ # Synthetic training data
│ └── requirements.txt
├── frontend/
│ └── src/
│ ├── pages/ # Home, Analysis, Prescription Scanner, Mapping, Archive, Profile
│ └── components/ # Auth, Chat Assistant, Medication Scheduler, Navbar, UI kit
└── HOW_TO_RUN.md # Step-by-step demo guide
Real patient documents and the local patient database are intentionally excluded from this repository (Dataset/ and *.db are git-ignored). Train only on synthetic or properly anonymized data.
- Security: Removed hard-coded OpenAI API keys from
services/ocr_service.pyandservices/llm_service.py. Keys now come fromOPENAI_API_KEYinbackend/.env. - Dependencies: Added the missing
openai,torch,transformersandpython-dotenvtorequirements.txt. The backend failed to start withoutopenai. - Repository cleanup: History rewritten to remove patient data, the virtualenv, build output and large model weights. Added
.gitignoreandbackend/.env.example. - Docs: The README now describes the real OCR/ML pipeline (EasyOCR, TrOCR, GPT-4o, BioBERT) and the current API.