Multi-Task Image Classification

One ResNet-50 backbone, four classification heads: colour, type, season and gender from a single product shot.

ML / DL2025All work

Fig. 01Chart of the ten most common article types in the training set
One ResNet-50 backbone, four classification heads: colour, type, season and gender from a single product shot.

What it is

What it does

Instead of four separate models, a shared ImageNet-pretrained ResNet-50 feeds four linear heads that predict product attributes simultaneously. The notebook covers the full loop: EDA, label encoding, training, evaluation and inference on live Amazon listings pulled straight off the web.

Why it exists

I didn't want four models for four labels on the same dress (colour, type, season, category). One backbone sees the fabric once; four tiny heads vote. Less training, same signal, and the seasonal correlation actually helps.

4
Prediction tasks
83.8%
Gender accuracy
1
Shared backbone

Repo Amit-kr26/Multi-Task-Image-ClassificationStack PyTorch · ResNet-50 · Multi-Task Learning · torchvision

Build5decisions

How it is built

Four-task heads

MultiTaskModel replaces ResNet-50's fc with Identity and attaches Linear heads for gender (5 classes), baseColour (44), season (4) and articleType (119).

Balanced data prep

The Kaggle Fashion Product Images dataset is null-filtered across all four label columns and sampled to 5,000 rows (seed 42), split 4,000 train / 1,000 test.

Deliberately light transforms

Resize to 224×224, ImageNet normalisation, nothing else. Augmentation was skipped so head-level differences stay attributable to the multi-task setup rather than preprocessing luck. A custom Dataset wrapper skips missing image files by index-wrapping instead of crashing.

Joint loss

Training minimises the unweighted sum of four CrossEntropyLoss terms. Simple, and enough since heads share the backbone rather than competing gradients.

Out-of-distribution check

Final cells fetch real Amazon product photos via requests + PIL and decode predictions end to end, an honest test beyond the held-out split.

How the pieces connect

One pass, four answers Train and measure styles.csv 44k rows Sample 5,000 4 label encoders Transform 224² ImageNet norm ResNet-50 2048-d backbone 4 linear heads 5 · 44 · 4 · 119 Joint loss 4 × CE, Adam 1e-3 5 epochs one pass per batch fashion_model.pth checkpoint Held-out test 1,000 rows Test accuracy 83.8 · 74.8 · 69.4 one sum of four cross-entropies