How qianyufan8/medgemma-fl works
MedGemma-FL is a runnable NVIDIA FLARE research baseline for federated QLoRA fine-tuning of MedGemma on histopathology tissue classification; pediatric trial matching and Gemma Scope auditing are planned, not implemented. The main workflow downloads and shards image data, trains site-local adapters, aggregates them into a global adapter bank, then supports inference and separate accuracy evaluation. The graph reflects README capabilities and sampled source; unsampled wiring is omitted where uncertain.
Main entry points: client.py Site training client · job.py Federated job recipe · run_inference.py Inference runner · run_evaluation.py Accuracy evaluation
Components 19
Data preparation
- Dataset downloader
download_data.py - Image datasets
- Site shard preparation
prepare_data.py - Site JSON splits
Federated training
- Federated job recipe
job.py - Site training client
client.py - LoRA aggregation
custom_aggregators.py
Model and adapter
- Global LoRA bank
model.py - MedGemma model helpers
model.py - Prompt and label helpers
data_utils.py - LoRA rank helpers
lora_utils.py
Inference and evaluation
- Inference runner
run_inference.py - Inference utilities
inference_utils.py - Accuracy evaluation
run_evaluation.py - Predictions and metrics
Other components
- Researcher
- Zenodo datasets
- Hugging Face
- NVFlare runtime
Connections 29
- Researcher → Dataset downloader: starts download
- Dataset downloader → Zenodo datasets: downloads
- Dataset downloader → Image datasets: extracts archives
- Researcher → Site shard preparation: starts preparation
- Site shard preparation → Image datasets: reads images
- Site shard preparation → Site JSON splits: writes site splits
- Researcher → Federated job recipe: starts job
- Federated job recipe → NVFlare runtime: configures and launches
- Federated job recipe → Site training client: dispatches training
- Federated job recipe → Global LoRA bank: configures global model
- Federated job recipe → LoRA aggregation: selects aggregator
- Site training client → NVFlare runtime: exchanges adapter updates
- Site training client → Site JSON splits: loads site data
- Site training client → MedGemma model helpers: loads trainable model
- Site training client → Prompt and label helpers: formats examples
- Site training client → LoRA rank helpers: truncates global bank
- NVFlare runtime → LoRA aggregation: submits client updates
- LoRA aggregation → Global LoRA bank: aggregates adapter bank
- Researcher → Inference runner: runs prediction
- Inference runner → Inference utilities: loads and predicts
- Inference runner → Site JSON splits: reads validation samples
- Inference utilities → MedGemma model helpers: loads base model
- Inference runner → Predictions and metrics: prints predictions
- Researcher → Accuracy evaluation: runs evaluation
- Accuracy evaluation → Inference utilities: generates predictions
- Accuracy evaluation → Hugging Face: may load pretrained weights
- Accuracy evaluation → Image datasets: reads evaluation images
- Accuracy evaluation → Predictions and metrics: reports accuracy metrics
- Inference runner → Hugging Face: may load pretrained weights