# vinith-44/image-based-radiology-report-generation-using-medgemma architecture

> Architecture diagram of the GitHub repository vinith-44/image-based-radiology-report-generation-using-medgemma, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-08). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/vinith-44/image-based-radiology-report-generation-using-medgemma
- Repository: https://github.com/vinith-44/image-based-radiology-report-generation-using-medgemma

## Overview

RADAR drafts structured radiology reports from X-ray, CT, or MRI images. The documented end-to-end flow preprocesses an image, derives graph-guided disease estimates (GHFE) and RAMT confidence, retrieves and guards supporting clinical evidence (RadioShield), then generates a report with MedGemma. RAMT also has a separate semi-supervised training workflow. The README and excerpts establish the main stages; some wiring among unsampled modules is documented rather than directly visible in source.

Main entry points: [`src/medgemma_report_generator.py`](https://github.com/vinith-44/image-based-radiology-report-generation-using-medgemma/blob/main/src/medgemma_report_generator.py) (Report pipeline), [`src/radioshield_rag.py`](https://github.com/vinith-44/image-based-radiology-report-generation-using-medgemma/blob/main/src/radioshield_rag.py) (RadioShield RAG), [`src/medgemma_engine.py`](https://github.com/vinith-44/image-based-radiology-report-generation-using-medgemma/blob/main/src/medgemma_engine.py) (MedGemma inference), [`src/ghfe_module.py`](https://github.com/vinith-44/image-based-radiology-report-generation-using-medgemma/blob/main/src/ghfe_module.py) (GHFE features)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_analysis["Image analysis"]
  node_ghfe["GHFE features<br/>[ghfe_module.py]"]
  node_ramt_inference["RAMT inference"]
end

subgraph group_evidence["Evidence retrieval"]
  node_rag["RadioShield RAG<br/>[radioshield_rag.py]"]
  node_evidence_index[("Clinical evidence index<br/>[radioshield_rag.py]")]
  node_faithfulness_guard["NLI faithfulness guard<br/>[radioshield_rag.py]"]
end

subgraph group_generation["Report generation"]
  node_report_pipeline["Report pipeline"]
  node_medgemma["MedGemma inference<br/>[medgemma_engine.py]"]
  node_report["Structured report"]
end

subgraph group_training["Model training"]
  node_ramt_training["RAMT training<br/>[ramt_module.py]"]
end

node_radiologist(("Radiology user"))
node_scan["Medical image"]
node_huggingface["Hugging Face Hub"]

node_radiologist -->|"submits case"| node_report_pipeline
node_scan -->|"provides image"| node_report_pipeline
node_report_pipeline -->|"extracts features"| node_ghfe
node_report_pipeline -->|"estimates confidence"| node_ramt_inference
node_ramt_training -->|"reuses model"| node_ghfe
node_report_pipeline -->|"requests evidence"| node_rag
node_rag -->|"retrieves chunks"| node_evidence_index
node_rag -->|"checks faithfulness"| node_faithfulness_guard
node_report_pipeline -.->|"generates report"| node_medgemma
node_medgemma -->|"loads model"| node_huggingface
node_report_pipeline -->|"formats output"| node_report

click node_report_pipeline "https://github.com/vinith-44/image-based-radiology-report-generation-using-medgemma/blob/main/src/medgemma_report_generator.py"
click node_ghfe "https://github.com/vinith-44/image-based-radiology-report-generation-using-medgemma/blob/main/src/ghfe_module.py"
click node_ramt_inference "https://github.com/vinith-44/image-based-radiology-report-generation-using-medgemma/blob/main/src/medgemma_report_generator.py"
click node_ramt_training "https://github.com/vinith-44/image-based-radiology-report-generation-using-medgemma/blob/main/src/ramt_module.py"
click node_rag "https://github.com/vinith-44/image-based-radiology-report-generation-using-medgemma/blob/main/src/radioshield_rag.py"
click node_evidence_index "https://github.com/vinith-44/image-based-radiology-report-generation-using-medgemma/blob/main/src/radioshield_rag.py"
click node_faithfulness_guard "https://github.com/vinith-44/image-based-radiology-report-generation-using-medgemma/blob/main/src/radioshield_rag.py"
click node_medgemma "https://github.com/vinith-44/image-based-radiology-report-generation-using-medgemma/blob/main/src/medgemma_engine.py"
click node_report "https://github.com/vinith-44/image-based-radiology-report-generation-using-medgemma/blob/main/src/medgemma_report_generator.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_ghfe,node_ramt_inference,node_radiologist toneBlue
class node_rag,node_evidence_index,node_faithfulness_guard toneAmber
class node_report_pipeline,node_medgemma,node_report toneMint
class node_ramt_training toneRose
class node_scan,node_huggingface toneIndigo
```

## Components

### Image analysis

- [GHFE features](https://github.com/vinith-44/image-based-radiology-report-generation-using-medgemma/blob/main/src/ghfe_module.py): `src/ghfe_module.py`
- [RAMT inference](https://github.com/vinith-44/image-based-radiology-report-generation-using-medgemma/blob/main/src/medgemma_report_generator.py): `src/medgemma_report_generator.py`

### Evidence retrieval

- [RadioShield RAG](https://github.com/vinith-44/image-based-radiology-report-generation-using-medgemma/blob/main/src/radioshield_rag.py): `src/radioshield_rag.py`
- [Clinical evidence index](https://github.com/vinith-44/image-based-radiology-report-generation-using-medgemma/blob/main/src/radioshield_rag.py): `src/radioshield_rag.py`
- [NLI faithfulness guard](https://github.com/vinith-44/image-based-radiology-report-generation-using-medgemma/blob/main/src/radioshield_rag.py): `src/radioshield_rag.py`

### Report generation

- [Report pipeline](https://github.com/vinith-44/image-based-radiology-report-generation-using-medgemma/blob/main/src/medgemma_report_generator.py): `src/medgemma_report_generator.py`
- [MedGemma inference](https://github.com/vinith-44/image-based-radiology-report-generation-using-medgemma/blob/main/src/medgemma_engine.py): `src/medgemma_engine.py`
- [Structured report](https://github.com/vinith-44/image-based-radiology-report-generation-using-medgemma/blob/main/src/medgemma_report_generator.py): `src/medgemma_report_generator.py`

### Model training

- [RAMT training](https://github.com/vinith-44/image-based-radiology-report-generation-using-medgemma/blob/main/src/ramt_module.py): `src/ramt_module.py`

### Other components

- **Radiology user**
- **Medical image**
- **Hugging Face Hub**

## Connections

- Radiology user → Report pipeline: submits case (evidence: `README.md`)
- Medical image → Report pipeline: provides image (evidence: `README.md`)
- Report pipeline → GHFE features: extracts features (evidence: `README.md`)
- Report pipeline → RAMT inference: estimates confidence (evidence: `README.md`)
- RAMT training → GHFE features: reuses model (evidence: `src/ramt_module.py`)
- Report pipeline → RadioShield RAG: requests evidence (evidence: `src/medgemma_report_generator.py`)
- RadioShield RAG → Clinical evidence index: retrieves chunks (evidence: `src/radioshield_rag.py`)
- RadioShield RAG → NLI faithfulness guard: checks faithfulness (evidence: `src/radioshield_rag.py`)
- Report pipeline → MedGemma inference: generates report
- MedGemma inference → Hugging Face Hub: loads model (evidence: `src/medgemma_engine.py`)
- Report pipeline → Structured report: formats output (evidence: `src/medgemma_report_generator.py`)
