Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/tommyngx/MammoMix/llms.txt

Use this file to discover all available pages before exploring further.

This guide walks you through cloning MammoMix, installing its dependencies, preparing a mammography dataset, launching a YOLOS training run, and reading the evaluation results that print automatically when training completes.
MammoMix trains on GPU by default. train.py sets CUDA_VISIBLE_DEVICES=0 and enables fp16 automatically when a CUDA device is detected. A machine with at least one CUDA-capable GPU is strongly recommended.
1

Clone the repository

git clone https://github.com/tommyngx/MammoMix.git && cd MammoMix
2

Install dependencies

pip install -r requirements.txt
This installs PyTorch, HuggingFace Transformers, TIMM, Datasets, Weights & Biases, and torchmetrics[detection]. See Installation for a full breakdown of each dependency and CUDA version notes.
3

Prepare your dataset

MammoMix expects datasets to be split into train/, val/, and test/ subdirectories, each containing images/ and labels/ folders with VOC-format XML annotations. The splitting.py script handles this for all three supported datasets at once.Open splitting.py and set the path variables at the bottom of the file:
DATASETS     = ['CSAW', 'DDSM', 'DMID']
RAW_DATA_DIR = 'AJCAI25/raw'
SPLITS_DIR   = 'AJCAI25/splits'
VAL_SPLIT    = 0.2
Then run the script:
python splitting.py
The script reads raw images and XML annotations from RAW_DATA_DIR, cross-validates them against each dataset’s bbox_annotations.csv, and writes split manifests (train.txt, val.txt, test.txt) to SPLITS_DIR. The validation split (20% by default) is carved from the training set using a fixed random seed of 42 for reproducibility.Once splitting is done, update splits_dir in your chosen config to point at SPLITS_DIR:
dataset:
  splits_dir: AJCAI25/splits
4

Train a YOLOS model

Pass the config file and a dataset name to train.py. The --dataset flag overrides the dataset.name field in the config:
python train.py --config configs/config_yolos.yaml --dataset CSAW
Training loads hustvl/yolos-base from HuggingFace Hub and fine-tunes it for 30 epochs using a cosine-with-restarts learning rate schedule, gradient accumulation over 2 steps, and per-epoch warmup. The best checkpoint by eval_map_50 is kept. When the run finishes, the model is saved to a timestamped directory:
../yolos_CSAW_120525/
├── config.json
├── model.safetensors
└── preprocessor_config.json
5

Evaluate on the test set

Evaluation runs automatically at the end of train.py — no separate command needed. Results are printed directly to the console:
=== Evaluating on test dataset ===
Test dataset: 412 samples

=== Test Results ===
test_map: 0.3812
test_map_50: 0.5471
test_map_75: 0.3204
test_map_small: 0.1023
test_map_medium: 0.4102
test_map_large: 0.5890
test_loss: 1.2347
The metric names follow the torchmetrics MeanAveragePrecision output format. test_map_50 is the primary metric used for model selection during training.
MammoMix logs all training runs to Weights & Biases automatically via report_to="all" in TrainingArguments. Run wandb login before training to authenticate, and set logging.wandb_project in your config file to organize runs by project name. The W&B run name is generated automatically as {model}_{dataset}_{DDMMYY}.

Build docs developers (and LLMs) love