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

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +19 -15
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[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
 
@@ -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.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()
 
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
+ ![Loss and Accuracy Curves](EfficientNet_B3_20percent.pth_curves.png)
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
+ ![Confusion Matrix](EfficientNet_B3_20percent.pth_confusion_matrix.png)
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
+ ![Wrong Predictions](EfficientNet_B3_20percent.pth_wrong_pred.png)
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()