Analyze CT scans with Google's MedGemma 1.5 vision-language model via mlx-vlm on Apple Silicon. Upload DICOM files, preview windowed slices, and get streaming AI-generated clinical analysis — all in a local Streamlit app.
For educational purposes only — not for clinical use.
- Apple Silicon Mac (M1 or later)
- uv
- Hugging Face account with MedGemma access
-
Install dependencies:
uv sync
-
Create a
.envfile with your Hugging Face token:HF_TOKEN=hf_...
uv run streamlit run streamlit_app.py- Upload
.dcmfiles in the sidebar - Adjust max slices and prompts as needed
- Preview the windowed CT slices (animated GIF)
- Click Analyze to run MedGemma inference (streams token-by-token)
DICOMs are parsed, sorted by instance number, and uniformly sampled to a configurable max. Each slice is windowed into 3-channel RGB:
| Channel | Window | HU Range |
|---|---|---|
| Red | Wide | -1024..1024 |
| Green | Soft tissue | -135..215 |
| Blue | Brain | 0..80 |
Windowed slices are passed as PIL images in a multi-image chat message. Inference runs locally via mlx-vlm with streaming output.
uv run pytest tests/ -v # run tests
uv run ruff check . # lint
uv run ruff format . # format
uv run ty check # type checkct_utils.py # CT processing utilities (windowing, sampling, DICOM parsing)
streamlit_app.py # Streamlit UI and MedGemma inference via mlx-vlm
tests/
test_ct_utils.py # Unit and integration tests
samples/ # Sample DICOM files for testing