Skip to content

About

🧠 Multimodal Agentic RAG system for medical imaging β€” UNet-ResNet34 segmentation + BioBERT RAG + LangGraph reasoning β†’ structured differential diagnosis

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

Β 

History

80 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

MediVision AI Agent

Multi-organ CT segmentation + Medical RAG + Local LLM reasoning

Python PyTorch License: MIT

Niyati Kapadia Β· LinkedIn


What This Is

MediVision is a local, privacy-first medical imaging analysis pipeline. Upload an abdominal CT scan slice β€” the system segments organs, retrieves relevant medical literature, and generates a structured findings report. Everything runs locally. No data leaves your machine.

Honest scope: Research prototype. Not clinically validated. See MODEL_CARD.md for full limitations.


Pipeline

CT scan (PNG/JPG)
      ↓
UNet-ResNet34 segmentation
(trained on Synapse, Test Dice 0.859)
      ↓
CCA post-processing + anatomical sanity checks
      ↓
Medical RAG (BM25, 12 documents, organ-aware retrieval)
      ↓
Llama3 local reasoning (Ollama, fully offline)
      ↓
Structured findings report (measurements only, no diagnoses)

Segmentation Results

Trained on Synapse multi-organ CT dataset. Evaluated on official test set.

Organ Dice Organ Dice
Right kidney 0.950 Pancreas 0.841
Stomach 0.926 Gallbladder 0.735
Spleen 0.916 Liver 0.713
Left kidney 0.902 Aorta 0.892
Overall 0.859

Outperforms TransUNet (0.772) and SwinUNet (0.790) using a simpler 2D architecture. Full evaluation: evaluation/segmentation_metrics.md


Quickstart

git clone https://github.com/niyatikapadia/MediVision-AI-Agent.git
cd MediVision-AI-Agent
pip install -r requirements.txt

# Place model weights
cp unet_resnet34_v3_best.pth models/

# Start Ollama (required for agent reasoning)
ollama serve   # separate terminal

# Run demo
python app.py
# Open http://localhost:7860

Project Structure

MediVision-AI-Agent/
β”œβ”€β”€ app.py                          # Gradio demo app
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ segmentation.py             # UNet-ResNet34 inference + CCA + sanity checks
β”‚   β”œβ”€β”€ rag_module.py               # BM25 retrieval, 12-doc medical KB
β”‚   β”œβ”€β”€ agent.py                    # Ollama agent (findings only, no diagnoses)
β”‚   └── visualize.py                # Segmentation overlay rendering
β”œβ”€β”€ training/
β”‚   β”œβ”€β”€ train.py                    # v3 training (512px, Focal Tversky, SCSE)
β”‚   └── train_finetune_liver.py     # v3.1 liver fine-tuning (planned)
β”œβ”€β”€ evaluation/
β”‚   β”œβ”€β”€ segmentation_metrics.md     # Real results + comparison to baselines
β”‚   β”œβ”€β”€ rag_benchmark.md            # RAG retrieval quality
β”‚   β”œβ”€β”€ agent_reasoning_tests.md    # Agent trace examples
β”‚   └── segmentation_eval.py       # Runnable evaluation script
β”œβ”€β”€ examples/
β”‚   β”œβ”€β”€ example_case_1.md           # Full pipeline trace: hepatic lesion
β”‚   └── example_case_2.md           # Full pipeline trace: normal baseline
β”œβ”€β”€ docs/
β”‚   └── architecture.md             # Design decisions + references
β”œβ”€β”€ data/
β”‚   β”œβ”€β”€ generate_sample_data.py     # Synthetic test image generator
β”‚   └── sample_data/                # Sample PNG scans for testing
β”œβ”€β”€ models/
β”‚   └── .gitkeep                    # Place unet_resnet34_v3_best.pth here
β”œβ”€β”€ MODEL_CARD.md                   # Full model documentation
β”œβ”€β”€ Dockerfile
β”œβ”€β”€ docker-compose.yml
└── requirements.txt

Key Design Decisions

Why local LLM? Documents never leave the machine. Safe for confidential contracts, medical records, legal documents. No API costs, no rate limits.

Why 2D slices? Full 3D DICOM processing is a planned v2 extension. 2D is a known limitation β€” documented in MODEL_CARD.md.

Why findings-only reports? The agent is explicitly prohibited from making diagnoses. It reports measurements and observations. Expert radiologist review is always recommended.

See docs/architecture.md for full reasoning.


Limitations

  • Single 2D slice β€” no volumetric context
  • Liver/kidney boundary confusion on some slices
  • Internal validation only β€” no external test set
  • 12-document RAG KB (not full PubMed)
  • Uncalibrated confidence scores

Full details: MODEL_CARD.md


Roadmap

  • v3.1 β€” liver fine-tuning (train_finetune_liver.py ready)
  • Full DICOM series support
  • Temperature scaling for confidence calibration
  • Hausdorff distance metrics
  • nnU-Net benchmark comparison

License

MIT β€” see LICENSE.

Research prototype. Not for clinical use.
Built by Niyati Kapadia

About

🧠 Multimodal Agentic RAG system for medical imaging β€” UNet-ResNet34 segmentation + BioBERT RAG + LangGraph reasoning β†’ structured differential diagnosis

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages