Update README.md
Browse files
README.md
CHANGED
|
@@ -1,10 +1,73 @@
|
|
| 1 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2 |
tags:
|
|
|
|
| 3 |
- model_hub_mixin
|
| 4 |
- pytorch_model_hub_mixin
|
| 5 |
---
|
| 6 |
|
| 7 |
-
This model
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
---
|
| 2 |
+
license: mit
|
| 3 |
+
datasets:
|
| 4 |
+
- sdtemple/colored-shapes
|
| 5 |
+
language:
|
| 6 |
+
- en
|
| 7 |
+
metrics:
|
| 8 |
+
- accuracy
|
| 9 |
+
- precision
|
| 10 |
+
- recall
|
| 11 |
+
- roc_auc
|
| 12 |
+
pipeline_tag: image-classification
|
| 13 |
tags:
|
| 14 |
+
- tutorial
|
| 15 |
- model_hub_mixin
|
| 16 |
- pytorch_model_hub_mixin
|
| 17 |
---
|
| 18 |
|
| 19 |
+
This model predicts the shape (circle, rectangle, diamond, or triangle) of the 1 colored shape (8 colors) in a 224 x 224 x 3 image.
|
| 20 |
+
|
| 21 |
+
This model is a part of a how to tutorial on fitting PyTorch models.
|
| 22 |
+
|
| 23 |
+
The model is trained on 2000 examples for each color and shape combo (64,000 samples in total) simulated according to [https://github.com/sdtemple/zootopia3](https://github.com/sdtemple/zootopia3).
|
| 24 |
+
|
| 25 |
+
The model is tested/evaluated on the dataset [https://huggingface.co/datasets/sdtemple/colored-shapes](https://huggingface.co/datasets/sdtemple/colored-shapes), which has slightly smaller shapes simulated (out of distribution) relative to the training data. The metrics below can be +- a few points depending on random seed.
|
| 26 |
+
|
| 27 |
+
- Accuracy: 75%
|
| 28 |
+
- Min precision (triangle): 57%
|
| 29 |
+
- Max precision (rectangle): 98%
|
| 30 |
+
- Min recall (diamond): 66%
|
| 31 |
+
- Max recall (triangle): 84%
|
| 32 |
+
- AUROC (macro-averaged): 92%
|
| 33 |
+
- Min AUROC (diamond): 90%
|
| 34 |
+
- Max AUROC (circle): 94%
|
| 35 |
+
|
| 36 |
+
Compared to [https://huggingface.co/sdtemple/color-prediction-model](https://huggingface.co/sdtemple/color-prediction-model), it is harder to predict the shape than the color of the object.
|
| 37 |
+
|
| 38 |
+
The model architecture is the following. In light experimentation, I found it important to have multiple convolutions and that too many parameters leads to noisy validation losses by epoch.
|
| 39 |
+
|
| 40 |
+
```
|
| 41 |
+
MyCNN(
|
| 42 |
+
(conv_block): Sequential(
|
| 43 |
+
(0): Conv2d(3, 16, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
|
| 44 |
+
(1): BatchNorm2d(16, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
|
| 45 |
+
(2): MaxPool2d(kernel_size=2, stride=2, padding=0, dilation=1, ceil_mode=False)
|
| 46 |
+
(3): Conv2d(16, 16, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
|
| 47 |
+
(4): BatchNorm2d(16, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
|
| 48 |
+
(5): MaxPool2d(kernel_size=2, stride=2, padding=0, dilation=1, ceil_mode=False)
|
| 49 |
+
(6): Conv2d(16, 16, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
|
| 50 |
+
(7): BatchNorm2d(16, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
|
| 51 |
+
(8): MaxPool2d(kernel_size=2, stride=2, padding=0, dilation=1, ceil_mode=False)
|
| 52 |
+
(9): Conv2d(16, 16, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
|
| 53 |
+
(10): BatchNorm2d(16, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
|
| 54 |
+
(11): MaxPool2d(kernel_size=2, stride=2, padding=0, dilation=1, ceil_mode=False)
|
| 55 |
+
(12): Conv2d(16, 16, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
|
| 56 |
+
(13): BatchNorm2d(16, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
|
| 57 |
+
(14): AvgPool2d(kernel_size=2, stride=2, padding=0)
|
| 58 |
+
)
|
| 59 |
+
(linear_block): Sequential(
|
| 60 |
+
(0): Linear(in_features=784, out_features=16, bias=True)
|
| 61 |
+
(1): BatchNorm1d(16, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
|
| 62 |
+
(2): ReLU()
|
| 63 |
+
(3): Dropout(p=0.2, inplace=False)
|
| 64 |
+
(4): Linear(in_features=16, out_features=16, bias=True)
|
| 65 |
+
(5): BatchNorm1d(16, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
|
| 66 |
+
(6): ReLU()
|
| 67 |
+
(7): Dropout(p=0.2, inplace=False)
|
| 68 |
+
)
|
| 69 |
+
(output_block): Linear(in_features=16, out_features=4, bias=True)
|
| 70 |
+
)
|
| 71 |
+
```
|
| 72 |
+
|
| 73 |
+
This model has been pushed to the Hub using the [PytorchModelHubMixin](https://huggingface.co/docs/huggingface_hub/package_reference/mixins#huggingface_hub.PyTorchModelHubMixin) integration:
|