nailarais1 commited on
Commit
7360266
·
verified ·
1 Parent(s): 12f8bb5

Upload 7 files

Browse files
.gitattributes ADDED
@@ -0,0 +1 @@
 
 
1
+ checkpoint.pth filter=lfs diff=lfs merge=lfs -text
README.md ADDED
@@ -0,0 +1,92 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ library_name: pytorch
3
+ tags:
4
+ - pytorch
5
+ - image-classification
6
+ - flowers
7
+ - computer-vision
8
+ pipeline_tag: image-classification
9
+ ---
10
+
11
+ # 🌸 102-Flower Image Classifier — EfficientNet-B0
12
+
13
+ PyTorch image-classification model trained to recognize **102 flower categories**.
14
+
15
+ ## Results
16
+
17
+ - Architecture: **EfficientNet-B0**
18
+ - Classes: **102**
19
+ - Input: **224 × 224**
20
+ - Best validation accuracy: **94.38%**
21
+ - Epochs: **3**
22
+ - Optimizer: **AdamW**
23
+ - Learning rate: **0.001**
24
+
25
+ ## Files
26
+
27
+ - `checkpoint.pth` — trained model checkpoint
28
+ - `model_config.json` — model architecture metadata
29
+ - `training_config.json` — training settings and validation result
30
+ - `class_config.json` — exact class/index mappings
31
+ - `labels.txt` — labels in model-output index order
32
+ - `requirements.txt` — Python dependencies
33
+
34
+ ## Use the model
35
+
36
+ ```python
37
+ import torch
38
+ import torch.nn as nn
39
+ from torchvision import models, transforms
40
+ from PIL import Image
41
+
42
+ checkpoint = torch.load("checkpoint.pth", map_location="cpu")
43
+
44
+ model = models.efficientnet_b0(weights=None)
45
+ model.classifier[1] = nn.Linear(model.classifier[1].in_features, 102)
46
+
47
+ model.load_state_dict(checkpoint["model_state_dict"])
48
+ model.eval()
49
+
50
+ idx_to_class = {
51
+ int(k): v for k, v in __import__("json").load(open("class_config.json"))["idx_to_class"].items()
52
+ }
53
+
54
+ transform = transforms.Compose([
55
+ transforms.Resize(256),
56
+ transforms.CenterCrop(224),
57
+ transforms.ToTensor(),
58
+ transforms.Normalize([0.485, 0.456, 0.406],
59
+ [0.229, 0.224, 0.225])
60
+ ])
61
+
62
+ image = Image.open("flower.jpg").convert("RGB")
63
+ x = transform(image).unsqueeze(0)
64
+
65
+ with torch.no_grad():
66
+ probabilities = torch.softmax(model(x), dim=1)
67
+ confidence, prediction = probabilities.max(dim=1)
68
+
69
+ idx = prediction.item()
70
+ print("Prediction:", idx_to_class[idx])
71
+ print("Confidence:", f"{confidence.item()*100:.2f}%")
72
+ ```
73
+
74
+ ## Checkpoint contents
75
+
76
+ The checkpoint contains:
77
+ - `epoch`
78
+ - `model_state_dict`
79
+ - `optimizer_state_dict`
80
+ - `class_to_idx`
81
+
82
+ ## Training
83
+
84
+ The model was trained with transfer learning using an ImageNet-pretrained EfficientNet-B0 backbone, then fine-tuned for the 102 flower classes.
85
+
86
+ ## Citation / attribution
87
+
88
+ Please retain attribution to the model author when redistributing or building upon this model. Check the original dataset's license and terms before redistribution.
89
+
90
+ ## License
91
+
92
+ Add the license that applies to your model and dataset before publishing.
checkpoint.pth ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:968d2b85efa0f8825261d7ba4ed5fc82f7e1f92dd25ac9b0483f47534c5fc4d2
3
+ size 50127726
class_config.json ADDED
@@ -0,0 +1,210 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "class_to_idx": {
3
+ "1": 0,
4
+ "10": 1,
5
+ "100": 2,
6
+ "101": 3,
7
+ "102": 4,
8
+ "11": 5,
9
+ "12": 6,
10
+ "13": 7,
11
+ "14": 8,
12
+ "15": 9,
13
+ "16": 10,
14
+ "17": 11,
15
+ "18": 12,
16
+ "19": 13,
17
+ "2": 14,
18
+ "20": 15,
19
+ "21": 16,
20
+ "22": 17,
21
+ "23": 18,
22
+ "24": 19,
23
+ "25": 20,
24
+ "26": 21,
25
+ "27": 22,
26
+ "28": 23,
27
+ "29": 24,
28
+ "3": 25,
29
+ "30": 26,
30
+ "31": 27,
31
+ "32": 28,
32
+ "33": 29,
33
+ "34": 30,
34
+ "35": 31,
35
+ "36": 32,
36
+ "37": 33,
37
+ "38": 34,
38
+ "39": 35,
39
+ "4": 36,
40
+ "40": 37,
41
+ "41": 38,
42
+ "42": 39,
43
+ "43": 40,
44
+ "44": 41,
45
+ "45": 42,
46
+ "46": 43,
47
+ "47": 44,
48
+ "48": 45,
49
+ "49": 46,
50
+ "5": 47,
51
+ "50": 48,
52
+ "51": 49,
53
+ "52": 50,
54
+ "53": 51,
55
+ "54": 52,
56
+ "55": 53,
57
+ "56": 54,
58
+ "57": 55,
59
+ "58": 56,
60
+ "59": 57,
61
+ "6": 58,
62
+ "60": 59,
63
+ "61": 60,
64
+ "62": 61,
65
+ "63": 62,
66
+ "64": 63,
67
+ "65": 64,
68
+ "66": 65,
69
+ "67": 66,
70
+ "68": 67,
71
+ "69": 68,
72
+ "7": 69,
73
+ "70": 70,
74
+ "71": 71,
75
+ "72": 72,
76
+ "73": 73,
77
+ "74": 74,
78
+ "75": 75,
79
+ "76": 76,
80
+ "77": 77,
81
+ "78": 78,
82
+ "79": 79,
83
+ "8": 80,
84
+ "80": 81,
85
+ "81": 82,
86
+ "82": 83,
87
+ "83": 84,
88
+ "84": 85,
89
+ "85": 86,
90
+ "86": 87,
91
+ "87": 88,
92
+ "88": 89,
93
+ "89": 90,
94
+ "9": 91,
95
+ "90": 92,
96
+ "91": 93,
97
+ "92": 94,
98
+ "93": 95,
99
+ "94": 96,
100
+ "95": 97,
101
+ "96": 98,
102
+ "97": 99,
103
+ "98": 100,
104
+ "99": 101
105
+ },
106
+ "idx_to_class": {
107
+ "0": "pink primrose",
108
+ "1": "globe thistle",
109
+ "2": "blanket flower",
110
+ "3": "trumpet creeper",
111
+ "4": "blackberry lily",
112
+ "5": "snapdragon",
113
+ "6": "colt's foot",
114
+ "7": "king protea",
115
+ "8": "spear thistle",
116
+ "9": "yellow iris",
117
+ "10": "globe-flower",
118
+ "11": "purple coneflower",
119
+ "12": "peruvian lily",
120
+ "13": "balloon flower",
121
+ "14": "hard-leaved pocket orchid",
122
+ "15": "giant white arum lily",
123
+ "16": "fire lily",
124
+ "17": "pincushion flower",
125
+ "18": "fritillary",
126
+ "19": "red ginger",
127
+ "20": "grape hyacinth",
128
+ "21": "corn poppy",
129
+ "22": "prince of wales feathers",
130
+ "23": "stemless gentian",
131
+ "24": "artichoke",
132
+ "25": "canterbury bells",
133
+ "26": "sweet william",
134
+ "27": "carnation",
135
+ "28": "garden phlox",
136
+ "29": "love in the mist",
137
+ "30": "mexican aster",
138
+ "31": "alpine sea holly",
139
+ "32": "ruby-lipped cattleya",
140
+ "33": "cape flower",
141
+ "34": "great masterwort",
142
+ "35": "siam tulip",
143
+ "36": "sweet pea",
144
+ "37": "lenten rose",
145
+ "38": "barbeton daisy",
146
+ "39": "daffodil",
147
+ "40": "sword lily",
148
+ "41": "poinsettia",
149
+ "42": "bolero deep blue",
150
+ "43": "wallflower",
151
+ "44": "marigold",
152
+ "45": "buttercup",
153
+ "46": "oxeye daisy",
154
+ "47": "english marigold",
155
+ "48": "common dandelion",
156
+ "49": "petunia",
157
+ "50": "wild pansy",
158
+ "51": "primula",
159
+ "52": "sunflower",
160
+ "53": "pelargonium",
161
+ "54": "bishop of llandaff",
162
+ "55": "gaura",
163
+ "56": "geranium",
164
+ "57": "orange dahlia",
165
+ "58": "tiger lily",
166
+ "59": "pink-yellow dahlia",
167
+ "60": "cautleya spicata",
168
+ "61": "japanese anemone",
169
+ "62": "black-eyed susan",
170
+ "63": "silverbush",
171
+ "64": "californian poppy",
172
+ "65": "osteospermum",
173
+ "66": "spring crocus",
174
+ "67": "bearded iris",
175
+ "68": "windflower",
176
+ "69": "moon orchid",
177
+ "70": "tree poppy",
178
+ "71": "gazania",
179
+ "72": "azalea",
180
+ "73": "water lily",
181
+ "74": "rose",
182
+ "75": "thorn apple",
183
+ "76": "morning glory",
184
+ "77": "passion flower",
185
+ "78": "lotus lotus",
186
+ "79": "toad lily",
187
+ "80": "bird of paradise",
188
+ "81": "anthurium",
189
+ "82": "frangipani",
190
+ "83": "clematis",
191
+ "84": "hibiscus",
192
+ "85": "columbine",
193
+ "86": "desert-rose",
194
+ "87": "tree mallow",
195
+ "88": "magnolia",
196
+ "89": "cyclamen",
197
+ "90": "watercress",
198
+ "91": "monkshood",
199
+ "92": "canna lily",
200
+ "93": "hippeastrum",
201
+ "94": "bee balm",
202
+ "95": "ball moss",
203
+ "96": "foxglove",
204
+ "97": "bougainvillea",
205
+ "98": "camellia",
206
+ "99": "mallow",
207
+ "100": "mexican petunia",
208
+ "101": "bromelia"
209
+ }
210
+ }
labels.txt ADDED
@@ -0,0 +1,102 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ pink primrose
2
+ globe thistle
3
+ blanket flower
4
+ trumpet creeper
5
+ blackberry lily
6
+ snapdragon
7
+ colt's foot
8
+ king protea
9
+ spear thistle
10
+ yellow iris
11
+ globe-flower
12
+ purple coneflower
13
+ peruvian lily
14
+ balloon flower
15
+ hard-leaved pocket orchid
16
+ giant white arum lily
17
+ fire lily
18
+ pincushion flower
19
+ fritillary
20
+ red ginger
21
+ grape hyacinth
22
+ corn poppy
23
+ prince of wales feathers
24
+ stemless gentian
25
+ artichoke
26
+ canterbury bells
27
+ sweet william
28
+ carnation
29
+ garden phlox
30
+ love in the mist
31
+ mexican aster
32
+ alpine sea holly
33
+ ruby-lipped cattleya
34
+ cape flower
35
+ great masterwort
36
+ siam tulip
37
+ sweet pea
38
+ lenten rose
39
+ barbeton daisy
40
+ daffodil
41
+ sword lily
42
+ poinsettia
43
+ bolero deep blue
44
+ wallflower
45
+ marigold
46
+ buttercup
47
+ oxeye daisy
48
+ english marigold
49
+ common dandelion
50
+ petunia
51
+ wild pansy
52
+ primula
53
+ sunflower
54
+ pelargonium
55
+ bishop of llandaff
56
+ gaura
57
+ geranium
58
+ orange dahlia
59
+ tiger lily
60
+ pink-yellow dahlia
61
+ cautleya spicata
62
+ japanese anemone
63
+ black-eyed susan
64
+ silverbush
65
+ californian poppy
66
+ osteospermum
67
+ spring crocus
68
+ bearded iris
69
+ windflower
70
+ moon orchid
71
+ tree poppy
72
+ gazania
73
+ azalea
74
+ water lily
75
+ rose
76
+ thorn apple
77
+ morning glory
78
+ passion flower
79
+ lotus lotus
80
+ toad lily
81
+ bird of paradise
82
+ anthurium
83
+ frangipani
84
+ clematis
85
+ hibiscus
86
+ columbine
87
+ desert-rose
88
+ tree mallow
89
+ magnolia
90
+ cyclamen
91
+ watercress
92
+ monkshood
93
+ canna lily
94
+ hippeastrum
95
+ bee balm
96
+ ball moss
97
+ foxglove
98
+ bougainvillea
99
+ camellia
100
+ mallow
101
+ mexican petunia
102
+ bromelia
model_config.json ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architecture": "efficientnet_b0",
3
+ "num_classes": 102,
4
+ "input_size": 224,
5
+ "pretrained_backbone": "ImageNet weights used during training",
6
+ "framework": "PyTorch",
7
+ "torchvision": true,
8
+ "checkpoint_format": "custom checkpoint with model_state_dict"
9
+ }
requirements.txt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ torch
2
+ torchvision
3
+ Pillow
training_config.json ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "learning_rate": 0.001,
3
+ "hidden_units": 512,
4
+ "epochs": 3,
5
+ "batch_size": 32,
6
+ "optimizer": "AdamW",
7
+ "scheduler": {
8
+ "type": "StepLR",
9
+ "step_size": 5,
10
+ "gamma": 0.1
11
+ },
12
+ "loss": "CrossEntropyLoss",
13
+ "best_validation_accuracy_percent": 94.38,
14
+ "normalization": {
15
+ "mean": [
16
+ 0.485,
17
+ 0.456,
18
+ 0.406
19
+ ],
20
+ "std": [
21
+ 0.229,
22
+ 0.224,
23
+ 0.225
24
+ ]
25
+ },
26
+ "train_transforms": [
27
+ "RandomResizedCrop(224)",
28
+ "RandomHorizontalFlip",
29
+ "ColorJitter(brightness=0.2,contrast=0.2,saturation=0.2,hue=0.1)"
30
+ ],
31
+ "validation_transforms": [
32
+ "Resize(256)",
33
+ "CenterCrop(224)"
34
+ ]
35
+ }