End of training
Browse files- README.md +191 -0
- config.json +285 -0
- config.toml +27 -0
- model.safetensors +3 -0
- preprocessor_config.json +37 -0
- train.ipynb +470 -0
- training_args.bin +3 -0
README.md
ADDED
@@ -0,0 +1,191 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
license: apache-2.0
|
3 |
+
base_model: microsoft/resnet-50
|
4 |
+
tags:
|
5 |
+
- generated_from_trainer
|
6 |
+
datasets:
|
7 |
+
- stanford-dogs
|
8 |
+
metrics:
|
9 |
+
- accuracy
|
10 |
+
- f1
|
11 |
+
- precision
|
12 |
+
- recall
|
13 |
+
model-index:
|
14 |
+
- name: microsoft-resnet-50-batch32-lr0.005-standford-dogs
|
15 |
+
results:
|
16 |
+
- task:
|
17 |
+
name: Image Classification
|
18 |
+
type: image-classification
|
19 |
+
dataset:
|
20 |
+
name: stanford-dogs
|
21 |
+
type: stanford-dogs
|
22 |
+
config: default
|
23 |
+
split: full
|
24 |
+
args: default
|
25 |
+
metrics:
|
26 |
+
- name: Accuracy
|
27 |
+
type: accuracy
|
28 |
+
value: 0.82555879494655
|
29 |
+
- name: F1
|
30 |
+
type: f1
|
31 |
+
value: 0.8098053489000772
|
32 |
+
- name: Precision
|
33 |
+
type: precision
|
34 |
+
value: 0.8426096100022951
|
35 |
+
- name: Recall
|
36 |
+
type: recall
|
37 |
+
value: 0.817750070550628
|
38 |
+
---
|
39 |
+
|
40 |
+
<!-- This model card has been generated automatically according to the information the Trainer had access to. You
|
41 |
+
should probably proofread and complete it, then remove this comment. -->
|
42 |
+
|
43 |
+
# microsoft-resnet-50-batch32-lr0.005-standford-dogs
|
44 |
+
|
45 |
+
This model is a fine-tuned version of [microsoft/resnet-50](https://huggingface.co/microsoft/resnet-50) on the stanford-dogs dataset.
|
46 |
+
It achieves the following results on the evaluation set:
|
47 |
+
- Loss: 1.1192
|
48 |
+
- Accuracy: 0.8256
|
49 |
+
- F1: 0.8098
|
50 |
+
- Precision: 0.8426
|
51 |
+
- Recall: 0.8178
|
52 |
+
|
53 |
+
## Model description
|
54 |
+
|
55 |
+
More information needed
|
56 |
+
|
57 |
+
## Intended uses & limitations
|
58 |
+
|
59 |
+
More information needed
|
60 |
+
|
61 |
+
## Training and evaluation data
|
62 |
+
|
63 |
+
More information needed
|
64 |
+
|
65 |
+
## Training procedure
|
66 |
+
|
67 |
+
### Training hyperparameters
|
68 |
+
|
69 |
+
The following hyperparameters were used during training:
|
70 |
+
- learning_rate: 5e-05
|
71 |
+
- train_batch_size: 32
|
72 |
+
- eval_batch_size: 32
|
73 |
+
- seed: 42
|
74 |
+
- gradient_accumulation_steps: 4
|
75 |
+
- total_train_batch_size: 128
|
76 |
+
- optimizer: Adam with betas=(0.9,0.999) and epsilon=1e-08
|
77 |
+
- lr_scheduler_type: linear
|
78 |
+
- training_steps: 1000
|
79 |
+
|
80 |
+
### Training results
|
81 |
+
|
82 |
+
| Training Loss | Epoch | Step | Validation Loss | Accuracy | F1 | Precision | Recall |
|
83 |
+
|:-------------:|:------:|:----:|:---------------:|:--------:|:------:|:---------:|:------:|
|
84 |
+
| 4.7839 | 0.0777 | 10 | 4.7747 | 0.2556 | 0.2410 | 0.4479 | 0.2436 |
|
85 |
+
| 4.7731 | 0.1553 | 20 | 4.7576 | 0.3511 | 0.3282 | 0.6032 | 0.3338 |
|
86 |
+
| 4.7617 | 0.2330 | 30 | 4.7363 | 0.4184 | 0.3974 | 0.6668 | 0.3947 |
|
87 |
+
| 4.7445 | 0.3107 | 40 | 4.7115 | 0.5265 | 0.4927 | 0.7032 | 0.4993 |
|
88 |
+
| 4.7266 | 0.3883 | 50 | 4.6846 | 0.5561 | 0.5413 | 0.7422 | 0.5333 |
|
89 |
+
| 4.7081 | 0.4660 | 60 | 4.6547 | 0.6062 | 0.5767 | 0.7392 | 0.5828 |
|
90 |
+
| 4.6807 | 0.5437 | 70 | 4.6161 | 0.5909 | 0.5750 | 0.7740 | 0.5673 |
|
91 |
+
| 4.6572 | 0.6214 | 80 | 4.5761 | 0.6324 | 0.6162 | 0.8021 | 0.6102 |
|
92 |
+
| 4.6286 | 0.6990 | 90 | 4.5274 | 0.6297 | 0.6241 | 0.8188 | 0.6080 |
|
93 |
+
| 4.598 | 0.7767 | 100 | 4.4746 | 0.6569 | 0.6609 | 0.8380 | 0.6370 |
|
94 |
+
| 4.5578 | 0.8544 | 110 | 4.4193 | 0.6674 | 0.6713 | 0.8301 | 0.6486 |
|
95 |
+
| 4.521 | 0.9320 | 120 | 4.3553 | 0.6914 | 0.6868 | 0.8215 | 0.6729 |
|
96 |
+
| 4.4888 | 1.0097 | 130 | 4.2924 | 0.7082 | 0.7064 | 0.8415 | 0.6904 |
|
97 |
+
| 4.4312 | 1.0874 | 140 | 4.2125 | 0.7155 | 0.7076 | 0.8381 | 0.6980 |
|
98 |
+
| 4.3865 | 1.1650 | 150 | 4.1433 | 0.7145 | 0.7115 | 0.8315 | 0.6984 |
|
99 |
+
| 4.336 | 1.2427 | 160 | 4.0630 | 0.7082 | 0.7010 | 0.8353 | 0.6930 |
|
100 |
+
| 4.2903 | 1.3204 | 170 | 3.9781 | 0.7148 | 0.7024 | 0.8109 | 0.6982 |
|
101 |
+
| 4.2465 | 1.3981 | 180 | 3.8896 | 0.7376 | 0.7234 | 0.8328 | 0.7217 |
|
102 |
+
| 4.1924 | 1.4757 | 190 | 3.8117 | 0.7476 | 0.7310 | 0.8161 | 0.7322 |
|
103 |
+
| 4.1217 | 1.5534 | 200 | 3.7499 | 0.7510 | 0.7344 | 0.8105 | 0.7372 |
|
104 |
+
| 4.068 | 1.6311 | 210 | 3.6340 | 0.7551 | 0.7355 | 0.8183 | 0.7409 |
|
105 |
+
| 4.0148 | 1.7087 | 220 | 3.5678 | 0.7546 | 0.7358 | 0.8066 | 0.7413 |
|
106 |
+
| 3.9682 | 1.7864 | 230 | 3.4852 | 0.7663 | 0.7477 | 0.8145 | 0.7530 |
|
107 |
+
| 3.9196 | 1.8641 | 240 | 3.3841 | 0.7648 | 0.7464 | 0.8075 | 0.7520 |
|
108 |
+
| 3.8481 | 1.9417 | 250 | 3.3003 | 0.7626 | 0.7421 | 0.8056 | 0.7495 |
|
109 |
+
| 3.8017 | 2.0194 | 260 | 3.2395 | 0.7578 | 0.7370 | 0.8045 | 0.7461 |
|
110 |
+
| 3.7528 | 2.0971 | 270 | 3.1183 | 0.7578 | 0.7349 | 0.8007 | 0.7457 |
|
111 |
+
| 3.6614 | 2.1748 | 280 | 3.0364 | 0.7655 | 0.7435 | 0.8011 | 0.7531 |
|
112 |
+
| 3.6522 | 2.2524 | 290 | 2.9775 | 0.7629 | 0.7415 | 0.7990 | 0.7507 |
|
113 |
+
| 3.5922 | 2.3301 | 300 | 2.8995 | 0.7665 | 0.7466 | 0.8090 | 0.7551 |
|
114 |
+
| 3.519 | 2.4078 | 310 | 2.8049 | 0.7680 | 0.7488 | 0.8129 | 0.7566 |
|
115 |
+
| 3.4724 | 2.4854 | 320 | 2.7425 | 0.7704 | 0.7528 | 0.8170 | 0.7601 |
|
116 |
+
| 3.4333 | 2.5631 | 330 | 2.6444 | 0.7755 | 0.7560 | 0.8236 | 0.7648 |
|
117 |
+
| 3.4303 | 2.6408 | 340 | 2.5672 | 0.7687 | 0.7473 | 0.8178 | 0.7585 |
|
118 |
+
| 3.3287 | 2.7184 | 350 | 2.5194 | 0.7806 | 0.7599 | 0.8229 | 0.7712 |
|
119 |
+
| 3.2916 | 2.7961 | 360 | 2.4733 | 0.7796 | 0.7575 | 0.8223 | 0.7698 |
|
120 |
+
| 3.1999 | 2.8738 | 370 | 2.4098 | 0.7792 | 0.7565 | 0.8158 | 0.7692 |
|
121 |
+
| 3.211 | 2.9515 | 380 | 2.3081 | 0.7796 | 0.7571 | 0.8284 | 0.7692 |
|
122 |
+
| 3.1437 | 3.0291 | 390 | 2.2523 | 0.7830 | 0.7600 | 0.8212 | 0.7730 |
|
123 |
+
| 3.1036 | 3.1068 | 400 | 2.2000 | 0.7847 | 0.7619 | 0.8210 | 0.7740 |
|
124 |
+
| 3.0345 | 3.1845 | 410 | 2.1385 | 0.7833 | 0.7606 | 0.8261 | 0.7726 |
|
125 |
+
| 2.99 | 3.2621 | 420 | 2.1079 | 0.7799 | 0.7560 | 0.8199 | 0.7698 |
|
126 |
+
| 2.9386 | 3.3398 | 430 | 2.0585 | 0.7821 | 0.7584 | 0.8232 | 0.7716 |
|
127 |
+
| 2.9093 | 3.4175 | 440 | 2.0176 | 0.7823 | 0.7586 | 0.8225 | 0.7721 |
|
128 |
+
| 2.8868 | 3.4951 | 450 | 1.9702 | 0.7818 | 0.7585 | 0.8183 | 0.7720 |
|
129 |
+
| 2.8603 | 3.5728 | 460 | 1.8973 | 0.7864 | 0.7645 | 0.8241 | 0.7767 |
|
130 |
+
| 2.8232 | 3.6505 | 470 | 1.8814 | 0.7855 | 0.7616 | 0.8128 | 0.7758 |
|
131 |
+
| 2.7889 | 3.7282 | 480 | 1.8170 | 0.7886 | 0.7676 | 0.8214 | 0.7792 |
|
132 |
+
| 2.7561 | 3.8058 | 490 | 1.7750 | 0.7920 | 0.7721 | 0.8364 | 0.7828 |
|
133 |
+
| 2.7243 | 3.8835 | 500 | 1.7369 | 0.7906 | 0.7695 | 0.8295 | 0.7813 |
|
134 |
+
| 2.6619 | 3.9612 | 510 | 1.7225 | 0.7971 | 0.7766 | 0.8292 | 0.7884 |
|
135 |
+
| 2.7054 | 4.0388 | 520 | 1.6453 | 0.7983 | 0.7788 | 0.8346 | 0.7894 |
|
136 |
+
| 2.6069 | 4.1165 | 530 | 1.6340 | 0.8000 | 0.7807 | 0.8347 | 0.7910 |
|
137 |
+
| 2.5627 | 4.1942 | 540 | 1.6538 | 0.7971 | 0.7760 | 0.8337 | 0.7878 |
|
138 |
+
| 2.5555 | 4.2718 | 550 | 1.5779 | 0.7998 | 0.7785 | 0.8324 | 0.7906 |
|
139 |
+
| 2.5541 | 4.3495 | 560 | 1.5960 | 0.7945 | 0.7736 | 0.8329 | 0.7850 |
|
140 |
+
| 2.513 | 4.4272 | 570 | 1.5537 | 0.8025 | 0.7841 | 0.8368 | 0.7941 |
|
141 |
+
| 2.442 | 4.5049 | 580 | 1.5196 | 0.8034 | 0.7858 | 0.8380 | 0.7954 |
|
142 |
+
| 2.4763 | 4.5825 | 590 | 1.5009 | 0.8052 | 0.7870 | 0.8345 | 0.7965 |
|
143 |
+
| 2.4412 | 4.6602 | 600 | 1.4760 | 0.8098 | 0.7924 | 0.8391 | 0.8015 |
|
144 |
+
| 2.383 | 4.7379 | 610 | 1.4403 | 0.8088 | 0.7920 | 0.8395 | 0.8007 |
|
145 |
+
| 2.3731 | 4.8155 | 620 | 1.4123 | 0.8120 | 0.7956 | 0.8401 | 0.8039 |
|
146 |
+
| 2.3616 | 4.8932 | 630 | 1.4193 | 0.8105 | 0.7940 | 0.8369 | 0.8021 |
|
147 |
+
| 2.3311 | 4.9709 | 640 | 1.4220 | 0.8098 | 0.7934 | 0.8370 | 0.8016 |
|
148 |
+
| 2.3373 | 5.0485 | 650 | 1.3956 | 0.8081 | 0.7907 | 0.8367 | 0.7996 |
|
149 |
+
| 2.2879 | 5.1262 | 660 | 1.3375 | 0.8144 | 0.7976 | 0.8410 | 0.8062 |
|
150 |
+
| 2.299 | 5.2039 | 670 | 1.3431 | 0.8146 | 0.7967 | 0.8371 | 0.8061 |
|
151 |
+
| 2.2471 | 5.2816 | 680 | 1.3360 | 0.8151 | 0.7985 | 0.8389 | 0.8070 |
|
152 |
+
| 2.2419 | 5.3592 | 690 | 1.3139 | 0.8139 | 0.7977 | 0.8377 | 0.8058 |
|
153 |
+
| 2.2195 | 5.4369 | 700 | 1.3225 | 0.8151 | 0.7974 | 0.8395 | 0.8062 |
|
154 |
+
| 2.1901 | 5.5146 | 710 | 1.2797 | 0.8173 | 0.8001 | 0.8397 | 0.8087 |
|
155 |
+
| 2.1931 | 5.5922 | 720 | 1.2543 | 0.8192 | 0.8032 | 0.8423 | 0.8109 |
|
156 |
+
| 2.195 | 5.6699 | 730 | 1.2767 | 0.8209 | 0.8039 | 0.8405 | 0.8125 |
|
157 |
+
| 2.1413 | 5.7476 | 740 | 1.2735 | 0.8212 | 0.8053 | 0.8416 | 0.8132 |
|
158 |
+
| 2.1696 | 5.8252 | 750 | 1.2694 | 0.8149 | 0.7983 | 0.8358 | 0.8069 |
|
159 |
+
| 2.1387 | 5.9029 | 760 | 1.2532 | 0.8217 | 0.8062 | 0.8422 | 0.8136 |
|
160 |
+
| 2.1811 | 5.9806 | 770 | 1.2426 | 0.8197 | 0.8034 | 0.8417 | 0.8116 |
|
161 |
+
| 2.077 | 6.0583 | 780 | 1.2101 | 0.8243 | 0.8078 | 0.8464 | 0.8159 |
|
162 |
+
| 2.1099 | 6.1359 | 790 | 1.1947 | 0.8265 | 0.8108 | 0.8455 | 0.8186 |
|
163 |
+
| 2.0825 | 6.2136 | 800 | 1.1826 | 0.8241 | 0.8080 | 0.8455 | 0.8161 |
|
164 |
+
| 2.0933 | 6.2913 | 810 | 1.1934 | 0.8282 | 0.8128 | 0.8474 | 0.8207 |
|
165 |
+
| 2.0857 | 6.3689 | 820 | 1.1897 | 0.8258 | 0.8099 | 0.8465 | 0.8181 |
|
166 |
+
| 2.0881 | 6.4466 | 830 | 1.1666 | 0.8277 | 0.8124 | 0.8477 | 0.8199 |
|
167 |
+
| 2.074 | 6.5243 | 840 | 1.1815 | 0.8248 | 0.8081 | 0.8433 | 0.8167 |
|
168 |
+
| 2.0145 | 6.6019 | 850 | 1.1680 | 0.8292 | 0.8130 | 0.8473 | 0.8209 |
|
169 |
+
| 2.0778 | 6.6796 | 860 | 1.1565 | 0.8260 | 0.8094 | 0.8348 | 0.8178 |
|
170 |
+
| 1.9784 | 6.7573 | 870 | 1.1571 | 0.8345 | 0.8201 | 0.8529 | 0.8269 |
|
171 |
+
| 2.0595 | 6.8350 | 880 | 1.1554 | 0.8309 | 0.8165 | 0.8475 | 0.8234 |
|
172 |
+
| 2.0252 | 6.9126 | 890 | 1.1444 | 0.8282 | 0.8140 | 0.8476 | 0.8209 |
|
173 |
+
| 1.9708 | 6.9903 | 900 | 1.1478 | 0.8302 | 0.8158 | 0.8472 | 0.8224 |
|
174 |
+
| 2.0656 | 7.0680 | 910 | 1.1285 | 0.8324 | 0.8169 | 0.8485 | 0.8245 |
|
175 |
+
| 2.0086 | 7.1456 | 920 | 1.1289 | 0.8290 | 0.8148 | 0.8444 | 0.8219 |
|
176 |
+
| 2.0056 | 7.2233 | 930 | 1.1268 | 0.8280 | 0.8130 | 0.8470 | 0.8208 |
|
177 |
+
| 1.9498 | 7.3010 | 940 | 1.1246 | 0.8311 | 0.8158 | 0.8497 | 0.8234 |
|
178 |
+
| 2.0067 | 7.3786 | 950 | 1.1495 | 0.8285 | 0.8132 | 0.8440 | 0.8207 |
|
179 |
+
| 2.0171 | 7.4563 | 960 | 1.1168 | 0.8285 | 0.8138 | 0.8501 | 0.8209 |
|
180 |
+
| 1.9683 | 7.5340 | 970 | 1.1290 | 0.8314 | 0.8165 | 0.8500 | 0.8235 |
|
181 |
+
| 1.9771 | 7.6117 | 980 | 1.0982 | 0.8314 | 0.8153 | 0.8454 | 0.8233 |
|
182 |
+
| 2.0086 | 7.6893 | 990 | 1.1275 | 0.8294 | 0.8151 | 0.8491 | 0.8218 |
|
183 |
+
| 1.9854 | 7.7670 | 1000 | 1.1192 | 0.8256 | 0.8098 | 0.8426 | 0.8178 |
|
184 |
+
|
185 |
+
|
186 |
+
### Framework versions
|
187 |
+
|
188 |
+
- Transformers 4.40.2
|
189 |
+
- Pytorch 2.3.0
|
190 |
+
- Datasets 2.19.1
|
191 |
+
- Tokenizers 0.19.1
|
config.json
ADDED
@@ -0,0 +1,285 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"_name_or_path": "microsoft/resnet-50",
|
3 |
+
"architectures": [
|
4 |
+
"ResNetForImageClassification"
|
5 |
+
],
|
6 |
+
"depths": [
|
7 |
+
3,
|
8 |
+
4,
|
9 |
+
6,
|
10 |
+
3
|
11 |
+
],
|
12 |
+
"downsample_in_bottleneck": false,
|
13 |
+
"downsample_in_first_stage": false,
|
14 |
+
"embedding_size": 64,
|
15 |
+
"hidden_act": "relu",
|
16 |
+
"hidden_sizes": [
|
17 |
+
256,
|
18 |
+
512,
|
19 |
+
1024,
|
20 |
+
2048
|
21 |
+
],
|
22 |
+
"id2label": {
|
23 |
+
"0": "Affenpinscher",
|
24 |
+
"1": "Afghan Hound",
|
25 |
+
"2": "African Hunting Dog",
|
26 |
+
"3": "Airedale",
|
27 |
+
"4": "American Staffordshire Terrier",
|
28 |
+
"5": "Appenzeller",
|
29 |
+
"6": "Australian Terrier",
|
30 |
+
"7": "Basenji",
|
31 |
+
"8": "Basset",
|
32 |
+
"9": "Beagle",
|
33 |
+
"10": "Bedlington Terrier",
|
34 |
+
"11": "Bernese Mountain Dog",
|
35 |
+
"12": "Black And Tan Coonhound",
|
36 |
+
"13": "Blenheim Spaniel",
|
37 |
+
"14": "Bloodhound",
|
38 |
+
"15": "Bluetick",
|
39 |
+
"16": "Border Collie",
|
40 |
+
"17": "Border Terrier",
|
41 |
+
"18": "Borzoi",
|
42 |
+
"19": "Boston Bull",
|
43 |
+
"20": "Bouvier Des Flandres",
|
44 |
+
"21": "Boxer",
|
45 |
+
"22": "Brabancon Griffon",
|
46 |
+
"23": "Briard",
|
47 |
+
"24": "Brittany Spaniel",
|
48 |
+
"25": "Bull Mastiff",
|
49 |
+
"26": "Cairn",
|
50 |
+
"27": "Cardigan",
|
51 |
+
"28": "Chesapeake Bay Retriever",
|
52 |
+
"29": "Chihuahua",
|
53 |
+
"30": "Chow",
|
54 |
+
"31": "Clumber",
|
55 |
+
"32": "Cocker Spaniel",
|
56 |
+
"33": "Collie",
|
57 |
+
"34": "Curly Coated Retriever",
|
58 |
+
"35": "Dandie Dinmont",
|
59 |
+
"36": "Dhole",
|
60 |
+
"37": "Dingo",
|
61 |
+
"38": "Doberman",
|
62 |
+
"39": "English Foxhound",
|
63 |
+
"40": "English Setter",
|
64 |
+
"41": "English Springer",
|
65 |
+
"42": "Entlebucher",
|
66 |
+
"43": "Eskimo Dog",
|
67 |
+
"44": "Flat Coated Retriever",
|
68 |
+
"45": "French Bulldog",
|
69 |
+
"46": "German Shepherd",
|
70 |
+
"47": "German Short Haired Pointer",
|
71 |
+
"48": "Giant Schnauzer",
|
72 |
+
"49": "Golden Retriever",
|
73 |
+
"50": "Gordon Setter",
|
74 |
+
"51": "Great Dane",
|
75 |
+
"52": "Great Pyrenees",
|
76 |
+
"53": "Greater Swiss Mountain Dog",
|
77 |
+
"54": "Groenendael",
|
78 |
+
"55": "Ibizan Hound",
|
79 |
+
"56": "Irish Setter",
|
80 |
+
"57": "Irish Terrier",
|
81 |
+
"58": "Irish Water Spaniel",
|
82 |
+
"59": "Irish Wolfhound",
|
83 |
+
"60": "Italian Greyhound",
|
84 |
+
"61": "Japanese Spaniel",
|
85 |
+
"62": "Keeshond",
|
86 |
+
"63": "Kelpie",
|
87 |
+
"64": "Kerry Blue Terrier",
|
88 |
+
"65": "Komondor",
|
89 |
+
"66": "Kuvasz",
|
90 |
+
"67": "Labrador Retriever",
|
91 |
+
"68": "Lakeland Terrier",
|
92 |
+
"69": "Leonberg",
|
93 |
+
"70": "Lhasa",
|
94 |
+
"71": "Malamute",
|
95 |
+
"72": "Malinois",
|
96 |
+
"73": "Maltese Dog",
|
97 |
+
"74": "Mexican Hairless",
|
98 |
+
"75": "Miniature Pinscher",
|
99 |
+
"76": "Miniature Poodle",
|
100 |
+
"77": "Miniature Schnauzer",
|
101 |
+
"78": "Newfoundland",
|
102 |
+
"79": "Norfolk Terrier",
|
103 |
+
"80": "Norwegian Elkhound",
|
104 |
+
"81": "Norwich Terrier",
|
105 |
+
"82": "Old English Sheepdog",
|
106 |
+
"83": "Otterhound",
|
107 |
+
"84": "Papillon",
|
108 |
+
"85": "Pekinese",
|
109 |
+
"86": "Pembroke",
|
110 |
+
"87": "Pomeranian",
|
111 |
+
"88": "Pug",
|
112 |
+
"89": "Redbone",
|
113 |
+
"90": "Rhodesian Ridgeback",
|
114 |
+
"91": "Rottweiler",
|
115 |
+
"92": "Saint Bernard",
|
116 |
+
"93": "Saluki",
|
117 |
+
"94": "Samoyed",
|
118 |
+
"95": "Schipperke",
|
119 |
+
"96": "Scotch Terrier",
|
120 |
+
"97": "Scottish Deerhound",
|
121 |
+
"98": "Sealyham Terrier",
|
122 |
+
"99": "Shetland Sheepdog",
|
123 |
+
"100": "Shih Tzu",
|
124 |
+
"101": "Siberian Husky",
|
125 |
+
"102": "Silky Terrier",
|
126 |
+
"103": "Soft Coated Wheaten Terrier",
|
127 |
+
"104": "Staffordshire Bullterrier",
|
128 |
+
"105": "Standard Poodle",
|
129 |
+
"106": "Standard Schnauzer",
|
130 |
+
"107": "Sussex Spaniel",
|
131 |
+
"108": "Tibetan Mastiff",
|
132 |
+
"109": "Tibetan Terrier",
|
133 |
+
"110": "Toy Poodle",
|
134 |
+
"111": "Toy Terrier",
|
135 |
+
"112": "Vizsla",
|
136 |
+
"113": "Walker Hound",
|
137 |
+
"114": "Weimaraner",
|
138 |
+
"115": "Welsh Springer Spaniel",
|
139 |
+
"116": "West Highland White Terrier",
|
140 |
+
"117": "Whippet",
|
141 |
+
"118": "Wire Haired Fox Terrier",
|
142 |
+
"119": "Yorkshire Terrier"
|
143 |
+
},
|
144 |
+
"label2id": {
|
145 |
+
"Affenpinscher": 0,
|
146 |
+
"Afghan Hound": 1,
|
147 |
+
"African Hunting Dog": 2,
|
148 |
+
"Airedale": 3,
|
149 |
+
"American Staffordshire Terrier": 4,
|
150 |
+
"Appenzeller": 5,
|
151 |
+
"Australian Terrier": 6,
|
152 |
+
"Basenji": 7,
|
153 |
+
"Basset": 8,
|
154 |
+
"Beagle": 9,
|
155 |
+
"Bedlington Terrier": 10,
|
156 |
+
"Bernese Mountain Dog": 11,
|
157 |
+
"Black And Tan Coonhound": 12,
|
158 |
+
"Blenheim Spaniel": 13,
|
159 |
+
"Bloodhound": 14,
|
160 |
+
"Bluetick": 15,
|
161 |
+
"Border Collie": 16,
|
162 |
+
"Border Terrier": 17,
|
163 |
+
"Borzoi": 18,
|
164 |
+
"Boston Bull": 19,
|
165 |
+
"Bouvier Des Flandres": 20,
|
166 |
+
"Boxer": 21,
|
167 |
+
"Brabancon Griffon": 22,
|
168 |
+
"Briard": 23,
|
169 |
+
"Brittany Spaniel": 24,
|
170 |
+
"Bull Mastiff": 25,
|
171 |
+
"Cairn": 26,
|
172 |
+
"Cardigan": 27,
|
173 |
+
"Chesapeake Bay Retriever": 28,
|
174 |
+
"Chihuahua": 29,
|
175 |
+
"Chow": 30,
|
176 |
+
"Clumber": 31,
|
177 |
+
"Cocker Spaniel": 32,
|
178 |
+
"Collie": 33,
|
179 |
+
"Curly Coated Retriever": 34,
|
180 |
+
"Dandie Dinmont": 35,
|
181 |
+
"Dhole": 36,
|
182 |
+
"Dingo": 37,
|
183 |
+
"Doberman": 38,
|
184 |
+
"English Foxhound": 39,
|
185 |
+
"English Setter": 40,
|
186 |
+
"English Springer": 41,
|
187 |
+
"Entlebucher": 42,
|
188 |
+
"Eskimo Dog": 43,
|
189 |
+
"Flat Coated Retriever": 44,
|
190 |
+
"French Bulldog": 45,
|
191 |
+
"German Shepherd": 46,
|
192 |
+
"German Short Haired Pointer": 47,
|
193 |
+
"Giant Schnauzer": 48,
|
194 |
+
"Golden Retriever": 49,
|
195 |
+
"Gordon Setter": 50,
|
196 |
+
"Great Dane": 51,
|
197 |
+
"Great Pyrenees": 52,
|
198 |
+
"Greater Swiss Mountain Dog": 53,
|
199 |
+
"Groenendael": 54,
|
200 |
+
"Ibizan Hound": 55,
|
201 |
+
"Irish Setter": 56,
|
202 |
+
"Irish Terrier": 57,
|
203 |
+
"Irish Water Spaniel": 58,
|
204 |
+
"Irish Wolfhound": 59,
|
205 |
+
"Italian Greyhound": 60,
|
206 |
+
"Japanese Spaniel": 61,
|
207 |
+
"Keeshond": 62,
|
208 |
+
"Kelpie": 63,
|
209 |
+
"Kerry Blue Terrier": 64,
|
210 |
+
"Komondor": 65,
|
211 |
+
"Kuvasz": 66,
|
212 |
+
"Labrador Retriever": 67,
|
213 |
+
"Lakeland Terrier": 68,
|
214 |
+
"Leonberg": 69,
|
215 |
+
"Lhasa": 70,
|
216 |
+
"Malamute": 71,
|
217 |
+
"Malinois": 72,
|
218 |
+
"Maltese Dog": 73,
|
219 |
+
"Mexican Hairless": 74,
|
220 |
+
"Miniature Pinscher": 75,
|
221 |
+
"Miniature Poodle": 76,
|
222 |
+
"Miniature Schnauzer": 77,
|
223 |
+
"Newfoundland": 78,
|
224 |
+
"Norfolk Terrier": 79,
|
225 |
+
"Norwegian Elkhound": 80,
|
226 |
+
"Norwich Terrier": 81,
|
227 |
+
"Old English Sheepdog": 82,
|
228 |
+
"Otterhound": 83,
|
229 |
+
"Papillon": 84,
|
230 |
+
"Pekinese": 85,
|
231 |
+
"Pembroke": 86,
|
232 |
+
"Pomeranian": 87,
|
233 |
+
"Pug": 88,
|
234 |
+
"Redbone": 89,
|
235 |
+
"Rhodesian Ridgeback": 90,
|
236 |
+
"Rottweiler": 91,
|
237 |
+
"Saint Bernard": 92,
|
238 |
+
"Saluki": 93,
|
239 |
+
"Samoyed": 94,
|
240 |
+
"Schipperke": 95,
|
241 |
+
"Scotch Terrier": 96,
|
242 |
+
"Scottish Deerhound": 97,
|
243 |
+
"Sealyham Terrier": 98,
|
244 |
+
"Shetland Sheepdog": 99,
|
245 |
+
"Shih Tzu": 100,
|
246 |
+
"Siberian Husky": 101,
|
247 |
+
"Silky Terrier": 102,
|
248 |
+
"Soft Coated Wheaten Terrier": 103,
|
249 |
+
"Staffordshire Bullterrier": 104,
|
250 |
+
"Standard Poodle": 105,
|
251 |
+
"Standard Schnauzer": 106,
|
252 |
+
"Sussex Spaniel": 107,
|
253 |
+
"Tibetan Mastiff": 108,
|
254 |
+
"Tibetan Terrier": 109,
|
255 |
+
"Toy Poodle": 110,
|
256 |
+
"Toy Terrier": 111,
|
257 |
+
"Vizsla": 112,
|
258 |
+
"Walker Hound": 113,
|
259 |
+
"Weimaraner": 114,
|
260 |
+
"Welsh Springer Spaniel": 115,
|
261 |
+
"West Highland White Terrier": 116,
|
262 |
+
"Whippet": 117,
|
263 |
+
"Wire Haired Fox Terrier": 118,
|
264 |
+
"Yorkshire Terrier": 119
|
265 |
+
},
|
266 |
+
"layer_type": "bottleneck",
|
267 |
+
"model_type": "resnet",
|
268 |
+
"num_channels": 3,
|
269 |
+
"out_features": [
|
270 |
+
"stage4"
|
271 |
+
],
|
272 |
+
"out_indices": [
|
273 |
+
4
|
274 |
+
],
|
275 |
+
"problem_type": "single_label_classification",
|
276 |
+
"stage_names": [
|
277 |
+
"stem",
|
278 |
+
"stage1",
|
279 |
+
"stage2",
|
280 |
+
"stage3",
|
281 |
+
"stage4"
|
282 |
+
],
|
283 |
+
"torch_dtype": "float32",
|
284 |
+
"transformers_version": "4.40.2"
|
285 |
+
}
|
config.toml
ADDED
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
[training_args]
|
2 |
+
output_dir="/Users/andrewmayes/Openclassroom/CanineNet/code/"
|
3 |
+
evaluation_strategy="steps"
|
4 |
+
save_strategy="steps"
|
5 |
+
learning_rate=5e-5
|
6 |
+
#per_device_train_batch_size=32 # 512
|
7 |
+
#per_device_eval_batch_size=32 # 512
|
8 |
+
# num_train_epochs=5,
|
9 |
+
eval_delay=0 # 50
|
10 |
+
eval_steps=0.01
|
11 |
+
#eval_accumulation_steps
|
12 |
+
gradient_accumulation_steps=4
|
13 |
+
gradient_checkpointing=false#true
|
14 |
+
optim="adafactor"
|
15 |
+
max_steps=1000 # 100
|
16 |
+
#logging_dir=""
|
17 |
+
#log_level="error"
|
18 |
+
load_best_model_at_end=true
|
19 |
+
metric_for_best_model="f1"
|
20 |
+
greater_is_better=true
|
21 |
+
#use_mps_device=true
|
22 |
+
logging_steps=0.01
|
23 |
+
save_steps=0.01
|
24 |
+
#auto_find_batch_size=true
|
25 |
+
report_to="mlflow"
|
26 |
+
save_total_limit=2
|
27 |
+
#hub_model_id="amaye15/SwinV2-Base-Document-Classifier"
|
model.safetensors
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:05a149ec7944715556aec826546223b954ad2fb4f192f2a211384b753f192142
|
3 |
+
size 95270232
|
preprocessor_config.json
ADDED
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"_valid_processor_keys": [
|
3 |
+
"images",
|
4 |
+
"do_resize",
|
5 |
+
"size",
|
6 |
+
"crop_pct",
|
7 |
+
"resample",
|
8 |
+
"do_rescale",
|
9 |
+
"rescale_factor",
|
10 |
+
"do_normalize",
|
11 |
+
"image_mean",
|
12 |
+
"image_std",
|
13 |
+
"return_tensors",
|
14 |
+
"data_format",
|
15 |
+
"input_data_format"
|
16 |
+
],
|
17 |
+
"crop_pct": 0.875,
|
18 |
+
"do_normalize": true,
|
19 |
+
"do_rescale": true,
|
20 |
+
"do_resize": true,
|
21 |
+
"image_mean": [
|
22 |
+
0.485,
|
23 |
+
0.456,
|
24 |
+
0.406
|
25 |
+
],
|
26 |
+
"image_processor_type": "ConvNextImageProcessor",
|
27 |
+
"image_std": [
|
28 |
+
0.229,
|
29 |
+
0.224,
|
30 |
+
0.225
|
31 |
+
],
|
32 |
+
"resample": 3,
|
33 |
+
"rescale_factor": 0.00392156862745098,
|
34 |
+
"size": {
|
35 |
+
"shortest_edge": 224
|
36 |
+
}
|
37 |
+
}
|
train.ipynb
ADDED
@@ -0,0 +1,470 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"cells": [
|
3 |
+
{
|
4 |
+
"cell_type": "markdown",
|
5 |
+
"metadata": {},
|
6 |
+
"source": [
|
7 |
+
"# Install"
|
8 |
+
]
|
9 |
+
},
|
10 |
+
{
|
11 |
+
"cell_type": "code",
|
12 |
+
"execution_count": 1,
|
13 |
+
"metadata": {},
|
14 |
+
"outputs": [
|
15 |
+
{
|
16 |
+
"name": "stdout",
|
17 |
+
"output_type": "stream",
|
18 |
+
"text": [
|
19 |
+
"Requirement already satisfied: uv in /Users/andrewmayes/Openclassroom/CanineNet/env/lib/python3.12/site-packages (0.1.42)\n",
|
20 |
+
"Note: you may need to restart the kernel to use updated packages.\n"
|
21 |
+
]
|
22 |
+
}
|
23 |
+
],
|
24 |
+
"source": [
|
25 |
+
"%pip install uv"
|
26 |
+
]
|
27 |
+
},
|
28 |
+
{
|
29 |
+
"cell_type": "code",
|
30 |
+
"execution_count": 2,
|
31 |
+
"metadata": {},
|
32 |
+
"outputs": [
|
33 |
+
{
|
34 |
+
"name": "stdout",
|
35 |
+
"output_type": "stream",
|
36 |
+
"text": [
|
37 |
+
"\u001b[2mAudited \u001b[1m12 packages\u001b[0m in 15ms\u001b[0m\n"
|
38 |
+
]
|
39 |
+
}
|
40 |
+
],
|
41 |
+
"source": [
|
42 |
+
"!uv pip install dagshub setuptools accelerate toml torch torchvision transformers mlflow datasets ipywidgets python-dotenv evaluate"
|
43 |
+
]
|
44 |
+
},
|
45 |
+
{
|
46 |
+
"cell_type": "markdown",
|
47 |
+
"metadata": {},
|
48 |
+
"source": [
|
49 |
+
"# Setup"
|
50 |
+
]
|
51 |
+
},
|
52 |
+
{
|
53 |
+
"cell_type": "code",
|
54 |
+
"execution_count": 3,
|
55 |
+
"metadata": {},
|
56 |
+
"outputs": [
|
57 |
+
{
|
58 |
+
"data": {
|
59 |
+
"text/html": [
|
60 |
+
"<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">Initialized MLflow to track repo <span style=\"color: #008000; text-decoration-color: #008000\">\"amaye15/CanineNet\"</span>\n",
|
61 |
+
"</pre>\n"
|
62 |
+
],
|
63 |
+
"text/plain": [
|
64 |
+
"Initialized MLflow to track repo \u001b[32m\"amaye15/CanineNet\"\u001b[0m\n"
|
65 |
+
]
|
66 |
+
},
|
67 |
+
"metadata": {},
|
68 |
+
"output_type": "display_data"
|
69 |
+
},
|
70 |
+
{
|
71 |
+
"data": {
|
72 |
+
"text/html": [
|
73 |
+
"<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">Repository amaye15/CanineNet initialized!\n",
|
74 |
+
"</pre>\n"
|
75 |
+
],
|
76 |
+
"text/plain": [
|
77 |
+
"Repository amaye15/CanineNet initialized!\n"
|
78 |
+
]
|
79 |
+
},
|
80 |
+
"metadata": {},
|
81 |
+
"output_type": "display_data"
|
82 |
+
}
|
83 |
+
],
|
84 |
+
"source": [
|
85 |
+
"import os\n",
|
86 |
+
"import toml\n",
|
87 |
+
"import torch\n",
|
88 |
+
"import mlflow\n",
|
89 |
+
"import dagshub\n",
|
90 |
+
"import datasets\n",
|
91 |
+
"import evaluate\n",
|
92 |
+
"from dotenv import load_dotenv\n",
|
93 |
+
"from torchvision.transforms import v2\n",
|
94 |
+
"from transformers import AutoImageProcessor, AutoModelForImageClassification, TrainingArguments, Trainer\n",
|
95 |
+
"\n",
|
96 |
+
"ENV_PATH = \"/Users/andrewmayes/Openclassroom/CanineNet/.env\"\n",
|
97 |
+
"CONFIG_PATH = \"/Users/andrewmayes/Openclassroom/CanineNet/code/config.toml\"\n",
|
98 |
+
"CONFIG = toml.load(CONFIG_PATH)\n",
|
99 |
+
"\n",
|
100 |
+
"load_dotenv(ENV_PATH)\n",
|
101 |
+
"\n",
|
102 |
+
"dagshub.init(repo_name=os.environ['MLFLOW_TRACKING_PROJECTNAME'], repo_owner=os.environ['MLFLOW_TRACKING_USERNAME'], mlflow=True, dvc=True)\n",
|
103 |
+
"\n",
|
104 |
+
"os.environ['MLFLOW_TRACKING_USERNAME'] = \"amaye15\"\n",
|
105 |
+
"\n",
|
106 |
+
"mlflow.set_tracking_uri(f'https://dagshub.com/' + os.environ['MLFLOW_TRACKING_USERNAME']\n",
|
107 |
+
" + '/' + os.environ['MLFLOW_TRACKING_PROJECTNAME'] + '.mlflow')\n",
|
108 |
+
"\n",
|
109 |
+
"CREATE_DATASET = True\n",
|
110 |
+
"ORIGINAL_DATASET = \"Alanox/stanford-dogs\"\n",
|
111 |
+
"MODIFIED_DATASET = \"amaye15/stanford-dogs\"\n",
|
112 |
+
"REMOVE_COLUMNS = [\"name\", \"annotations\"]\n",
|
113 |
+
"RENAME_COLUMNS = {\"image\":\"pixel_values\", \"target\":\"label\"}\n",
|
114 |
+
"SPLIT = 0.2\n",
|
115 |
+
"\n",
|
116 |
+
"METRICS = [\"accuracy\", \"f1\", \"precision\", \"recall\"]\n",
|
117 |
+
"# MODELS = 'google/vit-base-patch16-224'\n",
|
118 |
+
"# MODELS = \"google/siglip-base-patch16-224\"\n",
|
119 |
+
"\n"
|
120 |
+
]
|
121 |
+
},
|
122 |
+
{
|
123 |
+
"cell_type": "markdown",
|
124 |
+
"metadata": {},
|
125 |
+
"source": [
|
126 |
+
"# Dataset"
|
127 |
+
]
|
128 |
+
},
|
129 |
+
{
|
130 |
+
"cell_type": "code",
|
131 |
+
"execution_count": 4,
|
132 |
+
"metadata": {},
|
133 |
+
"outputs": [
|
134 |
+
{
|
135 |
+
"name": "stdout",
|
136 |
+
"output_type": "stream",
|
137 |
+
"text": [
|
138 |
+
"Affenpinscher: 0\n",
|
139 |
+
"Afghan Hound: 1\n",
|
140 |
+
"African Hunting Dog: 2\n",
|
141 |
+
"Airedale: 3\n",
|
142 |
+
"American Staffordshire Terrier: 4\n",
|
143 |
+
"Appenzeller: 5\n",
|
144 |
+
"Australian Terrier: 6\n",
|
145 |
+
"Basenji: 7\n",
|
146 |
+
"Basset: 8\n",
|
147 |
+
"Beagle: 9\n",
|
148 |
+
"Bedlington Terrier: 10\n",
|
149 |
+
"Bernese Mountain Dog: 11\n",
|
150 |
+
"Black And Tan Coonhound: 12\n",
|
151 |
+
"Blenheim Spaniel: 13\n",
|
152 |
+
"Bloodhound: 14\n",
|
153 |
+
"Bluetick: 15\n",
|
154 |
+
"Border Collie: 16\n",
|
155 |
+
"Border Terrier: 17\n",
|
156 |
+
"Borzoi: 18\n",
|
157 |
+
"Boston Bull: 19\n",
|
158 |
+
"Bouvier Des Flandres: 20\n",
|
159 |
+
"Boxer: 21\n",
|
160 |
+
"Brabancon Griffon: 22\n",
|
161 |
+
"Briard: 23\n",
|
162 |
+
"Brittany Spaniel: 24\n",
|
163 |
+
"Bull Mastiff: 25\n",
|
164 |
+
"Cairn: 26\n",
|
165 |
+
"Cardigan: 27\n",
|
166 |
+
"Chesapeake Bay Retriever: 28\n",
|
167 |
+
"Chihuahua: 29\n",
|
168 |
+
"Chow: 30\n",
|
169 |
+
"Clumber: 31\n",
|
170 |
+
"Cocker Spaniel: 32\n",
|
171 |
+
"Collie: 33\n",
|
172 |
+
"Curly Coated Retriever: 34\n",
|
173 |
+
"Dandie Dinmont: 35\n",
|
174 |
+
"Dhole: 36\n",
|
175 |
+
"Dingo: 37\n",
|
176 |
+
"Doberman: 38\n",
|
177 |
+
"English Foxhound: 39\n",
|
178 |
+
"English Setter: 40\n",
|
179 |
+
"English Springer: 41\n",
|
180 |
+
"Entlebucher: 42\n",
|
181 |
+
"Eskimo Dog: 43\n",
|
182 |
+
"Flat Coated Retriever: 44\n",
|
183 |
+
"French Bulldog: 45\n",
|
184 |
+
"German Shepherd: 46\n",
|
185 |
+
"German Short Haired Pointer: 47\n",
|
186 |
+
"Giant Schnauzer: 48\n",
|
187 |
+
"Golden Retriever: 49\n",
|
188 |
+
"Gordon Setter: 50\n",
|
189 |
+
"Great Dane: 51\n",
|
190 |
+
"Great Pyrenees: 52\n",
|
191 |
+
"Greater Swiss Mountain Dog: 53\n",
|
192 |
+
"Groenendael: 54\n",
|
193 |
+
"Ibizan Hound: 55\n",
|
194 |
+
"Irish Setter: 56\n",
|
195 |
+
"Irish Terrier: 57\n",
|
196 |
+
"Irish Water Spaniel: 58\n",
|
197 |
+
"Irish Wolfhound: 59\n",
|
198 |
+
"Italian Greyhound: 60\n",
|
199 |
+
"Japanese Spaniel: 61\n",
|
200 |
+
"Keeshond: 62\n",
|
201 |
+
"Kelpie: 63\n",
|
202 |
+
"Kerry Blue Terrier: 64\n",
|
203 |
+
"Komondor: 65\n",
|
204 |
+
"Kuvasz: 66\n",
|
205 |
+
"Labrador Retriever: 67\n",
|
206 |
+
"Lakeland Terrier: 68\n",
|
207 |
+
"Leonberg: 69\n",
|
208 |
+
"Lhasa: 70\n",
|
209 |
+
"Malamute: 71\n",
|
210 |
+
"Malinois: 72\n",
|
211 |
+
"Maltese Dog: 73\n",
|
212 |
+
"Mexican Hairless: 74\n",
|
213 |
+
"Miniature Pinscher: 75\n",
|
214 |
+
"Miniature Poodle: 76\n",
|
215 |
+
"Miniature Schnauzer: 77\n",
|
216 |
+
"Newfoundland: 78\n",
|
217 |
+
"Norfolk Terrier: 79\n",
|
218 |
+
"Norwegian Elkhound: 80\n",
|
219 |
+
"Norwich Terrier: 81\n",
|
220 |
+
"Old English Sheepdog: 82\n",
|
221 |
+
"Otterhound: 83\n",
|
222 |
+
"Papillon: 84\n",
|
223 |
+
"Pekinese: 85\n",
|
224 |
+
"Pembroke: 86\n",
|
225 |
+
"Pomeranian: 87\n",
|
226 |
+
"Pug: 88\n",
|
227 |
+
"Redbone: 89\n",
|
228 |
+
"Rhodesian Ridgeback: 90\n",
|
229 |
+
"Rottweiler: 91\n",
|
230 |
+
"Saint Bernard: 92\n",
|
231 |
+
"Saluki: 93\n",
|
232 |
+
"Samoyed: 94\n",
|
233 |
+
"Schipperke: 95\n",
|
234 |
+
"Scotch Terrier: 96\n",
|
235 |
+
"Scottish Deerhound: 97\n",
|
236 |
+
"Sealyham Terrier: 98\n",
|
237 |
+
"Shetland Sheepdog: 99\n",
|
238 |
+
"Shih Tzu: 100\n",
|
239 |
+
"Siberian Husky: 101\n",
|
240 |
+
"Silky Terrier: 102\n",
|
241 |
+
"Soft Coated Wheaten Terrier: 103\n",
|
242 |
+
"Staffordshire Bullterrier: 104\n",
|
243 |
+
"Standard Poodle: 105\n",
|
244 |
+
"Standard Schnauzer: 106\n",
|
245 |
+
"Sussex Spaniel: 107\n",
|
246 |
+
"Tibetan Mastiff: 108\n",
|
247 |
+
"Tibetan Terrier: 109\n",
|
248 |
+
"Toy Poodle: 110\n",
|
249 |
+
"Toy Terrier: 111\n",
|
250 |
+
"Vizsla: 112\n",
|
251 |
+
"Walker Hound: 113\n",
|
252 |
+
"Weimaraner: 114\n",
|
253 |
+
"Welsh Springer Spaniel: 115\n",
|
254 |
+
"West Highland White Terrier: 116\n",
|
255 |
+
"Whippet: 117\n",
|
256 |
+
"Wire Haired Fox Terrier: 118\n",
|
257 |
+
"Yorkshire Terrier: 119\n"
|
258 |
+
]
|
259 |
+
}
|
260 |
+
],
|
261 |
+
"source": [
|
262 |
+
"if CREATE_DATASET:\n",
|
263 |
+
" ds = datasets.load_dataset(ORIGINAL_DATASET, token=os.getenv(\"HF_TOKEN\"), split=\"full\", trust_remote_code=True)\n",
|
264 |
+
" ds = ds.remove_columns(REMOVE_COLUMNS).rename_columns(RENAME_COLUMNS)\n",
|
265 |
+
"\n",
|
266 |
+
" labels = ds.select_columns(\"label\").to_pandas().sort_values(\"label\").get(\"label\").unique().tolist()\n",
|
267 |
+
" numbers = range(len(labels))\n",
|
268 |
+
" label2int = dict(zip(labels, numbers))\n",
|
269 |
+
" int2label = dict(zip(numbers, labels))\n",
|
270 |
+
"\n",
|
271 |
+
" for key, val in label2int.items():\n",
|
272 |
+
" print(f\"{key}: {val}\")\n",
|
273 |
+
"\n",
|
274 |
+
" ds = ds.class_encode_column(\"label\")\n",
|
275 |
+
" ds = ds.align_labels_with_mapping(label2int, \"label\")\n",
|
276 |
+
"\n",
|
277 |
+
" ds = ds.train_test_split(test_size=SPLIT, stratify_by_column = \"label\")\n",
|
278 |
+
" #ds.push_to_hub(MODIFIED_DATASET, token=os.getenv(\"HF_TOKEN\"))\n",
|
279 |
+
"\n",
|
280 |
+
" CONFIG[\"label2int\"] = str(label2int)\n",
|
281 |
+
" CONFIG[\"int2label\"] = str(int2label)\n",
|
282 |
+
"\n",
|
283 |
+
" # with open(\"output.toml\", \"w\") as toml_file:\n",
|
284 |
+
" # toml.dump(toml.dumps(CONFIG), toml_file)\n",
|
285 |
+
"\n",
|
286 |
+
" #ds = datasets.load_dataset(MODIFIED_DATASET, token=os.getenv(\"HF_TOKEN\"), trust_remote_code=True, streaming=True)"
|
287 |
+
]
|
288 |
+
},
|
289 |
+
{
|
290 |
+
"cell_type": "code",
|
291 |
+
"execution_count": 5,
|
292 |
+
"metadata": {},
|
293 |
+
"outputs": [
|
294 |
+
{
|
295 |
+
"name": "stderr",
|
296 |
+
"output_type": "stream",
|
297 |
+
"text": [
|
298 |
+
"/Users/andrewmayes/Openclassroom/CanineNet/env/lib/python3.12/site-packages/huggingface_hub/file_download.py:1132: FutureWarning: `resume_download` is deprecated and will be removed in version 1.0.0. Downloads always resume when possible. If you want to force a new download, use `force_download=True`.\n",
|
299 |
+
" warnings.warn(\n",
|
300 |
+
"Could not find image processor class in the image processor config or the model config. Loading based on pattern matching with the model's feature extractor configuration. Please open a PR/issue to update `preprocessor_config.json` to use `image_processor_type` instead of `feature_extractor_type`. This warning will be removed in v4.40.\n",
|
301 |
+
"Some weights of ResNetForImageClassification were not initialized from the model checkpoint at microsoft/resnet-50 and are newly initialized because the shapes did not match:\n",
|
302 |
+
"- classifier.1.bias: found shape torch.Size([1000]) in the checkpoint and torch.Size([120]) in the model instantiated\n",
|
303 |
+
"- classifier.1.weight: found shape torch.Size([1000, 2048]) in the checkpoint and torch.Size([120, 2048]) in the model instantiated\n",
|
304 |
+
"You should probably TRAIN this model on a down-stream task to be able to use it for predictions and inference.\n",
|
305 |
+
"max_steps is given, it will override any value given in num_train_epochs\n"
|
306 |
+
]
|
307 |
+
},
|
308 |
+
{
|
309 |
+
"data": {
|
310 |
+
"application/vnd.jupyter.widget-view+json": {
|
311 |
+
"model_id": "5d2082be56df4467893881fa27d9e334",
|
312 |
+
"version_major": 2,
|
313 |
+
"version_minor": 0
|
314 |
+
},
|
315 |
+
"text/plain": [
|
316 |
+
" 0%| | 0/1000 [00:00<?, ?it/s]"
|
317 |
+
]
|
318 |
+
},
|
319 |
+
"metadata": {},
|
320 |
+
"output_type": "display_data"
|
321 |
+
}
|
322 |
+
],
|
323 |
+
"source": [
|
324 |
+
"metrics = {metric: evaluate.load(metric) for metric in METRICS}\n",
|
325 |
+
"\n",
|
326 |
+
"\n",
|
327 |
+
"# for lr in [5e-3, 5e-4, 5e-5]: # 5e-5\n",
|
328 |
+
"# for batch in [64]: # 32\n",
|
329 |
+
"# for model_name in [\"google/vit-base-patch16-224\", \"microsoft/swinv2-base-patch4-window16-256\", \"google/siglip-base-patch16-224\"]: # \"facebook/dinov2-base\"\n",
|
330 |
+
"\n",
|
331 |
+
"lr = 5e-3\n",
|
332 |
+
"batch = 32\n",
|
333 |
+
"model_name = \"microsoft/resnet-50\"\n",
|
334 |
+
"\n",
|
335 |
+
"image_processor = AutoImageProcessor.from_pretrained(model_name)\n",
|
336 |
+
"model = AutoModelForImageClassification.from_pretrained(\n",
|
337 |
+
"model_name,\n",
|
338 |
+
"num_labels=len(label2int),\n",
|
339 |
+
"id2label=int2label,\n",
|
340 |
+
"label2id=label2int,\n",
|
341 |
+
"ignore_mismatched_sizes=True,\n",
|
342 |
+
")\n",
|
343 |
+
"\n",
|
344 |
+
"# Then, in your transformations:\n",
|
345 |
+
"def train_transform(examples, num_ops=10, magnitude=9, num_magnitude_bins=31):\n",
|
346 |
+
"\n",
|
347 |
+
" transformation = v2.Compose(\n",
|
348 |
+
" [\n",
|
349 |
+
" v2.RandAugment(\n",
|
350 |
+
" num_ops=num_ops,\n",
|
351 |
+
" magnitude=magnitude,\n",
|
352 |
+
" num_magnitude_bins=num_magnitude_bins,\n",
|
353 |
+
" )\n",
|
354 |
+
" ]\n",
|
355 |
+
" )\n",
|
356 |
+
" # Ensure each image has three dimensions (in this case, ensure it's RGB)\n",
|
357 |
+
" examples[\"pixel_values\"] = [\n",
|
358 |
+
" image.convert(\"RGB\") for image in examples[\"pixel_values\"]\n",
|
359 |
+
" ]\n",
|
360 |
+
" # Apply transformations\n",
|
361 |
+
" examples[\"pixel_values\"] = [\n",
|
362 |
+
" image_processor(transformation(image), return_tensors=\"pt\")[\n",
|
363 |
+
" \"pixel_values\"\n",
|
364 |
+
" ].squeeze()\n",
|
365 |
+
" for image in examples[\"pixel_values\"]\n",
|
366 |
+
" ]\n",
|
367 |
+
" return examples\n",
|
368 |
+
"\n",
|
369 |
+
"\n",
|
370 |
+
"def test_transform(examples):\n",
|
371 |
+
" # Ensure each image is RGB\n",
|
372 |
+
" examples[\"pixel_values\"] = [\n",
|
373 |
+
" image.convert(\"RGB\") for image in examples[\"pixel_values\"]\n",
|
374 |
+
" ]\n",
|
375 |
+
" # Apply processing\n",
|
376 |
+
" examples[\"pixel_values\"] = [\n",
|
377 |
+
" image_processor(image, return_tensors=\"pt\")[\"pixel_values\"].squeeze()\n",
|
378 |
+
" for image in examples[\"pixel_values\"]\n",
|
379 |
+
" ]\n",
|
380 |
+
" return examples\n",
|
381 |
+
"\n",
|
382 |
+
"\n",
|
383 |
+
"def compute_metrics(eval_pred):\n",
|
384 |
+
" predictions, labels = eval_pred\n",
|
385 |
+
" # predictions = np.argmax(logits, axis=-1)\n",
|
386 |
+
" results = {}\n",
|
387 |
+
" for key, val in metrics.items():\n",
|
388 |
+
" if \"accuracy\" == key:\n",
|
389 |
+
" result = next(\n",
|
390 |
+
" iter(val.compute(predictions=predictions, references=labels).items())\n",
|
391 |
+
" )\n",
|
392 |
+
" if \"accuracy\" != key:\n",
|
393 |
+
" result = next(\n",
|
394 |
+
" iter(\n",
|
395 |
+
" val.compute(\n",
|
396 |
+
" predictions=predictions, references=labels, average=\"macro\"\n",
|
397 |
+
" ).items()\n",
|
398 |
+
" )\n",
|
399 |
+
" )\n",
|
400 |
+
" results[result[0]] = result[1]\n",
|
401 |
+
" return results\n",
|
402 |
+
"\n",
|
403 |
+
"\n",
|
404 |
+
"def collate_fn(examples):\n",
|
405 |
+
" pixel_values = torch.stack([example[\"pixel_values\"] for example in examples])\n",
|
406 |
+
" labels = torch.tensor([example[\"label\"] for example in examples])\n",
|
407 |
+
" return {\"pixel_values\": pixel_values, \"labels\": labels}\n",
|
408 |
+
"\n",
|
409 |
+
"\n",
|
410 |
+
"def preprocess_logits_for_metrics(logits, labels):\n",
|
411 |
+
" \"\"\"\n",
|
412 |
+
" Original Trainer may have a memory leak.\n",
|
413 |
+
" This is a workaround to avoid storing too many tensors that are not needed.\n",
|
414 |
+
" \"\"\"\n",
|
415 |
+
" pred_ids = torch.argmax(logits, dim=-1)\n",
|
416 |
+
" return pred_ids\n",
|
417 |
+
"\n",
|
418 |
+
"ds[\"train\"].set_transform(train_transform)\n",
|
419 |
+
"ds[\"test\"].set_transform(test_transform)\n",
|
420 |
+
"\n",
|
421 |
+
"training_args = TrainingArguments(**CONFIG[\"training_args\"])\n",
|
422 |
+
"training_args.per_device_train_batch_size = batch\n",
|
423 |
+
"training_args.per_device_eval_batch_size = batch\n",
|
424 |
+
"training_args.hub_model_id = f\"amaye15/{model_name.replace('/','-')}-batch{batch}-lr{lr}-standford-dogs\"\n",
|
425 |
+
"\n",
|
426 |
+
"mlflow.start_run(run_name=f\"{model_name.replace('/','-')}-batch{batch}-lr{lr}\")\n",
|
427 |
+
"\n",
|
428 |
+
"trainer = Trainer(\n",
|
429 |
+
" model=model,\n",
|
430 |
+
" args=training_args,\n",
|
431 |
+
" train_dataset=ds[\"train\"],\n",
|
432 |
+
" eval_dataset=ds[\"test\"],\n",
|
433 |
+
" tokenizer=image_processor,\n",
|
434 |
+
" data_collator=collate_fn,\n",
|
435 |
+
" compute_metrics=compute_metrics,\n",
|
436 |
+
" # callbacks=[early_stopping_callback],\n",
|
437 |
+
" preprocess_logits_for_metrics=preprocess_logits_for_metrics,\n",
|
438 |
+
")\n",
|
439 |
+
"\n",
|
440 |
+
"# Train the model\n",
|
441 |
+
"trainer.train()\n",
|
442 |
+
"\n",
|
443 |
+
"trainer.push_to_hub()\n",
|
444 |
+
"\n",
|
445 |
+
"mlflow.end_run()"
|
446 |
+
]
|
447 |
+
}
|
448 |
+
],
|
449 |
+
"metadata": {
|
450 |
+
"kernelspec": {
|
451 |
+
"display_name": "env",
|
452 |
+
"language": "python",
|
453 |
+
"name": "python3"
|
454 |
+
},
|
455 |
+
"language_info": {
|
456 |
+
"codemirror_mode": {
|
457 |
+
"name": "ipython",
|
458 |
+
"version": 3
|
459 |
+
},
|
460 |
+
"file_extension": ".py",
|
461 |
+
"mimetype": "text/x-python",
|
462 |
+
"name": "python",
|
463 |
+
"nbconvert_exporter": "python",
|
464 |
+
"pygments_lexer": "ipython3",
|
465 |
+
"version": "3.12.3"
|
466 |
+
}
|
467 |
+
},
|
468 |
+
"nbformat": 4,
|
469 |
+
"nbformat_minor": 2
|
470 |
+
}
|
training_args.bin
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:b3d78fe7e384da50a7fd018fd0715177c5cbfbcae3417c7ce0956c33b1571350
|
3 |
+
size 5112
|