Add image-level split support for CLIP fine-tuning

Image-level splits allow the model to see some images from each logo
brand during training, unlike logo-level splits where test brands are
completely unseen. This is less rigorous but more representative of
real-world use.

Changes:
- Add configs/image_level_splits.yaml with gentler training settings:
  - split_level: "image" for image-level splits
  - temperature: 0.15 (softer contrastive learning)
  - learning_rate: 5e-6 (slower learning)
  - max_epochs: 30 (more epochs)

- Update training/dataset.py:
  - Add split_level parameter to LogoDataset
  - Implement _split_images() for image-level splitting
  - Update LogoContrastiveDataset to use split-specific image mappings

- Update training/config.py:
  - Add split_level field to TrainingConfig

- Update train_clip_logo.py:
  - Pass split_level to create_dataloaders

Usage:
  uv run python train_clip_logo.py --config configs/image_level_splits.yaml
This commit is contained in:
Rick McEwen
2026-01-05 15:10:45 -05:00
parent 32bfefc022
commit 14a1bda3fa
4 changed files with 200 additions and 20 deletions

View File

@ -256,6 +256,7 @@ def main():
test_split=config.test_split,
seed=config.seed,
augmentation_strength=config.augmentation_strength,
split_level=getattr(config, 'split_level', 'logo'),
)
# Create trainer