Update README.md
Browse files
README.md
CHANGED
|
@@ -12,12 +12,13 @@ metrics:
|
|
| 12 |
---
|
| 13 |
# EfficientNet-B3 Pizza/Steak/Sushi Classifier
|
| 14 |
|
| 15 |
-
I fine-tuned a pre-trained EfficientNet-B3 model to classify images into three categories: pizza, steak, and sushi
|
| 16 |
|
| 17 |
## Model Details
|
| 18 |
* **Architecture:** `torchvision.models.efficientnet_b3`
|
| 19 |
* **Weights:** `EfficientNet_B3_Weights.DEFAULT`
|
| 20 |
-
* **Modifications:** I froze all the base feature layers
|
|
|
|
| 21 |
## Training Procedure
|
| 22 |
I trained the model for 10 epochs using the Adam optimizer.
|
| 23 |
|
|
@@ -25,7 +26,7 @@ I trained the model for 10 epochs using the Adam optimizer.
|
|
| 25 |
* **Learning Rate:** 0.001
|
| 26 |
* **Loss Function:** CrossEntropyLoss
|
| 27 |
* **Transforms:** I used the automatic transforms provided by the default EfficientNet-B3 weights.
|
| 28 |
-
* **Hardware:** Trained using `cuda` (if available) with a set manual seed of 37 for reproducibility
|
| 29 |
|
| 30 |
## Dataset
|
| 31 |
I used a 20% subset of a pizza, steak, and sushi dataset. The data was split into `train` and `test` directories.
|
|
@@ -33,35 +34,38 @@ I used a 20% subset of a pizza, steak, and sushi dataset. The data was split int
|
|
| 33 |
## Evaluation Results
|
| 34 |
|
| 35 |
### Accuracy and Loss Curves
|
| 36 |
-
Over the 10 epochs, both the training and testing loss steadily decreased, with the testing loss ending below 0.
|
| 37 |
|
| 38 |
-

|
| 60 |
-
|
|
|
|
| 61 |
model.classifier = torch.nn.Sequential(
|
| 62 |
torch.nn.Dropout(p=0.2, inplace=True),
|
| 63 |
-
torch.nn.Linear(in_features=
|
| 64 |
)
|
| 65 |
-
|
|
|
|
| 66 |
model.load_state_dict(torch.load("EfficientNet_B3_20percent.pth", map_location="cpu"))
|
| 67 |
model.eval()
|
|
|
|
| 12 |
---
|
| 13 |
# EfficientNet-B3 Pizza/Steak/Sushi Classifier
|
| 14 |
|
| 15 |
+
I fine-tuned a pre-trained EfficientNet-B3 model to classify images into three categories: pizza, steak, and sushi.
|
| 16 |
|
| 17 |
## Model Details
|
| 18 |
* **Architecture:** `torchvision.models.efficientnet_b3`
|
| 19 |
* **Weights:** `EfficientNet_B3_Weights.DEFAULT`
|
| 20 |
+
* **Modifications:** I froze all the base feature layers.
|
| 21 |
+
|
| 22 |
## Training Procedure
|
| 23 |
I trained the model for 10 epochs using the Adam optimizer.
|
| 24 |
|
|
|
|
| 26 |
* **Learning Rate:** 0.001
|
| 27 |
* **Loss Function:** CrossEntropyLoss
|
| 28 |
* **Transforms:** I used the automatic transforms provided by the default EfficientNet-B3 weights.
|
| 29 |
+
* **Hardware:** Trained using `cuda` (if available) with a set manual seed of 37 for reproducibility.
|
| 30 |
|
| 31 |
## Dataset
|
| 32 |
I used a 20% subset of a pizza, steak, and sushi dataset. The data was split into `train` and `test` directories.
|
|
|
|
| 34 |
## Evaluation Results
|
| 35 |
|
| 36 |
### Accuracy and Loss Curves
|
| 37 |
+
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%.
|
| 38 |
|
| 39 |
+

|
| 40 |
|
| 41 |
### Confusion Matrix
|
| 42 |
The model performs exceptionally well across all three classes on the test set:
|
| 43 |
+
* **Pizza:** 42 correct, 2 misclassified as steak, 2 misclassified as sushi.
|
| 44 |
+
* **Steak:** 57 correct, 0 misclassified as pizza, 1 misclassified as sushi.
|
| 45 |
+
* **Sushi:** 45 correct, 0 misclassified as pizza, 1 misclassified as steak.
|
| 46 |
|
| 47 |
+

|
| 48 |
|
| 49 |
### Most Confident Wrong Predictions
|
| 50 |
+
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.
|
| 51 |
|
| 52 |
+

|
| 53 |
|
| 54 |
## How to use
|
| 55 |
```python
|
| 56 |
import torch
|
| 57 |
import torchvision
|
| 58 |
+
|
| 59 |
+
# I loaded the model architecture
|
| 60 |
weights = torchvision.models.EfficientNet_B3_Weights.DEFAULT
|
| 61 |
model = torchvision.models.efficientnet_b3(weights=weights)
|
| 62 |
+
|
| 63 |
+
# I modified the classifier to match the 3 classes
|
| 64 |
model.classifier = torch.nn.Sequential(
|
| 65 |
torch.nn.Dropout(p=0.2, inplace=True),
|
| 66 |
+
torch.nn.Linear(in_features=1536, out_features=3, bias=True),
|
| 67 |
)
|
| 68 |
+
|
| 69 |
+
# I loaded the weights
|
| 70 |
model.load_state_dict(torch.load("EfficientNet_B3_20percent.pth", map_location="cpu"))
|
| 71 |
model.eval()
|