Per-Modality Separate Model
SkillAI & modelsTrains one specialized model per imaging modality or series type, routing inputs by metadata at inference for modality-specific feature learning.
Available today. Use it from your connected AI after setup.
No other account needed.
Connect ahel once, and every AI you use reads what you have installed.
Then ask your AI: use the Per-Modality Separate Model skill
What this skill tells your AI
The instructions your AI receives, as published by wenmin-wu/ds-skills in skills/cv/per-modality-separate-model/SKILL.md and read by ahel’s review.
Overview
Different imaging modalities (CT vs MRI, or MRI T1 vs T2, or X-ray PA vs lateral) have fundamentally different contrast, resolution, and anatomy visibility. A single model must learn to handle all variations, diluting its capacity. Training separate models per modality lets each specialize — Sagittal T1 learns disc morphology while Axial T2 learns nerve root compression. At inference, series metadata routes each input to the correct model. Predictions are then aggregated per study.
Quick Start
import timm
import torch.nn as nn
MODALITIES = ['Sagittal T1', 'Sagittal T2/STIR', 'Axial T2']
# Train one model per modality
models = {}
optimizers = {}
for mod in MODALITIES:
model = timm.create_model('efficientnet_b3', pretrained=True,
num_classes=75, in_chans=1)
models[mod] = model.cuda()
optimizers[mod] = torch.optim.Adam(model.parameters(), lr=1e-4)
# Training loop: filter batches by modality
for images, labels, modality in dataloader:
model = models[modality]
optimizer = optimizers[modality]
model.train()
logits = model(images.cuda())
loss = criterion(logits, labels.cuda())
loss.backward()
optimizer.step()
optimizer.zero_grad()
# Inference: route by series_description
def predict_study(study_series):
predictions = {}
for series_desc, images in study_series.items():
model = models[series_desc]
model.eval()
with torch.no_grad():
predictions[series_desc] = model(images.cuda())
return aggregate(predictions)
Workflow
- Group training data by modality/series type using metadata
- Initialize one model per modality (same or different architectures)
- Train each model only on its modality's data
- At inference, read series metadata to route inputs to the correct model
- Aggregate per-modality predictions at the study level
Key Decisions
- Shared vs separate architecture: Start with same backbone; switch to modality-specific if performance differs
- Data imbalance: Some modalities have fewer samples — adjust epochs or use class weights
- Aggregation: Average, max, or learned combination of per-modality predictions
- vs channel stacking: Separate models use more parameters but specialize better
References
Signals
- GitHub stars
- 60
- Forks
- 4
- Last commit
- Apr 2026
Advanced
- Catalog kind
- skill
- Gateway key
cv-per-modality-separate-model- Source
- github.com/wenmin-wu/ds-skills