CoolFace
Apppublic

build-small-hackathon/ct-app

sourceHugging Faceapache-2.0updated 3mo agoView on Hugging Face
2likes
README.md96 linesDownload Raw Back to root
1---2title: Ct App3emoji: ๐Ÿ 4colorFrom: blue5colorTo: indigo6sdk: gradio7sdk_version: 6.18.08python_version: '3.13'9app_file: app.py10pinned: false11license: apache-2.012short_description: App that scans CT docs using TotalSegmentator model, flags o13tags:14  - track:backyard15  - sponsor:modal16  - achievement:offgrid17  - achievement:offbrand18  - achievement:fieldnotes19---20 21 22# ๐Ÿฉป CT Report Generator23> **An automated 3D volumetric reporting pipeline for CT scans, powered by TotalSegmentator (3D U-Net) (โšก ~30 Million Total Parameters) โ€” deployed serverlessly on Modal.**24 25> ๐Ÿ“บ **[Watch the full video demo and post on X (Twitter)!](https://x.com/AKIS23820044161/status/2066586748541657272)**26 27> Special Bonus Targets :  Tiny Titan (~30M parameters model) ยท Off-Brand Award 28---29 30## ๐Ÿ“– Overview31 32CT report generator is a Gradio-based clinical dashboard that automates the extraction and quantification of anatomical structures from 3D CT scans. It processes raw `.nii` / `.nii.gz` volumetric data, calculates the exact volume of dozens of internal organs, and automatically flags any measurements that fall outside of expected healthy reference ranges (e.g., hepatomegaly, splenomegaly, or asymmetrical kidneys).33 34---35 36## ๐Ÿš€ Features37 38| Feature | Description |39|---|---|40| ๐Ÿง  **Total Body Segmentation** | Automatically identifies and segments major solid organs, thoracic structures, and GI/GU tracts. |41| ๐Ÿ“Š **Clinical Volume Alerts** | Cross-references organ volumes with normal adult reference ranges and flags anomalies (e.g. Enlarged liver, asymmetric lungs). |42| ๐Ÿ–ผ๏ธ **Cross-Section Preview** | Generates an immediate mid-axial visual slice of the uploaded 3D volume. |43| ๐Ÿ“‘ **PDF Report Generation** | Automatically compiles the findings into a clean, professional, downloadable PDF clinical report using WeasyPrint. |44 45---46 47## ๐Ÿค– AI Models Used48 49### 1. `TotalSegmentator` โ€” 3D Anatomical Segmentation50- **Architecture:** 3D U-Net (nnU-Net framework)51- **Total Parameters:** ~30 Million (30M)52- **Task:** 3D medical image segmentation.53- **Used for:** Identifying and calculating the exact cubic centimeter (cmยณ) volume of 100+ anatomical structures from raw CT scans.54- **Inference:** Fast-mode enabled for rapid screening on Modal **A10G GPU**.55 56---57 58## ๐Ÿ—๏ธ Architecture59 60```61GRADIO FRONTEND (app.py)62  โ”œโ”€โ”€ 3D Visualization     โ†’ nibabel + PIL (Mid-axial slice rendering)63  โ”œโ”€โ”€ Validation           โ†’ Checks for valid 3D shape and intensity spread64  โ”œโ”€โ”€ PDF Generation       โ†’ WeasyPrint HTML-to-PDF conversion65  โ””โ”€โ”€ Remote RPC           โ†’ Connects to Modal backend via `modal.Cls`66 67MODAL SERVERLESS BACKEND (backend.py)68  โ””โ”€โ”€ Segmenter [A10G]     โ†’ `TotalSegmentator` subprocess69                           โ†’ JSON parsing & Reference Range Logic70                           โ†’ Returns structured clinical findings71```72 73---74 75## ๐Ÿ–ฅ๏ธ GPU Resources (Modal)76 77| Container | GPU | Model(s) | Purpose |78|---|---|---|---|79| `Segmenter` | A10G (24GB) | TotalSegmentator 3D U-Net | Heavy volumetric segmentation and pixel quantification |80 81---82 83## โš™๏ธ Setup & Deployment84 85```bash86# 1. Install dependencies87python -m venv venv && source venv/bin/activate88pip install -r requirements.txt89 90# 2. Deploy Modal backend91modal deploy backend.py92 93# 3. Run the Gradio frontend94python app.py95```96