Add model card with training details and usage instructions
Browse files
README.md
CHANGED
|
@@ -1,199 +1,177 @@
|
|
| 1 |
---
|
| 2 |
-
library_name:
|
| 3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
---
|
| 5 |
|
| 6 |
-
#
|
| 7 |
-
|
| 8 |
-
<!-- Provide a quick summary of what the model is/does. -->
|
| 9 |
|
|
|
|
| 10 |
|
|
|
|
| 11 |
|
| 12 |
## Model Details
|
| 13 |
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
|
| 88 |
-
|
| 89 |
-
|
| 90 |
-
|
| 91 |
-
|
| 92 |
-
|
| 93 |
-
|
| 94 |
-
|
| 95 |
-
|
| 96 |
-
|
| 97 |
-
|
| 98 |
-
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
|
| 102 |
-
|
| 103 |
-
|
| 104 |
-
|
| 105 |
-
|
| 106 |
-
|
| 107 |
-
|
| 108 |
-
|
| 109 |
-
|
| 110 |
-
|
| 111 |
-
|
| 112 |
-
|
| 113 |
-
|
| 114 |
-
|
| 115 |
-
|
| 116 |
-
|
| 117 |
-
|
| 118 |
-
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
|
| 122 |
-
|
| 123 |
-
|
| 124 |
-
|
| 125 |
-
[
|
| 126 |
-
|
| 127 |
-
|
| 128 |
-
|
| 129 |
-
|
| 130 |
-
|
| 131 |
-
|
| 132 |
-
|
| 133 |
-
|
| 134 |
-
|
| 135 |
-
|
| 136 |
-
|
| 137 |
-
|
| 138 |
-
|
| 139 |
-
|
| 140 |
-
|
| 141 |
-
|
| 142 |
-
|
| 143 |
-
|
| 144 |
-
|
| 145 |
-
|
| 146 |
-
|
| 147 |
-
|
| 148 |
-
-
|
| 149 |
-
|
| 150 |
-
|
| 151 |
-
|
| 152 |
-
|
| 153 |
-
|
| 154 |
-
|
| 155 |
-
|
| 156 |
-
|
| 157 |
-
|
| 158 |
-
|
| 159 |
-
##
|
| 160 |
-
|
| 161 |
-
|
| 162 |
-
|
| 163 |
-
#### Hardware
|
| 164 |
-
|
| 165 |
-
[More Information Needed]
|
| 166 |
-
|
| 167 |
-
#### Software
|
| 168 |
-
|
| 169 |
-
[More Information Needed]
|
| 170 |
-
|
| 171 |
-
## Citation [optional]
|
| 172 |
-
|
| 173 |
-
<!-- If there is a paper or blog post introducing the model, the APA and Bibtex information for that should go in this section. -->
|
| 174 |
-
|
| 175 |
-
**BibTeX:**
|
| 176 |
-
|
| 177 |
-
[More Information Needed]
|
| 178 |
-
|
| 179 |
-
**APA:**
|
| 180 |
-
|
| 181 |
-
[More Information Needed]
|
| 182 |
-
|
| 183 |
-
## Glossary [optional]
|
| 184 |
-
|
| 185 |
-
<!-- If relevant, include terms and calculations in this section that can help readers understand the model or model card. -->
|
| 186 |
-
|
| 187 |
-
[More Information Needed]
|
| 188 |
-
|
| 189 |
-
## More Information [optional]
|
| 190 |
-
|
| 191 |
-
[More Information Needed]
|
| 192 |
-
|
| 193 |
-
## Model Card Authors [optional]
|
| 194 |
-
|
| 195 |
-
[More Information Needed]
|
| 196 |
-
|
| 197 |
-
## Model Card Contact
|
| 198 |
-
|
| 199 |
-
[More Information Needed]
|
|
|
|
| 1 |
---
|
| 2 |
+
library_name: peft
|
| 3 |
+
license: other
|
| 4 |
+
license_name: health-ai-developer-foundations
|
| 5 |
+
license_link: https://developers.google.com/health-ai-developer-foundations/terms
|
| 6 |
+
base_model: google/medgemma-4b-it
|
| 7 |
+
tags:
|
| 8 |
+
- medgemma
|
| 9 |
+
- lora
|
| 10 |
+
- medical-ai
|
| 11 |
+
- abdominal-ct
|
| 12 |
+
- organ-classification
|
| 13 |
+
- hai-def
|
| 14 |
+
- medmnist
|
| 15 |
+
datasets:
|
| 16 |
+
- satwatbashir/organamnist
|
| 17 |
+
language:
|
| 18 |
+
- en
|
| 19 |
+
pipeline_tag: image-text-to-text
|
| 20 |
---
|
| 21 |
|
| 22 |
+
# MedGemma Abdominal CT LoRA
|
|
|
|
|
|
|
| 23 |
|
| 24 |
+
**Abdominal organ classification adapter fine-tuned on OrganAMNIST (MedMNIST) using MedGemma 4B.**
|
| 25 |
|
| 26 |
+
Identifies the primary organ or anatomical structure visible in abdominal CT axial slices across 11 classes.
|
| 27 |
|
| 28 |
## Model Details
|
| 29 |
|
| 30 |
+
| Property | Value |
|
| 31 |
+
|----------|-------|
|
| 32 |
+
| **Base Model** | [google/medgemma-4b-it](https://huggingface.co/google/medgemma-4b-it) |
|
| 33 |
+
| **Method** | LoRA (Low-Rank Adaptation) |
|
| 34 |
+
| **Task** | Multi-class organ classification (11 classes) |
|
| 35 |
+
| **Modality** | Abdominal CT (axial 2D slices) |
|
| 36 |
+
| **Framework** | PyTorch + HuggingFace Transformers + PEFT |
|
| 37 |
+
|
| 38 |
+
## Training Dataset
|
| 39 |
+
|
| 40 |
+
**[OrganAMNIST](https://huggingface.co/datasets/satwatbashir/organamnist)** from the MedMNIST v2 benchmark — standardized 2D axial CT slices for organ classification.
|
| 41 |
+
|
| 42 |
+
Reference: Yang et al. 2023, *Scientific Data* - "MedMNIST v2: A Large-Scale Lightweight Benchmark for 2D and 3D Biomedical Image Classification"
|
| 43 |
+
|
| 44 |
+
- **Original dataset:** ~58,850 images
|
| 45 |
+
- **Train samples:** 10,000 (curated subset)
|
| 46 |
+
- **Validation samples:** 1,000
|
| 47 |
+
- **Image size:** 28x28 pixels (MedMNIST standard, resized by processor)
|
| 48 |
+
|
| 49 |
+
### Class Distribution
|
| 50 |
+
|
| 51 |
+
| ID | Organ | Description |
|
| 52 |
+
|:---:|-------|-------------|
|
| 53 |
+
| 0 | Bladder | Urinary bladder in the pelvis |
|
| 54 |
+
| 1 | Femur (left) | Proximal left femur and femoral head |
|
| 55 |
+
| 2 | Femur (right) | Proximal right femur and femoral head |
|
| 56 |
+
| 3 | Heart | Cardiac silhouette with chambers and great vessels |
|
| 57 |
+
| 4 | Kidney (left) | Left kidney with cortex and medulla |
|
| 58 |
+
| 5 | Kidney (right) | Right kidney (slightly lower due to liver) |
|
| 59 |
+
| 6 | Liver | Largest solid abdominal organ, right upper quadrant |
|
| 60 |
+
| 7 | Lung (left) | Left hemithorax pulmonary tissue |
|
| 61 |
+
| 8 | Lung (right) | Right hemithorax, three lobes |
|
| 62 |
+
| 9 | Spleen | Left upper quadrant, posterior to stomach |
|
| 63 |
+
| 10 | Pancreas | Retroperitoneal organ crossing midline |
|
| 64 |
+
|
| 65 |
+
## Training Configuration
|
| 66 |
+
|
| 67 |
+
### LoRA Parameters
|
| 68 |
+
|
| 69 |
+
| Parameter | Value |
|
| 70 |
+
|-----------|-------|
|
| 71 |
+
| Rank (r) | 16 |
|
| 72 |
+
| Alpha | 32 |
|
| 73 |
+
| Dropout | 0.05 |
|
| 74 |
+
| Target Modules | all-linear |
|
| 75 |
+
| Task Type | CAUSAL_LM |
|
| 76 |
+
| Trainable Params | 1.38B / 5.68B (24.3%) |
|
| 77 |
+
|
| 78 |
+
### Hyperparameters
|
| 79 |
+
|
| 80 |
+
| Parameter | Value |
|
| 81 |
+
|-----------|-------|
|
| 82 |
+
| Epochs | 1 |
|
| 83 |
+
| Per-device Batch Size | 1 |
|
| 84 |
+
| Gradient Accumulation Steps | 8 (effective batch = 8) |
|
| 85 |
+
| Learning Rate | 2e-4 |
|
| 86 |
+
| LR Scheduler | Linear with warmup |
|
| 87 |
+
| Warmup Ratio | 0.03 |
|
| 88 |
+
| Max Grad Norm | 0.3 |
|
| 89 |
+
| Precision | bfloat16 |
|
| 90 |
+
| Gradient Checkpointing | Enabled |
|
| 91 |
+
| Seed | 42 |
|
| 92 |
+
|
| 93 |
+
### Infrastructure
|
| 94 |
+
|
| 95 |
+
| Property | Value |
|
| 96 |
+
|----------|-------|
|
| 97 |
+
| GPU | NVIDIA L4 (24 GB VRAM) |
|
| 98 |
+
| Cloud Platform | [Modal](https://modal.com) serverless GPU |
|
| 99 |
+
| Training Time | ~45-60 minutes |
|
| 100 |
+
|
| 101 |
+
## Prompt Format
|
| 102 |
+
|
| 103 |
+
**Input:**
|
| 104 |
+
> Identify the primary organ or structure visible in this abdominal CT slice.
|
| 105 |
+
|
| 106 |
+
**Output:**
|
| 107 |
+
> This abdominal CT slice primarily shows the **Liver**.
|
| 108 |
+
>
|
| 109 |
+
> Liver (largest solid organ in the abdomen, occupying the right upper quadrant with homogeneous parenchymal density).
|
| 110 |
+
|
| 111 |
+
## Usage
|
| 112 |
+
|
| 113 |
+
```python
|
| 114 |
+
from transformers import AutoProcessor, AutoModelForImageTextToText
|
| 115 |
+
from peft import PeftModel
|
| 116 |
+
from PIL import Image
|
| 117 |
+
|
| 118 |
+
base_model_id = "google/medgemma-4b-it"
|
| 119 |
+
adapter_id = "efecelik/medgemma-abdominal-ct-lora"
|
| 120 |
+
|
| 121 |
+
processor = AutoProcessor.from_pretrained(base_model_id)
|
| 122 |
+
model = AutoModelForImageTextToText.from_pretrained(
|
| 123 |
+
base_model_id, torch_dtype="bfloat16", device_map="auto"
|
| 124 |
+
)
|
| 125 |
+
model = PeftModel.from_pretrained(model, adapter_id)
|
| 126 |
+
|
| 127 |
+
image = Image.open("abdominal_ct.jpg").convert("RGB")
|
| 128 |
+
messages = [
|
| 129 |
+
{"role": "user", "content": [
|
| 130 |
+
{"type": "image"},
|
| 131 |
+
{"type": "text", "text": "Identify the primary organ or structure visible in this abdominal CT slice."}
|
| 132 |
+
]}
|
| 133 |
+
]
|
| 134 |
+
|
| 135 |
+
inputs = processor.apply_chat_template(
|
| 136 |
+
messages, add_generation_prompt=True, tokenize=True,
|
| 137 |
+
return_dict=True, return_tensors="pt", images=[image]
|
| 138 |
+
).to(model.device)
|
| 139 |
+
|
| 140 |
+
output = model.generate(**inputs, max_new_tokens=256)
|
| 141 |
+
print(processor.decode(output[0], skip_special_tokens=True))
|
| 142 |
+
```
|
| 143 |
+
|
| 144 |
+
## Intended Use
|
| 145 |
+
|
| 146 |
+
This adapter is part of the **MedVision AI** platform built for the [MedGemma Impact Challenge](https://www.kaggle.com/competitions/med-gemma-impact-challenge). It is designed for:
|
| 147 |
+
|
| 148 |
+
- **Medical education**: Helping students learn abdominal CT anatomy and organ identification
|
| 149 |
+
- **Clinical decision support**: Assisting radiologists with organ localization
|
| 150 |
+
- **Research**: Exploring fine-tuned medical VLMs for abdominal imaging
|
| 151 |
+
|
| 152 |
+
## Limitations
|
| 153 |
+
|
| 154 |
+
- **Not for clinical diagnosis.** This model is for educational and research purposes only.
|
| 155 |
+
- **Organ identification only:** Classifies visible organ, does not detect pathology within organs.
|
| 156 |
+
- **Low resolution source:** MedMNIST images are 28x28 pixels, limiting fine structural detail.
|
| 157 |
+
- **Normal anatomy only:** Trained on healthy organ appearances, not pathological variants.
|
| 158 |
+
- **Single epoch:** Trained for 1 epoch; further training may improve performance.
|
| 159 |
+
|
| 160 |
+
## Citation
|
| 161 |
+
|
| 162 |
+
```bibtex
|
| 163 |
+
@article{yang2023medmnist,
|
| 164 |
+
title={MedMNIST v2-A large-scale lightweight benchmark for 2D and 3D biomedical image classification},
|
| 165 |
+
author={Yang, Jiancheng and Shi, Rui and Wei, Donglai and Liu, Zequan and Zhao, Lin and Ke, Bilian and Pfister, Hanspeter and Ni, Bingbing},
|
| 166 |
+
journal={Scientific Data},
|
| 167 |
+
volume={10},
|
| 168 |
+
number={1},
|
| 169 |
+
pages={41},
|
| 170 |
+
year={2023},
|
| 171 |
+
publisher={Nature Publishing Group UK London}
|
| 172 |
+
}
|
| 173 |
+
```
|
| 174 |
+
|
| 175 |
+
## Disclaimer
|
| 176 |
+
|
| 177 |
+
This model is for **educational and research purposes only**. It is NOT intended for clinical diagnosis or patient care decisions. Always consult qualified medical professionals for medical advice.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|