This project implements a complete end-to-end machine learning pipeline for binary image classification using FashionMNIST.
The model distinguishes Dress (label 3) from Sneaker (label 7) using a custom CNN, an inference API, and evaluation metrics.
mindsight-challenge/
│── src/
│ │── train.py
│ │── model.py
│ │── infer.py
│ │── utils.py
│
│── saved_models/
│ └── fashion_mnist_cnn.pth
│
│── dataset_samples_for_inference/
│ ├── dress_0.png
│ ├── dress_1.png
│ ├── sneaker_0.png
│ ├── sneaker_1.png
│
│── 1_data_analysis.py
│── 2_prepare_inference_samples.py
│── 3_compute_metrics.py
│── app.py
│── requirements.txt
│── Dockerfile
│── README.md
Run:
python3 1_data_analysis.pyThis script:
- Downloads FashionMNIST
- Prints dataset size
- Shows class distribution
- Visualizes sample images (train + test)
- Confirms that:
- Dress = label 3
- Sneaker = label 7
Run:
python3 src/train.pyTraining pipeline:
- Filters only classes 3 (Dress) and 7 (Sneaker)
- Remaps labels:
- Dress → 0
- Sneaker → 1
- Trains a lightweight CNN
- Achieves > 99% accuracy
- Saves trained model in:
saved_models/fashion_mnist_cnn.pth
Run:
python3 2_prepare_inference_samples.pyThis script extracts real test samples from FashionMNIST and stores them inside:
dataset_samples_for_inference/
dress_0.png
dress_1.png
sneaker_0.png
sneaker_1.png
You can upload these directly into Swagger UI.
Run:
python3 3_compute_metrics.pyThis script evaluates the trained model using the filtered test set
(Dress vs Sneaker only) and prints:
- Accuracy
- Precision
- Recall
- F1-score
- Confusion Matrix
A full report is also saved as:
metrics_report_binary.txt
Start the API:
uvicorn app:app --reloadThen open:
You can upload any image (PNG/JPG).
The API will:
- Convert to grayscale
- Resize to 28×28
- Normalize
- Predict "Dress" or "Sneaker"
python3 src/infer.py dataset_samples_for_inference/sneaker_0.pngBuild:
docker build -t mindsight-api .Run:
docker run -p 8000:8000 mindsight-apifastapi
uvicorn
torch
torchvision
pillow
numpy
python-multipart
scikit-learn
matplotlib
Install all with:
pip install -r requirements.txtSofia Brunori — Mindsight Challenge Submission

