Skip to content
Awais Asghar.
AI & Machine Learning2025

Outfit Classifier (Fashion-MNIST)

A from-scratch CNN that recognizes ten clothing categories.

A complete classification pipeline on Fashion-MNIST: preprocessing, a compact convolutional network, training curves and evaluation across T-shirts, trousers, dresses, sneakers, bags and more.

Outfit Classifier (Fashion-MNIST) thumbnail

README · rendered from GitHub

Outfit Classifier using CNN

Project Status Model Environment Framework License

This project builds a complete image classification system that identifies clothing items from the Fashion MNIST dataset. The goal is to train a CNN that can accurately classify outfits such as T-shirt, trouser, pullover, dress, coat, sandal, shirt, sneaker, bag, and ankle boot.

Image

1. Project Overview

This project builds a complete image classification system that identifies clothing items from the Fashion MNIST dataset. The goal is to train a CNN that can accurately classify outfits such as T-shirt, trouser, pullover, dress, coat, sandal, shirt, sneaker, bag, and ankle boot.

Image

Key Objectives

• Load and preprocess the Fashion MNIST dataset • Normalize and reshape images for CNN input • Build and train a CNN model • Evaluate model accuracy and loss • Visualize predictions and misclassifications • Save the trained model for deployment


2. Dataset Description

https://www.kaggle.com/datasets/electraawais/fashion-mnist-dataset

Fashion MNIST CSV dataset contains: • 60,000 training images • 10,000 test images • Each image is 28x28 pixels • Grayscale values from 0 to 255 • CSV structure: first column is label, remaining 784 columns are pixel values

Class Labels

0 T-shirt/top 1 Trouser 2 Pullover 3 Dress 4 Coat 5 Sandal 6 Shirt 7 Sneaker 8 Bag 9 Ankle boot

Image

3. Data Preparation

Image

Steps performed:

  1. Loaded training and test CSV files using pandas
  2. Separated labels and pixel data
  3. Normalized pixel data by dividing values by 255
  4. Reshaped flattened vectors into CNN-friendly format Shape used: (batch, 28, 28, 1)
  5. Converted labels to integer class values

Why normalization helps

• Speeds up convergence • Reduces gradient instability • Helps the CNN learn patterns more smoothly


4. Model Architecture (CNN)

Image Image

The model is a deep CNN with the following structure:

  1. Conv2D layer with ReLU activation
  2. MaxPooling2D
  3. Second Conv2D with ReLU
  4. Second MaxPooling2D
  5. Flatten layer
  6. Dense layer with 128 units
  7. Dense output layer with 10 units and softmax

Loss and Optimizer

• Loss function: Sparse Categorical Crossentropy • Optimizer: Adam • Metrics: Accuracy


5. Training Details

• Epochs used: 10 (or your value) • Batch size: 64 • Training performed on the normalized dataset • Validation accuracy monitored using test set

Image

Observations

• Training accuracy steadily increased • Validation accuracy stabilized around the model’s peak point • Overfitting was controlled by moderate depth and pooling layers


6. Evaluation Results

Typical results for this model architecture:

• Test accuracy: approx 88 percent to 92 percent • Test loss: low and stable • Confusion matrix shows common misclassifications between shirt and T-shirt categories

Image Image Image

Performance Insights

• CNN captures texture and shape information well • Fashion MNIST is harder than digit MNIST due to similar classes • Model performs strongly on distinct classes such as bag and sneaker


7. Visualizations Included in the Notebook

The notebook contains plots for:

• Sample input images • Training accuracy vs epochs • Training loss vs epochs • Predictions on random test images • Misclassified samples with true vs predicted labels

These visualizations help understand how well the model learns and where it struggles.


8. Model Saving

The trained CNN model is saved as an .h5 file. This allows: • Loading the model for inference • Deployment in applications • Further fine-tuning on custom datasets


9. Key Takeaways

• CNNs are highly effective for fashion item classification • Proper preprocessing significantly boosts performance • Even simple architectures achieve high accuracy on Fashion MNIST • The system is lightweight and suitable for real use cases

Image

More in AI / ML

Related projects

See all
  • AI / ML2025

    RecycleVision

    EfficientNetB0 transfer learning sorts waste into six recyclable categories.

    • Python
    • TensorFlow
    • Keras
    • EfficientNetB0