EfficientNet-B3 Pizza/Steak/Sushi Classifier

I fine-tuned a pre-trained EfficientNet-B3 model to classify images into three categories: pizza, steak, and sushi.

Model Details

  • Architecture: torchvision.models.efficientnet_b3
  • Weights: EfficientNet_B3_Weights.DEFAULT
  • Modifications: I froze all the base feature layers.

Training Procedure

I trained the model for 10 epochs using the Adam optimizer.

  • Batch Size: 32
  • Learning Rate: 0.001
  • Loss Function: CrossEntropyLoss
  • Transforms: I used the automatic transforms provided by the default EfficientNet-B3 weights.
  • Hardware: Trained using cuda (if available) with a set manual seed of 37 for reproducibility.

Dataset

I used a 20% subset of a pizza, steak, and sushi dataset. The data was split into train and test directories.

Evaluation Results

Accuracy and Loss Curves

Over the 10 epochs, both the training and testing loss steadily decreased, with the testing loss ending below 0.30. The testing accuracy remained highly stable and finished above 95%.

Loss and Accuracy Curves

Confusion Matrix

The model performs exceptionally well across all three classes on the test set:

  • Pizza: 42 correct, 2 misclassified as steak, 2 misclassified as sushi.
  • Steak: 57 correct, 0 misclassified as pizza, 1 misclassified as sushi.
  • Sushi: 45 correct, 0 misclassified as pizza, 1 misclassified as steak.

Confusion Matrix

Most Confident Wrong Predictions

I plotted the instances where the model was highly confident but incorrect. The model occasionally struggled with distinguishing close-up textures and lighting, such as predicting a steak dish as sushi with 0.73 confidence, or a pizza dish as steak with 0.46 confidence.

Wrong Predictions

How to use

import torch
import torchvision

# I loaded the model architecture
weights = torchvision.models.EfficientNet_B3_Weights.DEFAULT
model = torchvision.models.efficientnet_b3(weights=weights)

# I modified the classifier to match the 3 classes
model.classifier = torch.nn.Sequential(
    torch.nn.Dropout(p=0.2, inplace=True),
    torch.nn.Linear(in_features=1536, out_features=3, bias=True),
)

# I loaded the weights
model.load_state_dict(torch.load("EfficientNet_B3_20percent.pth", map_location="cpu"))
model.eval()
Downloads last month

-

Downloads are not tracked for this model. How to track
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Dataset used to train Shad0wKillar/efficientnet-b3

Collection including Shad0wKillar/efficientnet-b3