Update README.md
Browse fileshttps://cdn-uploads.huggingface.co/production/uploads/69e8826eb1347b4a2120bea7/HI8h4dIMXql7XgBNwuUjd.mp4
README.md
CHANGED
|
@@ -1,421 +1,84 @@
|
|
| 1 |
-
<div align="center">
|
| 2 |
-
|
| 3 |
-
<img src="https://img.shields.io/badge/AMD_Instinct-MI300X-ED1C24?style=for-the-badge&logo=amd&logoColor=white" />
|
| 4 |
-
<img src="https://img.shields.io/badge/ROCm-Stack-ED1C24?style=for-the-badge&logo=amd&logoColor=white" />
|
| 5 |
-
<img src="https://img.shields.io/badge/vLLM-Inference-6D28D9?style=for-the-badge" />
|
| 6 |
-
<img src="https://img.shields.io/badge/Qwen-Multimodal-0EA5E9?style=for-the-badge" />
|
| 7 |
-
<img src="https://img.shields.io/badge/FastAPI-0.115-009688?style=for-the-badge&logo=fastapi&logoColor=white" />
|
| 8 |
-
<img src="https://img.shields.io/badge/Python-3.12+-3776AB?style=for-the-badge&logo=python&logoColor=white" />
|
| 9 |
-
|
| 10 |
-
<br /><br />
|
| 11 |
-
|
| 12 |
-
# 🏥 MediAgent
|
| 13 |
-
|
| 14 |
-
### Autonomous Multi-Agent Medical Imaging Analysis System
|
| 15 |
-
|
| 16 |
-
**Five specialized AI agents. One radiological verdict. Running entirely on AMD.**
|
| 17 |
-
|
| 18 |
-
*AMD Developer Hackathon 2026 · Track: Vision & Multimodal AI*
|
| 19 |
-
|
| 20 |
-
<br />
|
| 21 |
-
|
| 22 |
-
> Built by **Ramyar** — Security researcher & full-stack developer, Sulaymaniyah, Iraq
|
| 23 |
-
|
| 24 |
-
</div>
|
| 25 |
-
|
| 26 |
-
---
|
| 27 |
-
|
| 28 |
-
## What Is MediAgent?
|
| 29 |
-
|
| 30 |
-
MediAgent is a production-grade autonomous AI system that analyzes medical images — X-rays, MRI scans, CT scans — through a five-agent pipeline and generates structured, peer-reviewed clinical radiology reports in real time.
|
| 31 |
-
|
| 32 |
-
Upload an image. Watch five AI agents execute live. Get a formal radiology report with differential diagnoses, ICD-10 codes, a quality score, and a FHIR R4 export ready for any EMR system.
|
| 33 |
-
|
| 34 |
-
**No cloud APIs. No OpenAI. No Nvidia.**
|
| 35 |
-
Pure AMD MI300X inference. Local. Private. Fast.
|
| 36 |
-
|
| 37 |
-
---
|
| 38 |
-
|
| 39 |
-
## The Pipeline
|
| 40 |
-
|
| 41 |
-
```
|
| 42 |
-
┌─────────────────────────────────────────────────────────────────────┐
|
| 43 |
-
│ IMAGE UPLOAD │
|
| 44 |
-
│ PNG / JPG / DICOM (.dcm) — up to 20 MB │
|
| 45 |
-
└──────────────────────────┬──────────────────────────────────────────┘
|
| 46 |
-
│
|
| 47 |
-
┌────────────────┴────────────────┐
|
| 48 |
-
│ PARALLEL STAGE │
|
| 49 |
-
▼ ▼
|
| 50 |
-
┌─────────────────┐ ┌─────────────────┐
|
| 51 |
-
│ INTAKE AGENT │ │ VISION AGENT │
|
| 52 |
-
│ │ │ │
|
| 53 |
-
│ • Validates │ │ • Multimodal │
|
| 54 |
-
│ image payload │ │ Qwen analysis │
|
| 55 |
-
│ • Normalizes │ │ • Anatomical │
|
| 56 |
-
│ clinical text │ │ findings │
|
| 57 |
-
│ • Extracts │ │ • Severity per │
|
| 58 |
-
│ demographics │ │ region │
|
| 59 |
-
│ • Safety triage │ │ • Confidence │
|
| 60 |
-
│ (16 keywords) │ │ scoring │
|
| 61 |
-
│ • Modality hint │ │ • Anomaly flags │
|
| 62 |
-
└────────┬────────┘ └────────┬────────┘
|
| 63 |
-
└──────────────┬──────────────────┘
|
| 64 |
-
│
|
| 65 |
-
▼
|
| 66 |
-
┌───────────────────────┐
|
| 67 |
-
│ RESEARCH AGENT │
|
| 68 |
-
│ │
|
| 69 |
-
│ • KB cross-reference │
|
| 70 |
-
│ (15 conditions) │
|
| 71 |
-
│ • Demographic weight │
|
| 72 |
-
│ • Ranked differentials│
|
| 73 |
-
│ • ICD-10 codes │
|
| 74 |
-
│ • Match probabilities │
|
| 75 |
-
└───────────┬───────────┘
|
| 76 |
-
│
|
| 77 |
-
▼
|
| 78 |
-
┌───────────────────────┐
|
| 79 |
-
│ REPORT AGENT │
|
| 80 |
-
│ │
|
| 81 |
-
│ • ACR/NICE format │
|
| 82 |
-
│ • Clinical history │
|
| 83 |
-
│ • Technique section │
|
| 84 |
-
│ • Findings narrative │
|
| 85 |
-
│ • Impression + top Dx │
|
| 86 |
-
│ • Recommendations │
|
| 87 |
-
└───────────┬───────────┘
|
| 88 |
-
│
|
| 89 |
-
▼
|
| 90 |
-
┌───────────────────────┐
|
| 91 |
-
│ CRITIC AGENT │
|
| 92 |
-
│ │
|
| 93 |
-
│ • Cross-validates │
|
| 94 |
-
│ report vs findings │
|
| 95 |
-
│ • Quality score 0-100 │
|
| 96 |
-
│ • Uncertainty flags │
|
| 97 |
-
│ • Disclaimer enforce │
|
| 98 |
-
└───────────┬───────────┘
|
| 99 |
-
│
|
| 100 |
-
▼
|
| 101 |
-
┌─────────────────────────────────────────────────────────────────────┐
|
| 102 |
-
│ FINAL REPORT │
|
| 103 |
-
│ Structured JSON · PDF Export · FHIR R4 DiagnosticReport │
|
| 104 |
-
└─────────────────────────────────────────────────────────────────────┘
|
| 105 |
-
```
|
| 106 |
-
|
| 107 |
-
INTAKE and VISION execute **concurrently** — cutting wall-clock latency by running the two most expensive operations in parallel. Everything downstream sequences after both complete.
|
| 108 |
-
|
| 109 |
-
---
|
| 110 |
-
|
| 111 |
-
## AMD Hardware Stack
|
| 112 |
-
|
| 113 |
-
| Component | Technology |
|
| 114 |
-
|---|---|
|
| 115 |
-
| **GPU** | AMD Instinct MI300X |
|
| 116 |
-
| **GPU Software** | ROCm — AMD's open-source GPU compute platform |
|
| 117 |
-
| **Inference Server** | vLLM (ROCm build) at `localhost:8000/v1` |
|
| 118 |
-
| **Model** | Qwen multimodal — native vision + text |
|
| 119 |
-
| **Backend** | FastAPI 0.115 + Uvicorn |
|
| 120 |
-
| **Frontend** | Vanilla JS + Tailwind CSS + SSE streaming |
|
| 121 |
-
|
| 122 |
-
This project is a direct proof of concept that AMD's ROCm stack is **production-viable for real-world medical AI**. Every inference call — vision analysis, clinical normalization, report synthesis, peer review, post-report chat — runs on AMD MI300X. Zero CUDA dependency. Zero cloud API calls.
|
| 123 |
-
|
| 124 |
-
---
|
| 125 |
-
|
| 126 |
-
## Key Features
|
| 127 |
-
|
| 128 |
-
### 🔴 Real-Time SSE Streaming
|
| 129 |
-
Watch the pipeline execute live, agent by agent. Every status transition — WAITING → RUNNING → DONE — streams to the dashboard as it happens via Server-Sent Events. Per-agent runtime counters track exactly how long each step takes.
|
| 130 |
-
|
| 131 |
-
### 👁️ Multimodal Vision Analysis
|
| 132 |
-
Qwen processes the raw medical image natively. It returns structured JSON: detected modality, technical quality assessment, per-region findings with anatomical names, radiological descriptions, severity levels (NORMAL / INCIDENTAL / SIGNIFICANT / CRITICAL), confidence scores (0–100), and anomaly flags.
|
| 133 |
-
|
| 134 |
-
### 🔬 Medical Knowledge Base + ICD-10 Mapping
|
| 135 |
-
The Research Agent cross-references vision findings against 15 curated clinical conditions spanning pulmonary, neurological, abdominal, musculoskeletal, and vascular pathology. Every differential diagnosis comes with an ICD-10 code, match probability, and a sentence explaining exactly why the condition matches the findings.
|
| 136 |
-
|
| 137 |
-
### 🛡️ Critic Agent QA
|
| 138 |
-
Every report goes through a peer-review pass before delivery. The Critic checks that all anomalies from the Vision Agent appear in the report, flags low-confidence findings, assigns a quality score (completeness 30% + accuracy 40% + safety 20% + compliance 10%), and hard-caps the score at 40/100 if a core agent failed.
|
| 139 |
-
|
| 140 |
-
### 🏥 DICOM Support
|
| 141 |
-
Upload real `.dcm` files. MediAgent extracts 20+ metadata fields — patient name, study date, institution, modality, body part, KVP, slice thickness, pixel spacing, image dimensions — and pre-populates the intake form automatically. MONOCHROME1 inversion and multi-frame handling included.
|
| 142 |
-
|
| 143 |
-
### 📋 FHIR R4 Export
|
| 144 |
-
Every report can be exported as a fully conformant HL7 FHIR R4 DiagnosticReport resource. Includes an inline Patient resource, Observation resources, LOINC and SNOMED CT codes, severity mapping, full report text in `presentedForm`, and custom extensions for AI quality score and pipeline status. Ready to import into Epic, Cerner, or any FHIR-capable EMR.
|
| 145 |
-
|
| 146 |
-
### 💬 Post-Report Clinical Chat
|
| 147 |
-
After the report is delivered, a ClinicalAdvisorAgent is available for follow-up questions. It answers in 2–4 sentences with direct reference to the report findings. Qwen's thinking/reasoning mode is explicitly disabled — answers are fast, direct, and clinical.
|
| 148 |
-
|
| 149 |
-
### 🔒 Hard Safety Enforcement
|
| 150 |
-
- **16 deterministic safety keywords** — chest pain, stroke symptoms, acute trauma, hemoptysis, sepsis, spinal trauma, and more — trigger urgent flags regardless of LLM output.
|
| 151 |
-
- **Age-based alerts** — pediatric (<18) and geriatric (>75) cases are automatically flagged for expert review.
|
| 152 |
-
- **Mandatory AI disclaimer** — enforced at two independent layers (Report Agent + Critic Agent) and cannot be bypassed or modified by the LLM.
|
| 153 |
-
- **Graceful degradation** — the pipeline produces a report even if individual agents fail, always marking what succeeded and what didn't.
|
| 154 |
-
|
| 155 |
-
### 📄 Client-Side PDF Export
|
| 156 |
-
Full radiology report exported as a formatted PDF directly in the browser using jsPDF — severity color banner, all six report sections, DICOM metadata, QA score. No server round-trip needed.
|
| 157 |
-
|
| 158 |
-
---
|
| 159 |
-
|
| 160 |
-
## Agent Architecture
|
| 161 |
-
|
| 162 |
-
### IntakeAgent
|
| 163 |
-
Validates the image payload (minimum size, valid base64), applies deterministic safety triage, and normalizes clinical language. For simple inputs under 120 characters it skips the LLM entirely and uses a built-in layman-to-medical term map (22 entries: "can't breathe" → "dyspnea", "lump" → "mass/nodule", "dizzy" → "dizziness/vertigo", etc.). Only calls the LLM for complex clinical narratives with comorbidities or medical history. Falls back cleanly to raw input preservation if the LLM is unavailable.
|
| 164 |
-
|
| 165 |
-
### VisionAgent
|
| 166 |
-
Sends the base64 image and clinical context to Qwen at temperature 0.0 with a strict JSON schema enforced via system prompt. Handles malformed enum values from the LLM with safe conversion fallbacks — a single bad field never drops a finding. Tracks token usage and anomaly counts in the output metadata.
|
| 167 |
-
|
| 168 |
-
### ResearchAgent
|
| 169 |
-
Pre-filters the knowledge base to only conditions compatible with the detected modality before sending to the LLM — reducing prompt size and improving accuracy. Enforces strict output rules: only conditions from the KB, 2–4 differentials maximum, 5% minimum probability, exact ICD-10 codes, and evidence sentences that actually explain the match.
|
| 170 |
-
|
| 171 |
-
### ReportAgent
|
| 172 |
-
Builds a structured prompt with clearly labeled sections — clinical history, imaging technique, findings block, differentials block — and asks the LLM to synthesize them into a formal ACR/NICE radiology report. The disclaimer is overwritten to the exact regulatory string after LLM generation, unconditionally.
|
| 173 |
-
|
| 174 |
-
### CriticAgent
|
| 175 |
-
Operates at temperature 0.0 for fully deterministic QA. Receives the draft report and the full pipeline state including raw vision findings. Checks every anomaly is accounted for, flags low-confidence observations, and appends a `[QUALITY ASSESSMENT]` block to the recommendations section with score, issues, and uncertainty warnings.
|
| 176 |
-
|
| 177 |
-
### ClinicalAdvisorAgent
|
| 178 |
-
Activated only after report delivery, scoped to the specific report's findings. Strips all Qwen thinking output via multi-layer regex before returning the answer — handles `<think>` XML blocks, markdown think fences, and plain-text reasoning preambles.
|
| 179 |
-
|
| 180 |
---
|
| 181 |
-
|
| 182 |
-
|
| 183 |
-
|
| 184 |
-
|
| 185 |
-
|
| 186 |
-
|
| 187 |
-
|
| 188 |
-
|
| 189 |
-
-
|
| 190 |
-
|
| 191 |
-
- Dual-strategy JSON extraction: direct parse first, then character-by-character brace-matching fallback for responses where the LLM adds conversational padding
|
| 192 |
-
|
| 193 |
---
|
| 194 |
|
| 195 |
-
#
|
| 196 |
-
|
| 197 |
-
15 conditions covering the most common radiological findings across all supported modalities:
|
| 198 |
|
| 199 |
-
|
| 200 |
-
|
| 201 |
-
| Community-Acquired Pneumonia | J18.9 | X-RAY, CT | SIGNIFICANT |
|
| 202 |
-
| Cardiogenic Pulmonary Edema | J81.0 | X-RAY, CT | CRITICAL |
|
| 203 |
-
| Pleural Effusion | J90 | X-RAY, CT, MRI | SIGNIFICANT |
|
| 204 |
-
| Spontaneous Pneumothorax | J93.9 | X-RAY, CT | CRITICAL |
|
| 205 |
-
| Intracerebral Hemorrhage | I61.9 | CT, MRI | CRITICAL |
|
| 206 |
-
| Ischemic Stroke | I63.9 | CT, MRI | CRITICAL |
|
| 207 |
-
| Intracranial Neoplasm | C71.9 | MRI, CT | SIGNIFICANT |
|
| 208 |
-
| Abdominal Aortic Aneurysm | I71.4 | CT, MRI | CRITICAL |
|
| 209 |
-
| Nephrolithiasis | N20.0 | CT, X-RAY | SIGNIFICANT |
|
| 210 |
-
| Small Bowel Obstruction | K56.6 | X-RAY, CT | SIGNIFICANT |
|
| 211 |
-
| Long Bone Fracture | S82.902 | X-RAY, CT | SIGNIFICANT |
|
| 212 |
-
| Degenerative Joint Disease | M19.90 | X-RAY, MRI | INCIDENTAL |
|
| 213 |
-
| Hepatic Steatosis | K76.0 | CT, MRI | INCIDENTAL |
|
| 214 |
-
| Herniated Disc | M51.16 | MRI, CT | SIGNIFICANT |
|
| 215 |
-
| Pulmonary Nodule | R91.1 | X-RAY, CT | SIGNIFICANT |
|
| 216 |
|
| 217 |
---
|
| 218 |
|
| 219 |
-
##
|
| 220 |
-
|
| 221 |
-
| Method | Endpoint | Description |
|
| 222 |
-
|---|---|---|
|
| 223 |
-
| `GET` | `/` | Clinical dashboard UI |
|
| 224 |
-
| `GET` | `/health` | System health, version, active sessions |
|
| 225 |
-
| `GET` | `/metrics/gpu` | Live AMD GPU metrics (util, VRAM, temp, power) |
|
| 226 |
-
| `POST` | `/analyze` | Synchronous pipeline → full JSON report |
|
| 227 |
-
| `POST` | `/analyze/stream` | Real-time SSE streaming pipeline |
|
| 228 |
-
| `GET` | `/status/{report_id}` | Poll live pipeline state |
|
| 229 |
-
| `POST` | `/chat/{report_id}` | Post-report clinical Q&A |
|
| 230 |
-
| `GET` | `/api/docs` | Swagger UI |
|
| 231 |
-
| `GET` | `/api/redoc` | ReDoc UI |
|
| 232 |
|
| 233 |
-
|
| 234 |
|
| 235 |
-
|
| 236 |
-
// Agent status update (emitted on every state transition)
|
| 237 |
-
{"agent": "VISION", "status": "RUNNING"}
|
| 238 |
-
{"agent": "VISION", "status": "DONE"}
|
| 239 |
-
|
| 240 |
-
// Final report (emitted when pipeline completes)
|
| 241 |
-
{"type": "report", "data": {...}, "report_id": "REP-A3F9C2D1B4E7"}
|
| 242 |
-
|
| 243 |
-
// Error
|
| 244 |
-
{"type": "error", "message": "Pipeline produced no report"}
|
| 245 |
-
```
|
| 246 |
-
|
| 247 |
-
### Form Fields (`/analyze`, `/analyze/stream`)
|
| 248 |
-
|
| 249 |
-
| Field | Type | Required | Notes |
|
| 250 |
-
|---|---|---|---|
|
| 251 |
-
| `image` | File | ✅ | PNG, JPG, or DICOM (.dcm), max 20 MB |
|
| 252 |
-
| `symptoms` | string | — | Free-text chief complaint |
|
| 253 |
-
| `age` | integer | — | 0–120 |
|
| 254 |
-
| `sex` | string | — | `M`, `F`, or `O` |
|
| 255 |
-
| `clinical_context` | string | — | Medical history, referral details |
|
| 256 |
|
| 257 |
---
|
| 258 |
|
| 259 |
-
##
|
| 260 |
-
|
| 261 |
-
```
|
| 262 |
-
PatientInput
|
| 263 |
-
└── image_base64, symptoms, age, sex, clinical_context
|
| 264 |
|
| 265 |
-
|
| 266 |
-
├── agent_statuses: {INTAKE, VISION, RESEARCH, REPORT, CRITIC}
|
| 267 |
-
├── intake_output: IntakeOutput
|
| 268 |
-
├── vision_output: VisionOutput
|
| 269 |
-
│ └── findings: [VisionFinding, ...]
|
| 270 |
-
│ └── anatomical_region, description, severity,
|
| 271 |
-
│ confidence, confidence_score, is_anomaly
|
| 272 |
-
├── research_output: ResearchOutput
|
| 273 |
-
│ └── differential_diagnoses: [KnowledgeMatch, ...]
|
| 274 |
-
│ └── condition_name, match_probability,
|
| 275 |
-
│ supporting_evidence, differential_rank, icd10_code
|
| 276 |
-
├── report_draft: ReportSection
|
| 277 |
-
│ └── clinical_history, technique, findings, impression,
|
| 278 |
-
│ recommendations, disclaimer
|
| 279 |
-
└── final_report: FinalReport
|
| 280 |
-
└── report_id, patient_metadata, sections, vision_summary,
|
| 281 |
-
research_summary, overall_severity, agent_pipeline_status,
|
| 282 |
-
generation_timestamp
|
| 283 |
-
```
|
| 284 |
|
| 285 |
-
|
| 286 |
|
| 287 |
-
|
| 288 |
-
|
| 289 |
-
```
|
| 290 |
-
mediagent/
|
| 291 |
-
├── main.py ← FastAPI server, all routes, SSE orchestration
|
| 292 |
-
├── core/
|
| 293 |
-
│ ├── llm.py ← LLM client (retry, vision, streaming, JSON extraction)
|
| 294 |
-
│ ├── models.py ← All Pydantic v2 data models
|
| 295 |
-
│ ├── pipeline.py ← Parallel pipeline orchestrator
|
| 296 |
-
│ ├── dicom.py ← DICOM parser (pydicom + numpy + Pillow)
|
| 297 |
-
│ └── fhir.py ← FHIR R4 DiagnosticReport builder
|
| 298 |
-
├── agents/
|
| 299 |
-
│ ├── intake.py ← Input validation, normalization, safety triage
|
| 300 |
-
│ ├── vision.py ← Multimodal image analysis
|
| 301 |
-
│ ├── research.py ← KB matching, ICD-10, differential diagnosis
|
| 302 |
-
│ ├── report.py ← ACR/NICE radiology report synthesis
|
| 303 |
-
│ ├── critic.py ← QA validation, quality scoring
|
| 304 |
-
│ └── advisor.py ← Post-report clinical Q&A
|
| 305 |
-
├── static/
|
| 306 |
-
│ └── index.html ← Full dashboard (Tailwind + Chart.js + SSE)
|
| 307 |
-
├── requirements.txt
|
| 308 |
-
└── .env.example
|
| 309 |
-
```
|
| 310 |
|
| 311 |
---
|
| 312 |
|
| 313 |
-
##
|
| 314 |
-
|
| 315 |
-
### Prerequisites
|
| 316 |
-
|
| 317 |
-
- Python 3.12+
|
| 318 |
-
- vLLM running a Qwen multimodal model on ROCm, accessible at `http://localhost:8000/v1`
|
| 319 |
-
- ROCm-compatible AMD GPU (MI300X recommended)
|
| 320 |
-
|
| 321 |
-
### Installation
|
| 322 |
-
|
| 323 |
-
```bash
|
| 324 |
-
# Clone the repository
|
| 325 |
-
git clone https://github.com/Ramyar2007/mediagent
|
| 326 |
-
cd mediagent
|
| 327 |
|
| 328 |
-
|
| 329 |
-
|
| 330 |
-
|
| 331 |
-
|
| 332 |
-
|
| 333 |
-
|
| 334 |
-
|
| 335 |
-
|
| 336 |
-
### Environment Variables
|
| 337 |
-
|
| 338 |
-
```env
|
| 339 |
-
LLM_BASE_URL=http://localhost:8000/v1 # vLLM OpenAI-compatible endpoint
|
| 340 |
-
LLM_MODEL=/model # Model path served by vLLM
|
| 341 |
-
APP_PORT=8090 # Server port
|
| 342 |
-
```
|
| 343 |
-
|
| 344 |
-
### Run
|
| 345 |
-
|
| 346 |
-
```bash
|
| 347 |
-
python main.py
|
| 348 |
-
```
|
| 349 |
-
|
| 350 |
-
Dashboard available at **http://localhost:8090**
|
| 351 |
-
|
| 352 |
-
Swagger docs at **http://localhost:8090/api/docs**
|
| 353 |
-
|
| 354 |
-
---
|
| 355 |
-
|
| 356 |
-
## Dependencies
|
| 357 |
-
|
| 358 |
-
| Package | Version | Purpose |
|
| 359 |
-
|---|---|---|
|
| 360 |
-
| `fastapi` | 0.115.6 | Web framework |
|
| 361 |
-
| `uvicorn[standard]` | 0.34.0 | ASGI server |
|
| 362 |
-
| `openai` | 1.58.1 | SDK for vLLM OpenAI-compatible API |
|
| 363 |
-
| `python-multipart` | 0.0.20 | Multipart form / file upload |
|
| 364 |
-
| `pydantic` | 2.10.5 | Data validation and serialization |
|
| 365 |
-
| `Pillow` | 11.1.0 | Image processing for DICOM conversion |
|
| 366 |
-
| `pydicom` | 2.4.4 | DICOM file parsing and metadata extraction |
|
| 367 |
-
| `numpy` | 1.26.4 | Pixel array normalization for DICOM |
|
| 368 |
|
| 369 |
-
|
| 370 |
|
| 371 |
---
|
| 372 |
|
| 373 |
-
##
|
| 374 |
-
|
| 375 |
-
MediAgent is built with clinical safety as a first-class concern, not an afterthought.
|
| 376 |
-
|
| 377 |
-
**Mandatory disclaimer** — enforced at two independent code layers and cannot be overridden by any LLM output:
|
| 378 |
-
|
| 379 |
-
> *"This analysis is AI-generated and must be reviewed by a licensed radiologist before any clinical decisions are made."*
|
| 380 |
-
|
| 381 |
-
**Hard safety rules that run deterministically, without LLM involvement:**
|
| 382 |
-
- 16 urgent clinical keywords trigger immediate flags before any AI processing
|
| 383 |
-
- Pediatric and geriatric age thresholds auto-flag for specialist review
|
| 384 |
-
- Quality score is hard-capped at 40/100 if core agents (Vision, Report) fail
|
| 385 |
-
- Low-confidence findings are always flagged with confirmatory imaging recommendations
|
| 386 |
-
- The disclaimer is re-enforced after every LLM call, unconditionally
|
| 387 |
|
| 388 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 389 |
|
| 390 |
---
|
| 391 |
|
| 392 |
-
##
|
| 393 |
|
| 394 |
-
|
| 395 |
-
|
| 396 |
-
- **
|
| 397 |
-
- **
|
| 398 |
-
- **
|
| 399 |
-
- **DICOM metadata card** — study date, institution, modality, body part, technical parameters
|
| 400 |
-
- **PDF export** — full formatted report generated client-side
|
| 401 |
-
- **Clinical chat** — slide-up Q&A panel backed by the ClinicalAdvisorAgent
|
| 402 |
-
- **AMD GPU panel** — live util %, VRAM used/total, temperature, power draw — polling every 3 seconds
|
| 403 |
|
| 404 |
---
|
| 405 |
|
| 406 |
-
##
|
| 407 |
-
|
| 408 |
-
**AMD Developer Hackathon 2026**
|
| 409 |
-
Track: Vision & Multimodal AI
|
| 410 |
|
| 411 |
-
|
|
|
|
| 412 |
|
| 413 |
---
|
| 414 |
|
| 415 |
-
|
| 416 |
-
|
| 417 |
-
**Built by Ramyar · Sulaymaniyah, Iraq**
|
| 418 |
-
|
| 419 |
-
*#AMDDevChallenge · AMD Instinct MI300X · ROCm · vLLM · Qwen*
|
| 420 |
-
|
| 421 |
-
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
---
|
| 2 |
+
license: mit
|
| 3 |
+
title: MediAgent
|
| 4 |
+
sdk: docker
|
| 5 |
+
emoji: 🏥
|
| 6 |
+
colorFrom: red
|
| 7 |
+
colorTo: gray
|
| 8 |
+
pinned: true
|
| 9 |
+
thumbnail: >-
|
| 10 |
+
https://cdn-uploads.huggingface.co/production/uploads/69e8826eb1347b4a2120bea7/py_Af1BHRw-N755ZiM4GO.jpeg
|
| 11 |
+
short_description: runs a 5-agent AI pipeline that analyzes medical images
|
|
|
|
|
|
|
| 12 |
---
|
| 13 |
|
| 14 |
+
# 🏥 MediAgent
|
| 15 |
+
### Autonomous Multi-Agent Medical Imaging Analysis — AMD Instinct MI300X
|
|
|
|
| 16 |
|
| 17 |
+
> **AMD Developer Hackathon 2026 · Vision & Multimodal AI Track**
|
| 18 |
+
> Built by Ramyar — Sulaymaniyah, Iraq
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
|
| 20 |
---
|
| 21 |
|
| 22 |
+
## What It Does
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 23 |
|
| 24 |
+
MediAgent runs a 5-agent AI pipeline that analyzes medical images (X-ray, MRI, CT, DICOM) and generates formal radiology reports with differential diagnoses, ICD-10 codes, and FHIR R4 export — entirely on AMD hardware.
|
| 25 |
|
| 26 |
+
**No cloud APIs. No OpenAI. No Nvidia. Pure AMD MI300X + ROCm + vLLM.**
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 27 |
|
| 28 |
---
|
| 29 |
|
| 30 |
+
## ⚠️ Demo Mode
|
|
|
|
|
|
|
|
|
|
|
|
|
| 31 |
|
| 32 |
+
This Space runs in **demo mode** — the full pipeline UI works and all 5 agents animate live, but no real inference is performed since the AMD Instinct MI300X backend is not available on HuggingFace's free hardware.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 33 |
|
| 34 |
+
**See the video demo for live inference on real AMD hardware.**
|
| 35 |
|
| 36 |
+
Live inference requires: AMD Instinct MI300X · ROCm · vLLM · Qwen multimodal
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 37 |
|
| 38 |
---
|
| 39 |
|
| 40 |
+
## The 5-Agent Pipeline
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 41 |
|
| 42 |
+
| Agent | Role |
|
| 43 |
+
|---|---|
|
| 44 |
+
| **INTAKE** | Validates input, normalizes clinical language, safety triage |
|
| 45 |
+
| **VISION** | Multimodal image analysis via Qwen on AMD MI300X |
|
| 46 |
+
| **RESEARCH** | KB cross-reference, differential diagnoses, ICD-10 codes |
|
| 47 |
+
| **REPORT** | ACR/NICE format radiology report synthesis |
|
| 48 |
+
| **CRITIC** | QA peer-review, quality scoring, disclaimer enforcement |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 49 |
|
| 50 |
+
INTAKE + VISION run in **parallel** to minimize latency.
|
| 51 |
|
| 52 |
---
|
| 53 |
|
| 54 |
+
## Key Features
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 55 |
|
| 56 |
+
- Real-time SSE streaming pipeline with per-agent timers
|
| 57 |
+
- DICOM (.dcm) file support with metadata extraction
|
| 58 |
+
- 15-condition medical knowledge base with ICD-10 mapping
|
| 59 |
+
- FHIR R4 DiagnosticReport export
|
| 60 |
+
- Client-side PDF export
|
| 61 |
+
- Post-report clinical Q&A (ClinicalAdvisorAgent)
|
| 62 |
+
- Live AMD GPU metrics (util, VRAM, temp, power)
|
| 63 |
+
- Hard-enforced clinical safety rules
|
| 64 |
|
| 65 |
---
|
| 66 |
|
| 67 |
+
## Tech Stack
|
| 68 |
|
| 69 |
+
- **GPU:** AMD Instinct MI300X
|
| 70 |
+
- **GPU Software:** ROCm
|
| 71 |
+
- **Inference:** vLLM (ROCm build) + Qwen multimodal
|
| 72 |
+
- **Backend:** FastAPI + Uvicorn
|
| 73 |
+
- **Frontend:** Vanilla JS + Tailwind CSS + Chart.js + SSE
|
|
|
|
|
|
|
|
|
|
|
|
|
| 74 |
|
| 75 |
---
|
| 76 |
|
| 77 |
+
## GitHub
|
|
|
|
|
|
|
|
|
|
| 78 |
|
| 79 |
+
Full source code, architecture docs, and README:
|
| 80 |
+
**https://github.com/Ramyar2007/mediagent**
|
| 81 |
|
| 82 |
---
|
| 83 |
|
| 84 |
+
*This system is a decision support tool. All outputs must be reviewed by a licensed radiologist before any clinical decisions are made.*
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|