Shad0wKillar commited on
Commit
34fb82b
·
verified ·
1 Parent(s): bde9d3b

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +67 -3
README.md CHANGED
@@ -1,3 +1,67 @@
1
- ---
2
- license: mit
3
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: mit
3
+ tags:
4
+ - vision
5
+ - image-classification
6
+ - pytorch
7
+ - efficientnet
8
+ datasets:
9
+ - Shad0wKillar/pizza_steak_sushi
10
+ metrics:
11
+ - accuracy
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[cite: 1].
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
+
24
+ * **Batch Size:** 32
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.
32
+
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.40. The testing accuracy outperformed the training accuracy early on and finished highly stable above 90%.
37
+
38
+ ![Loss and Accuracy Curves](plots/EfficientNet_B3_20percent.pth_curves.png)
39
+
40
+ ### Confusion Matrix
41
+ The model performs exceptionally well across all three classes on the test set:
42
+ * **Pizza:** 45 correct, 0 misclassified as steak, 1 misclassified as sushi.
43
+ * **Steak:** 56 correct, 0 misclassified as pizza, 2 misclassified as sushi.
44
+ * **Sushi:** 42 correct, 3 misclassified as pizza, 1 misclassified as steak.
45
+
46
+ ![Confusion Matrix](plots/EfficientNet_B3_20percent.pth_confusion_matrix.png)
47
+
48
+ ### Most Confident Wrong Predictions
49
+ I plotted the instances where the model was highly confident but incorrect. The model occasionally struggled with distinguishing close-up textures, such as predicting a steak dish as sushi with 0.82 confidence, or a sushi dish as pizza with 0.61 confidence.
50
+
51
+ ![Wrong Predictions](plots/EfficientNet_B3_20percent.pth_wrong_pred.png)
52
+
53
+ ## How to use
54
+ ```python
55
+ import torch
56
+ import torchvision
57
+ # 1. Load the model architecture
58
+ weights = torchvision.models.EfficientNet_B3_Weights.DEFAULT
59
+ model = torchvision.models.efficientnet_b3(weights=weights)
60
+ # 2. Modify the classifier to match the 3 classes
61
+ model.classifier = torch.nn.Sequential(
62
+ torch.nn.Dropout(p=0.2, inplace=True),
63
+ torch.nn.Linear(in_features=1280, out_features=3, bias=True),
64
+ )
65
+ # 3. Load the weights
66
+ model.load_state_dict(torch.load("EfficientNet_B3_20percent.pth", map_location="cpu"))
67
+ model.eval()