Skip to content

Paul Louppe

Machine Learning Engineer at Ethiqais

French & English NancyGitHub

Chihuahua or Muffin?

Computer VisionCNNPyTorchImage ClassificationDeep Learning
Year
2023
Status
Completed experiment
Role
Model training and evaluation

Custom PyTorch CNN experiment for distinguishing visually similar chihuahua and muffin images.

Problem

Chihuahuas and muffins are a useful toy problem for computer vision because the two classes can look surprisingly similar in small images. The goal was to train a convolutional neural network that could separate the two categories while learning how architecture choices affect model performance.

This project focused on the complete training workflow: dataset collection, preprocessing, architecture design, evaluation, and error analysis.

Approach

I collected roughly 5,000 images from Kaggle, organized them into class folders, resized them to 224x224 pixels, converted them into tensors, and split the dataset into training, validation, and test sets.

I then compared several CNN architectures:

  • A two-layer CNN with Xavier initialization, ReLU activations, and max-pooling.
  • A deeper four-layer CNN designed to capture more visual detail.
  • A three-layer CNN that balanced capacity and generalization.
  • A regularized variant using batch normalization and dropout.

Architecture

The best-performing model was a three-layer CNN with approximately 133,000 parameters. It used convolutional blocks for feature extraction followed by dense layers for classification. The model was trained for 20 epochs and monitored with training and validation curves.

The experiment also included a confusion matrix to understand where the model failed and whether the errors came from ambiguous images, preprocessing artifacts, or class-specific visual overlap.

Results

The strongest model reached 87.25% accuracy on the test set. The simple two-layer CNN also performed well, reaching around 85%, while the deeper and heavily regularized variants underperformed.

Key outcomes:

  • Built and trained multiple CNN architectures in PyTorch.
  • Reached 87.25% test accuracy with the three-layer model.
  • Identified cases where image quality, drawings, unusual backgrounds, or aggressive resizing caused failures.
  • Learned that additional depth and regularization do not automatically improve a small computer vision model.

What I learned

The project reinforced the value of starting simple, measuring carefully, and adding complexity only when the evidence supports it. The deeper model performed close to random guessing, which made the comparison more useful than if every architecture had improved monotonically.

It also showed that preprocessing and dataset quality can matter as much as model design. A cleaner dataset would likely improve performance beyond 90%.

Next steps

Future work would include transfer learning with pretrained vision models, stronger data augmentation, better filtering of low-quality images, and a small demo interface for uploading an image and inspecting the model prediction.