--- title: Ct App emoji: ๐Ÿ  colorFrom: blue colorTo: indigo sdk: gradio sdk_version: 6.18.0 python_version: '3.13' app_file: app.py pinned: false license: apache-2.0 short_description: App that scans CT docs using TotalSegmentator model, flags o tags: - track:backyard - sponsor:modal - achievement:offgrid - achievement:offbrand - achievement:fieldnotes --- # ๐Ÿฉป CT Report Generator > **An automated 3D volumetric reporting pipeline for CT scans, powered by TotalSegmentator (3D U-Net) (โšก ~30 Million Total Parameters) โ€” deployed serverlessly on Modal.** > ๐Ÿ“บ **[Watch the full video demo and post on X (Twitter)!](https://x.com/AKIS23820044161/status/2066586748541657272)** > Special Bonus Targets : Tiny Titan (~30M parameters model) ยท Off-Brand Award --- ## ๐Ÿ“– Overview CT 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). --- ## ๐Ÿš€ Features | Feature | Description | |---|---| | ๐Ÿง  **Total Body Segmentation** | Automatically identifies and segments major solid organs, thoracic structures, and GI/GU tracts. | | ๐Ÿ“Š **Clinical Volume Alerts** | Cross-references organ volumes with normal adult reference ranges and flags anomalies (e.g. Enlarged liver, asymmetric lungs). | | ๐Ÿ–ผ๏ธ **Cross-Section Preview** | Generates an immediate mid-axial visual slice of the uploaded 3D volume. | | ๐Ÿ“‘ **PDF Report Generation** | Automatically compiles the findings into a clean, professional, downloadable PDF clinical report using WeasyPrint. | --- ## ๐Ÿค– AI Models Used ### 1. `TotalSegmentator` โ€” 3D Anatomical Segmentation - **Architecture:** 3D U-Net (nnU-Net framework) - **Total Parameters:** ~30 Million (30M) - **Task:** 3D medical image segmentation. - **Used for:** Identifying and calculating the exact cubic centimeter (cmยณ) volume of 100+ anatomical structures from raw CT scans. - **Inference:** Fast-mode enabled for rapid screening on Modal **A10G GPU**. --- ## ๐Ÿ—๏ธ Architecture ``` GRADIO FRONTEND (app.py) โ”œโ”€โ”€ 3D Visualization โ†’ nibabel + PIL (Mid-axial slice rendering) โ”œโ”€โ”€ Validation โ†’ Checks for valid 3D shape and intensity spread โ”œโ”€โ”€ PDF Generation โ†’ WeasyPrint HTML-to-PDF conversion โ””โ”€โ”€ Remote RPC โ†’ Connects to Modal backend via `modal.Cls` MODAL SERVERLESS BACKEND (backend.py) โ””โ”€โ”€ Segmenter [A10G] โ†’ `TotalSegmentator` subprocess โ†’ JSON parsing & Reference Range Logic โ†’ Returns structured clinical findings ``` --- ## ๐Ÿ–ฅ๏ธ GPU Resources (Modal) | Container | GPU | Model(s) | Purpose | |---|---|---|---| | `Segmenter` | A10G (24GB) | TotalSegmentator 3D U-Net | Heavy volumetric segmentation and pixel quantification | --- ## โš™๏ธ Setup & Deployment ```bash # 1. Install dependencies python -m venv venv && source venv/bin/activate pip install -r requirements.txt # 2. Deploy Modal backend modal deploy backend.py # 3. Run the Gradio frontend python app.py ```