Spaces:
Running
Running
title
Browse files
README.md
CHANGED
@@ -1,5 +1,5 @@
|
|
1 |
---
|
2 |
-
title:
|
3 |
emoji: 🦀
|
4 |
colorFrom: pink
|
5 |
colorTo: blue
|
|
|
1 |
---
|
2 |
+
title: Dog or Cat?
|
3 |
emoji: 🦀
|
4 |
colorFrom: pink
|
5 |
colorTo: blue
|
app.ipynb
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
"cells": [
|
3 |
{
|
4 |
"cell_type": "code",
|
5 |
-
"execution_count":
|
6 |
"id": "44eb0ad3",
|
7 |
"metadata": {},
|
8 |
"outputs": [],
|
@@ -10,34 +10,8 @@
|
|
10 |
"#export\n",
|
11 |
"from fastai.vision.all import *\n",
|
12 |
"import gradio as gr\n",
|
13 |
-
"
|
14 |
-
|
15 |
-
},
|
16 |
-
{
|
17 |
-
"cell_type": "code",
|
18 |
-
"execution_count": 2,
|
19 |
-
"id": "37155c47",
|
20 |
-
"metadata": {},
|
21 |
-
"outputs": [
|
22 |
-
{
|
23 |
-
"data": {
|
24 |
-
"text/plain": [
|
25 |
-
"['beit_base_patch16_224',\n",
|
26 |
-
" 'beit_base_patch16_224_in22k',\n",
|
27 |
-
" 'beit_base_patch16_384',\n",
|
28 |
-
" 'beit_large_patch16_224',\n",
|
29 |
-
" 'beit_large_patch16_224_in22k',\n",
|
30 |
-
" 'beit_large_patch16_384',\n",
|
31 |
-
" 'beit_large_patch16_512']"
|
32 |
-
]
|
33 |
-
},
|
34 |
-
"execution_count": 2,
|
35 |
-
"metadata": {},
|
36 |
-
"output_type": "execute_result"
|
37 |
-
}
|
38 |
-
],
|
39 |
-
"source": [
|
40 |
-
"timm.list_models('beit*')"
|
41 |
]
|
42 |
},
|
43 |
{
|
@@ -51,36 +25,15 @@
|
|
51 |
"\n",
|
52 |
"dls = ImageDataLoaders.from_name_func('.',\n",
|
53 |
" get_image_files(path), valid_pct=0.2, seed=42,\n",
|
54 |
-
" label_func=
|
55 |
-
" item_tfms=Resize(
|
56 |
]
|
57 |
},
|
58 |
{
|
59 |
"cell_type": "code",
|
60 |
"execution_count": 4,
|
61 |
-
"id": "
|
62 |
"metadata": {},
|
63 |
-
"outputs": [
|
64 |
-
{
|
65 |
-
"name": "stderr",
|
66 |
-
"output_type": "stream",
|
67 |
-
"text": [
|
68 |
-
"/home/jhoward/mambaforge/lib/python3.9/site-packages/torch/functional.py:568: UserWarning: torch.meshgrid: in an upcoming release, it will be required to pass the indexing argument. (Triggered internally at /opt/conda/conda-bld/pytorch_1646755888534/work/aten/src/ATen/native/TensorShape.cpp:2228.)\n",
|
69 |
-
" return _VF.meshgrid(tensors, **kwargs) # type: ignore[attr-defined]\n"
|
70 |
-
]
|
71 |
-
}
|
72 |
-
],
|
73 |
-
"source": [
|
74 |
-
"learn = vision_learner(dls, 'beit_base_patch16_224_in22k', metrics=error_rate)"
|
75 |
-
]
|
76 |
-
},
|
77 |
-
{
|
78 |
-
"cell_type": "code",
|
79 |
-
"execution_count": 5,
|
80 |
-
"id": "8ba3d47b",
|
81 |
-
"metadata": {
|
82 |
-
"scrolled": false
|
83 |
-
},
|
84 |
"outputs": [
|
85 |
{
|
86 |
"data": {
|
@@ -122,10 +75,10 @@
|
|
122 |
" <tbody>\n",
|
123 |
" <tr>\n",
|
124 |
" <td>0</td>\n",
|
125 |
-
" <td>0.
|
126 |
-
" <td>0.
|
127 |
-
" <td>0.
|
128 |
-
" <td>
|
129 |
" </tr>\n",
|
130 |
" </tbody>\n",
|
131 |
"</table>"
|
@@ -137,126 +90,6 @@
|
|
137 |
"metadata": {},
|
138 |
"output_type": "display_data"
|
139 |
},
|
140 |
-
{
|
141 |
-
"data": {
|
142 |
-
"text/html": [
|
143 |
-
"\n",
|
144 |
-
"<style>\n",
|
145 |
-
" /* Turns off some styling */\n",
|
146 |
-
" progress {\n",
|
147 |
-
" /* gets rid of default border in Firefox and Opera. */\n",
|
148 |
-
" border: none;\n",
|
149 |
-
" /* Needs to be in here for Safari polyfill so background images work as expected. */\n",
|
150 |
-
" background-size: auto;\n",
|
151 |
-
" }\n",
|
152 |
-
" .progress-bar-interrupted, .progress-bar-interrupted::-webkit-progress-bar {\n",
|
153 |
-
" background: #F44336;\n",
|
154 |
-
" }\n",
|
155 |
-
"</style>\n"
|
156 |
-
],
|
157 |
-
"text/plain": [
|
158 |
-
"<IPython.core.display.HTML object>"
|
159 |
-
]
|
160 |
-
},
|
161 |
-
"metadata": {},
|
162 |
-
"output_type": "display_data"
|
163 |
-
},
|
164 |
-
{
|
165 |
-
"data": {
|
166 |
-
"text/html": [
|
167 |
-
"\n",
|
168 |
-
" <div>\n",
|
169 |
-
" <progress value='0' class='' max='1' style='width:300px; height:20px; vertical-align: middle;'></progress>\n",
|
170 |
-
" 0.00% [0/1 00:00<00:00]\n",
|
171 |
-
" </div>\n",
|
172 |
-
" \n",
|
173 |
-
"<table border=\"1\" class=\"dataframe\">\n",
|
174 |
-
" <thead>\n",
|
175 |
-
" <tr style=\"text-align: left;\">\n",
|
176 |
-
" <th>epoch</th>\n",
|
177 |
-
" <th>train_loss</th>\n",
|
178 |
-
" <th>valid_loss</th>\n",
|
179 |
-
" <th>error_rate</th>\n",
|
180 |
-
" <th>time</th>\n",
|
181 |
-
" </tr>\n",
|
182 |
-
" </thead>\n",
|
183 |
-
" <tbody>\n",
|
184 |
-
" </tbody>\n",
|
185 |
-
"</table><p>\n",
|
186 |
-
"\n",
|
187 |
-
" <div>\n",
|
188 |
-
" <progress value='0' class='' max='184' style='width:300px; height:20px; vertical-align: middle;'></progress>\n",
|
189 |
-
" 0.00% [0/184 00:00<00:00]\n",
|
190 |
-
" </div>\n",
|
191 |
-
" "
|
192 |
-
],
|
193 |
-
"text/plain": [
|
194 |
-
"<IPython.core.display.HTML object>"
|
195 |
-
]
|
196 |
-
},
|
197 |
-
"metadata": {},
|
198 |
-
"output_type": "display_data"
|
199 |
-
},
|
200 |
-
{
|
201 |
-
"ename": "RuntimeError",
|
202 |
-
"evalue": "CUDA out of memory. Tried to allocate 74.00 MiB (GPU 0; 4.00 GiB total capacity; 3.31 GiB already allocated; 0 bytes free; 3.47 GiB reserved in total by PyTorch) If reserved memory is >> allocated memory try setting max_split_size_mb to avoid fragmentation. See documentation for Memory Management and PYTORCH_CUDA_ALLOC_CONF",
|
203 |
-
"output_type": "error",
|
204 |
-
"traceback": [
|
205 |
-
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
|
206 |
-
"\u001b[0;31mRuntimeError\u001b[0m Traceback (most recent call last)",
|
207 |
-
"Input \u001b[0;32mIn [5]\u001b[0m, in \u001b[0;36m<cell line: 1>\u001b[0;34m()\u001b[0m\n\u001b[0;32m----> 1\u001b[0m \u001b[43mlearn\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mfine_tune\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;241;43m1\u001b[39;49m\u001b[43m)\u001b[49m\n",
|
208 |
-
"File \u001b[0;32m~/git/fastai/fastai/callback/schedule.py:164\u001b[0m, in \u001b[0;36mfine_tune\u001b[0;34m(self, epochs, base_lr, freeze_epochs, lr_mult, pct_start, div, **kwargs)\u001b[0m\n\u001b[1;32m 162\u001b[0m base_lr \u001b[38;5;241m/\u001b[39m\u001b[38;5;241m=\u001b[39m \u001b[38;5;241m2\u001b[39m\n\u001b[1;32m 163\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39munfreeze()\n\u001b[0;32m--> 164\u001b[0m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mfit_one_cycle\u001b[49m\u001b[43m(\u001b[49m\u001b[43mepochs\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;28;43mslice\u001b[39;49m\u001b[43m(\u001b[49m\u001b[43mbase_lr\u001b[49m\u001b[38;5;241;43m/\u001b[39;49m\u001b[43mlr_mult\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mbase_lr\u001b[49m\u001b[43m)\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mpct_start\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mpct_start\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mdiv\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mdiv\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43mkwargs\u001b[49m\u001b[43m)\u001b[49m\n",
|
209 |
-
"File \u001b[0;32m~/git/fastai/fastai/callback/schedule.py:116\u001b[0m, in \u001b[0;36mfit_one_cycle\u001b[0;34m(self, n_epoch, lr_max, div, div_final, pct_start, wd, moms, cbs, reset_opt)\u001b[0m\n\u001b[1;32m 113\u001b[0m lr_max \u001b[38;5;241m=\u001b[39m np\u001b[38;5;241m.\u001b[39marray([h[\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mlr\u001b[39m\u001b[38;5;124m'\u001b[39m] \u001b[38;5;28;01mfor\u001b[39;00m h \u001b[38;5;129;01min\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mopt\u001b[38;5;241m.\u001b[39mhypers])\n\u001b[1;32m 114\u001b[0m scheds \u001b[38;5;241m=\u001b[39m {\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mlr\u001b[39m\u001b[38;5;124m'\u001b[39m: combined_cos(pct_start, lr_max\u001b[38;5;241m/\u001b[39mdiv, lr_max, lr_max\u001b[38;5;241m/\u001b[39mdiv_final),\n\u001b[1;32m 115\u001b[0m \u001b[38;5;124m'\u001b[39m\u001b[38;5;124mmom\u001b[39m\u001b[38;5;124m'\u001b[39m: combined_cos(pct_start, \u001b[38;5;241m*\u001b[39m(\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mmoms \u001b[38;5;28;01mif\u001b[39;00m moms \u001b[38;5;129;01mis\u001b[39;00m \u001b[38;5;28;01mNone\u001b[39;00m \u001b[38;5;28;01melse\u001b[39;00m moms))}\n\u001b[0;32m--> 116\u001b[0m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mfit\u001b[49m\u001b[43m(\u001b[49m\u001b[43mn_epoch\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mcbs\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mParamScheduler\u001b[49m\u001b[43m(\u001b[49m\u001b[43mscheds\u001b[49m\u001b[43m)\u001b[49m\u001b[38;5;241;43m+\u001b[39;49m\u001b[43mL\u001b[49m\u001b[43m(\u001b[49m\u001b[43mcbs\u001b[49m\u001b[43m)\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mreset_opt\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mreset_opt\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mwd\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mwd\u001b[49m\u001b[43m)\u001b[49m\n",
|
210 |
-
"File \u001b[0;32m~/git/fastai/fastai/learner.py:221\u001b[0m, in \u001b[0;36mLearner.fit\u001b[0;34m(self, n_epoch, lr, wd, cbs, reset_opt)\u001b[0m\n\u001b[1;32m 219\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mopt\u001b[38;5;241m.\u001b[39mset_hypers(lr\u001b[38;5;241m=\u001b[39m\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mlr \u001b[38;5;28;01mif\u001b[39;00m lr \u001b[38;5;129;01mis\u001b[39;00m \u001b[38;5;28;01mNone\u001b[39;00m \u001b[38;5;28;01melse\u001b[39;00m lr)\n\u001b[1;32m 220\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mn_epoch \u001b[38;5;241m=\u001b[39m n_epoch\n\u001b[0;32m--> 221\u001b[0m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_with_events\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_do_fit\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[38;5;124;43mfit\u001b[39;49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mCancelFitException\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_end_cleanup\u001b[49m\u001b[43m)\u001b[49m\n",
|
211 |
-
"File \u001b[0;32m~/git/fastai/fastai/learner.py:163\u001b[0m, in \u001b[0;36mLearner._with_events\u001b[0;34m(self, f, event_type, ex, final)\u001b[0m\n\u001b[1;32m 162\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21m_with_events\u001b[39m(\u001b[38;5;28mself\u001b[39m, f, event_type, ex, final\u001b[38;5;241m=\u001b[39mnoop):\n\u001b[0;32m--> 163\u001b[0m \u001b[38;5;28;01mtry\u001b[39;00m: \u001b[38;5;28mself\u001b[39m(\u001b[38;5;124mf\u001b[39m\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mbefore_\u001b[39m\u001b[38;5;132;01m{\u001b[39;00mevent_type\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m'\u001b[39m); \u001b[43mf\u001b[49m\u001b[43m(\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 164\u001b[0m \u001b[38;5;28;01mexcept\u001b[39;00m ex: \u001b[38;5;28mself\u001b[39m(\u001b[38;5;124mf\u001b[39m\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mafter_cancel_\u001b[39m\u001b[38;5;132;01m{\u001b[39;00mevent_type\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m'\u001b[39m)\n\u001b[1;32m 165\u001b[0m \u001b[38;5;28mself\u001b[39m(\u001b[38;5;124mf\u001b[39m\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mafter_\u001b[39m\u001b[38;5;132;01m{\u001b[39;00mevent_type\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m'\u001b[39m); final()\n",
|
212 |
-
"File \u001b[0;32m~/git/fastai/fastai/learner.py:212\u001b[0m, in \u001b[0;36mLearner._do_fit\u001b[0;34m(self)\u001b[0m\n\u001b[1;32m 210\u001b[0m \u001b[38;5;28;01mfor\u001b[39;00m epoch \u001b[38;5;129;01min\u001b[39;00m \u001b[38;5;28mrange\u001b[39m(\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mn_epoch):\n\u001b[1;32m 211\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mepoch\u001b[38;5;241m=\u001b[39mepoch\n\u001b[0;32m--> 212\u001b[0m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_with_events\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_do_epoch\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[38;5;124;43mepoch\u001b[39;49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mCancelEpochException\u001b[49m\u001b[43m)\u001b[49m\n",
|
213 |
-
"File \u001b[0;32m~/git/fastai/fastai/learner.py:163\u001b[0m, in \u001b[0;36mLearner._with_events\u001b[0;34m(self, f, event_type, ex, final)\u001b[0m\n\u001b[1;32m 162\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21m_with_events\u001b[39m(\u001b[38;5;28mself\u001b[39m, f, event_type, ex, final\u001b[38;5;241m=\u001b[39mnoop):\n\u001b[0;32m--> 163\u001b[0m \u001b[38;5;28;01mtry\u001b[39;00m: \u001b[38;5;28mself\u001b[39m(\u001b[38;5;124mf\u001b[39m\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mbefore_\u001b[39m\u001b[38;5;132;01m{\u001b[39;00mevent_type\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m'\u001b[39m); \u001b[43mf\u001b[49m\u001b[43m(\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 164\u001b[0m \u001b[38;5;28;01mexcept\u001b[39;00m ex: \u001b[38;5;28mself\u001b[39m(\u001b[38;5;124mf\u001b[39m\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mafter_cancel_\u001b[39m\u001b[38;5;132;01m{\u001b[39;00mevent_type\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m'\u001b[39m)\n\u001b[1;32m 165\u001b[0m \u001b[38;5;28mself\u001b[39m(\u001b[38;5;124mf\u001b[39m\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mafter_\u001b[39m\u001b[38;5;132;01m{\u001b[39;00mevent_type\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m'\u001b[39m); final()\n",
|
214 |
-
"File \u001b[0;32m~/git/fastai/fastai/learner.py:206\u001b[0m, in \u001b[0;36mLearner._do_epoch\u001b[0;34m(self)\u001b[0m\n\u001b[1;32m 205\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21m_do_epoch\u001b[39m(\u001b[38;5;28mself\u001b[39m):\n\u001b[0;32m--> 206\u001b[0m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_do_epoch_train\u001b[49m\u001b[43m(\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 207\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_do_epoch_validate()\n",
|
215 |
-
"File \u001b[0;32m~/git/fastai/fastai/learner.py:198\u001b[0m, in \u001b[0;36mLearner._do_epoch_train\u001b[0;34m(self)\u001b[0m\n\u001b[1;32m 196\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21m_do_epoch_train\u001b[39m(\u001b[38;5;28mself\u001b[39m):\n\u001b[1;32m 197\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mdl \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mdls\u001b[38;5;241m.\u001b[39mtrain\n\u001b[0;32m--> 198\u001b[0m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_with_events\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mall_batches\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[38;5;124;43mtrain\u001b[39;49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mCancelTrainException\u001b[49m\u001b[43m)\u001b[49m\n",
|
216 |
-
"File \u001b[0;32m~/git/fastai/fastai/learner.py:163\u001b[0m, in \u001b[0;36mLearner._with_events\u001b[0;34m(self, f, event_type, ex, final)\u001b[0m\n\u001b[1;32m 162\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21m_with_events\u001b[39m(\u001b[38;5;28mself\u001b[39m, f, event_type, ex, final\u001b[38;5;241m=\u001b[39mnoop):\n\u001b[0;32m--> 163\u001b[0m \u001b[38;5;28;01mtry\u001b[39;00m: \u001b[38;5;28mself\u001b[39m(\u001b[38;5;124mf\u001b[39m\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mbefore_\u001b[39m\u001b[38;5;132;01m{\u001b[39;00mevent_type\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m'\u001b[39m); \u001b[43mf\u001b[49m\u001b[43m(\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 164\u001b[0m \u001b[38;5;28;01mexcept\u001b[39;00m ex: \u001b[38;5;28mself\u001b[39m(\u001b[38;5;124mf\u001b[39m\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mafter_cancel_\u001b[39m\u001b[38;5;132;01m{\u001b[39;00mevent_type\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m'\u001b[39m)\n\u001b[1;32m 165\u001b[0m \u001b[38;5;28mself\u001b[39m(\u001b[38;5;124mf\u001b[39m\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mafter_\u001b[39m\u001b[38;5;132;01m{\u001b[39;00mevent_type\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m'\u001b[39m); final()\n",
|
217 |
-
"File \u001b[0;32m~/git/fastai/fastai/learner.py:169\u001b[0m, in \u001b[0;36mLearner.all_batches\u001b[0;34m(self)\u001b[0m\n\u001b[1;32m 167\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21mall_batches\u001b[39m(\u001b[38;5;28mself\u001b[39m):\n\u001b[1;32m 168\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mn_iter \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mlen\u001b[39m(\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mdl)\n\u001b[0;32m--> 169\u001b[0m \u001b[38;5;28;01mfor\u001b[39;00m o \u001b[38;5;129;01min\u001b[39;00m \u001b[38;5;28menumerate\u001b[39m(\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mdl): \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mone_batch\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43mo\u001b[49m\u001b[43m)\u001b[49m\n",
|
218 |
-
"File \u001b[0;32m~/git/fastai/fastai/learner.py:194\u001b[0m, in \u001b[0;36mLearner.one_batch\u001b[0;34m(self, i, b)\u001b[0m\n\u001b[1;32m 192\u001b[0m b \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_set_device(b)\n\u001b[1;32m 193\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_split(b)\n\u001b[0;32m--> 194\u001b[0m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_with_events\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_do_one_batch\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[38;5;124;43mbatch\u001b[39;49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mCancelBatchException\u001b[49m\u001b[43m)\u001b[49m\n",
|
219 |
-
"File \u001b[0;32m~/git/fastai/fastai/learner.py:163\u001b[0m, in \u001b[0;36mLearner._with_events\u001b[0;34m(self, f, event_type, ex, final)\u001b[0m\n\u001b[1;32m 162\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21m_with_events\u001b[39m(\u001b[38;5;28mself\u001b[39m, f, event_type, ex, final\u001b[38;5;241m=\u001b[39mnoop):\n\u001b[0;32m--> 163\u001b[0m \u001b[38;5;28;01mtry\u001b[39;00m: \u001b[38;5;28mself\u001b[39m(\u001b[38;5;124mf\u001b[39m\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mbefore_\u001b[39m\u001b[38;5;132;01m{\u001b[39;00mevent_type\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m'\u001b[39m); \u001b[43mf\u001b[49m\u001b[43m(\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 164\u001b[0m \u001b[38;5;28;01mexcept\u001b[39;00m ex: \u001b[38;5;28mself\u001b[39m(\u001b[38;5;124mf\u001b[39m\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mafter_cancel_\u001b[39m\u001b[38;5;132;01m{\u001b[39;00mevent_type\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m'\u001b[39m)\n\u001b[1;32m 165\u001b[0m \u001b[38;5;28mself\u001b[39m(\u001b[38;5;124mf\u001b[39m\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mafter_\u001b[39m\u001b[38;5;132;01m{\u001b[39;00mevent_type\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m'\u001b[39m); final()\n",
|
220 |
-
"File \u001b[0;32m~/git/fastai/fastai/learner.py:172\u001b[0m, in \u001b[0;36mLearner._do_one_batch\u001b[0;34m(self)\u001b[0m\n\u001b[1;32m 171\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21m_do_one_batch\u001b[39m(\u001b[38;5;28mself\u001b[39m):\n\u001b[0;32m--> 172\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mpred \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mmodel\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mxb\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 173\u001b[0m \u001b[38;5;28mself\u001b[39m(\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mafter_pred\u001b[39m\u001b[38;5;124m'\u001b[39m)\n\u001b[1;32m 174\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;28mlen\u001b[39m(\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39myb):\n",
|
221 |
-
"File \u001b[0;32m~/mambaforge/lib/python3.9/site-packages/torch/nn/modules/module.py:1110\u001b[0m, in \u001b[0;36mModule._call_impl\u001b[0;34m(self, *input, **kwargs)\u001b[0m\n\u001b[1;32m 1106\u001b[0m \u001b[38;5;66;03m# If we don't have any hooks, we want to skip the rest of the logic in\u001b[39;00m\n\u001b[1;32m 1107\u001b[0m \u001b[38;5;66;03m# this function, and just call forward.\u001b[39;00m\n\u001b[1;32m 1108\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m (\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_backward_hooks \u001b[38;5;129;01mor\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_forward_hooks \u001b[38;5;129;01mor\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_forward_pre_hooks \u001b[38;5;129;01mor\u001b[39;00m _global_backward_hooks\n\u001b[1;32m 1109\u001b[0m \u001b[38;5;129;01mor\u001b[39;00m _global_forward_hooks \u001b[38;5;129;01mor\u001b[39;00m _global_forward_pre_hooks):\n\u001b[0;32m-> 1110\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[43mforward_call\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[38;5;28;43minput\u001b[39;49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43mkwargs\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 1111\u001b[0m \u001b[38;5;66;03m# Do not call functions when jit is used\u001b[39;00m\n\u001b[1;32m 1112\u001b[0m full_backward_hooks, non_full_backward_hooks \u001b[38;5;241m=\u001b[39m [], []\n",
|
222 |
-
"File \u001b[0;32m~/mambaforge/lib/python3.9/site-packages/torch/nn/modules/container.py:141\u001b[0m, in \u001b[0;36mSequential.forward\u001b[0;34m(self, input)\u001b[0m\n\u001b[1;32m 139\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21mforward\u001b[39m(\u001b[38;5;28mself\u001b[39m, \u001b[38;5;28minput\u001b[39m):\n\u001b[1;32m 140\u001b[0m \u001b[38;5;28;01mfor\u001b[39;00m module \u001b[38;5;129;01min\u001b[39;00m \u001b[38;5;28mself\u001b[39m:\n\u001b[0;32m--> 141\u001b[0m \u001b[38;5;28minput\u001b[39m \u001b[38;5;241m=\u001b[39m \u001b[43mmodule\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;28;43minput\u001b[39;49m\u001b[43m)\u001b[49m\n\u001b[1;32m 142\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28minput\u001b[39m\n",
|
223 |
-
"File \u001b[0;32m~/mambaforge/lib/python3.9/site-packages/torch/nn/modules/module.py:1110\u001b[0m, in \u001b[0;36mModule._call_impl\u001b[0;34m(self, *input, **kwargs)\u001b[0m\n\u001b[1;32m 1106\u001b[0m \u001b[38;5;66;03m# If we don't have any hooks, we want to skip the rest of the logic in\u001b[39;00m\n\u001b[1;32m 1107\u001b[0m \u001b[38;5;66;03m# this function, and just call forward.\u001b[39;00m\n\u001b[1;32m 1108\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m (\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_backward_hooks \u001b[38;5;129;01mor\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_forward_hooks \u001b[38;5;129;01mor\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_forward_pre_hooks \u001b[38;5;129;01mor\u001b[39;00m _global_backward_hooks\n\u001b[1;32m 1109\u001b[0m \u001b[38;5;129;01mor\u001b[39;00m _global_forward_hooks \u001b[38;5;129;01mor\u001b[39;00m _global_forward_pre_hooks):\n\u001b[0;32m-> 1110\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[43mforward_call\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[38;5;28;43minput\u001b[39;49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43mkwargs\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 1111\u001b[0m \u001b[38;5;66;03m# Do not call functions when jit is used\u001b[39;00m\n\u001b[1;32m 1112\u001b[0m full_backward_hooks, non_full_backward_hooks \u001b[38;5;241m=\u001b[39m [], []\n",
|
224 |
-
"File \u001b[0;32m~/git/fastai/fastai/vision/learner.py:174\u001b[0m, in \u001b[0;36mTimmBody.forward\u001b[0;34m(self, x)\u001b[0m\n\u001b[1;32m 173\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21mforward\u001b[39m(\u001b[38;5;28mself\u001b[39m,x):\n\u001b[0;32m--> 174\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mmodel\u001b[38;5;241m.\u001b[39mforward_features(x) \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mneeds_pool \u001b[38;5;28;01melse\u001b[39;00m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mmodel\u001b[49m\u001b[43m(\u001b[49m\u001b[43mx\u001b[49m\u001b[43m)\u001b[49m\n",
|
225 |
-
"File \u001b[0;32m~/mambaforge/lib/python3.9/site-packages/torch/nn/modules/module.py:1110\u001b[0m, in \u001b[0;36mModule._call_impl\u001b[0;34m(self, *input, **kwargs)\u001b[0m\n\u001b[1;32m 1106\u001b[0m \u001b[38;5;66;03m# If we don't have any hooks, we want to skip the rest of the logic in\u001b[39;00m\n\u001b[1;32m 1107\u001b[0m \u001b[38;5;66;03m# this function, and just call forward.\u001b[39;00m\n\u001b[1;32m 1108\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m (\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_backward_hooks \u001b[38;5;129;01mor\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_forward_hooks \u001b[38;5;129;01mor\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_forward_pre_hooks \u001b[38;5;129;01mor\u001b[39;00m _global_backward_hooks\n\u001b[1;32m 1109\u001b[0m \u001b[38;5;129;01mor\u001b[39;00m _global_forward_hooks \u001b[38;5;129;01mor\u001b[39;00m _global_forward_pre_hooks):\n\u001b[0;32m-> 1110\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[43mforward_call\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[38;5;28;43minput\u001b[39;49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43mkwargs\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 1111\u001b[0m \u001b[38;5;66;03m# Do not call functions when jit is used\u001b[39;00m\n\u001b[1;32m 1112\u001b[0m full_backward_hooks, non_full_backward_hooks \u001b[38;5;241m=\u001b[39m [], []\n",
|
226 |
-
"File \u001b[0;32m~/mambaforge/lib/python3.9/site-packages/timm/models/beit.py:337\u001b[0m, in \u001b[0;36mBeit.forward\u001b[0;34m(self, x)\u001b[0m\n\u001b[1;32m 336\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21mforward\u001b[39m(\u001b[38;5;28mself\u001b[39m, x):\n\u001b[0;32m--> 337\u001b[0m x \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mforward_features\u001b[49m\u001b[43m(\u001b[49m\u001b[43mx\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 338\u001b[0m x \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mhead(x)\n\u001b[1;32m 339\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m x\n",
|
227 |
-
"File \u001b[0;32m~/mambaforge/lib/python3.9/site-packages/timm/models/beit.py:327\u001b[0m, in \u001b[0;36mBeit.forward_features\u001b[0;34m(self, x)\u001b[0m\n\u001b[1;32m 325\u001b[0m rel_pos_bias \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mrel_pos_bias() \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mrel_pos_bias \u001b[38;5;129;01mis\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m \u001b[38;5;28;01mNone\u001b[39;00m \u001b[38;5;28;01melse\u001b[39;00m \u001b[38;5;28;01mNone\u001b[39;00m\n\u001b[1;32m 326\u001b[0m \u001b[38;5;28;01mfor\u001b[39;00m blk \u001b[38;5;129;01min\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mblocks:\n\u001b[0;32m--> 327\u001b[0m x \u001b[38;5;241m=\u001b[39m \u001b[43mblk\u001b[49m\u001b[43m(\u001b[49m\u001b[43mx\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mrel_pos_bias\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mrel_pos_bias\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 329\u001b[0m x \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mnorm(x)\n\u001b[1;32m 330\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mfc_norm \u001b[38;5;129;01mis\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m \u001b[38;5;28;01mNone\u001b[39;00m:\n",
|
228 |
-
"File \u001b[0;32m~/mambaforge/lib/python3.9/site-packages/torch/nn/modules/module.py:1110\u001b[0m, in \u001b[0;36mModule._call_impl\u001b[0;34m(self, *input, **kwargs)\u001b[0m\n\u001b[1;32m 1106\u001b[0m \u001b[38;5;66;03m# If we don't have any hooks, we want to skip the rest of the logic in\u001b[39;00m\n\u001b[1;32m 1107\u001b[0m \u001b[38;5;66;03m# this function, and just call forward.\u001b[39;00m\n\u001b[1;32m 1108\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m (\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_backward_hooks \u001b[38;5;129;01mor\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_forward_hooks \u001b[38;5;129;01mor\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_forward_pre_hooks \u001b[38;5;129;01mor\u001b[39;00m _global_backward_hooks\n\u001b[1;32m 1109\u001b[0m \u001b[38;5;129;01mor\u001b[39;00m _global_forward_hooks \u001b[38;5;129;01mor\u001b[39;00m _global_forward_pre_hooks):\n\u001b[0;32m-> 1110\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[43mforward_call\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[38;5;28;43minput\u001b[39;49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43mkwargs\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 1111\u001b[0m \u001b[38;5;66;03m# Do not call functions when jit is used\u001b[39;00m\n\u001b[1;32m 1112\u001b[0m full_backward_hooks, non_full_backward_hooks \u001b[38;5;241m=\u001b[39m [], []\n",
|
229 |
-
"File \u001b[0;32m~/mambaforge/lib/python3.9/site-packages/timm/models/beit.py:188\u001b[0m, in \u001b[0;36mBlock.forward\u001b[0;34m(self, x, rel_pos_bias)\u001b[0m\n\u001b[1;32m 186\u001b[0m \u001b[38;5;28;01melse\u001b[39;00m:\n\u001b[1;32m 187\u001b[0m x \u001b[38;5;241m=\u001b[39m x \u001b[38;5;241m+\u001b[39m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mdrop_path(\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mgamma_1 \u001b[38;5;241m*\u001b[39m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mattn(\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mnorm1(x), rel_pos_bias\u001b[38;5;241m=\u001b[39mrel_pos_bias))\n\u001b[0;32m--> 188\u001b[0m x \u001b[38;5;241m=\u001b[39m x \u001b[38;5;241m+\u001b[39m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mdrop_path(\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mgamma_2 \u001b[38;5;241m*\u001b[39m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mmlp\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mnorm2\u001b[49m\u001b[43m(\u001b[49m\u001b[43mx\u001b[49m\u001b[43m)\u001b[49m\u001b[43m)\u001b[49m)\n\u001b[1;32m 189\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m x\n",
|
230 |
-
"File \u001b[0;32m~/mambaforge/lib/python3.9/site-packages/torch/nn/modules/module.py:1110\u001b[0m, in \u001b[0;36mModule._call_impl\u001b[0;34m(self, *input, **kwargs)\u001b[0m\n\u001b[1;32m 1106\u001b[0m \u001b[38;5;66;03m# If we don't have any hooks, we want to skip the rest of the logic in\u001b[39;00m\n\u001b[1;32m 1107\u001b[0m \u001b[38;5;66;03m# this function, and just call forward.\u001b[39;00m\n\u001b[1;32m 1108\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m (\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_backward_hooks \u001b[38;5;129;01mor\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_forward_hooks \u001b[38;5;129;01mor\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_forward_pre_hooks \u001b[38;5;129;01mor\u001b[39;00m _global_backward_hooks\n\u001b[1;32m 1109\u001b[0m \u001b[38;5;129;01mor\u001b[39;00m _global_forward_hooks \u001b[38;5;129;01mor\u001b[39;00m _global_forward_pre_hooks):\n\u001b[0;32m-> 1110\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[43mforward_call\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[38;5;28;43minput\u001b[39;49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43mkwargs\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 1111\u001b[0m \u001b[38;5;66;03m# Do not call functions when jit is used\u001b[39;00m\n\u001b[1;32m 1112\u001b[0m full_backward_hooks, non_full_backward_hooks \u001b[38;5;241m=\u001b[39m [], []\n",
|
231 |
-
"File \u001b[0;32m~/mambaforge/lib/python3.9/site-packages/timm/models/layers/mlp.py:27\u001b[0m, in \u001b[0;36mMlp.forward\u001b[0;34m(self, x)\u001b[0m\n\u001b[1;32m 25\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21mforward\u001b[39m(\u001b[38;5;28mself\u001b[39m, x):\n\u001b[1;32m 26\u001b[0m x \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mfc1(x)\n\u001b[0;32m---> 27\u001b[0m x \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mact\u001b[49m\u001b[43m(\u001b[49m\u001b[43mx\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 28\u001b[0m x \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mdrop1(x)\n\u001b[1;32m 29\u001b[0m x \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mfc2(x)\n",
|
232 |
-
"File \u001b[0;32m~/mambaforge/lib/python3.9/site-packages/torch/nn/modules/module.py:1110\u001b[0m, in \u001b[0;36mModule._call_impl\u001b[0;34m(self, *input, **kwargs)\u001b[0m\n\u001b[1;32m 1106\u001b[0m \u001b[38;5;66;03m# If we don't have any hooks, we want to skip the rest of the logic in\u001b[39;00m\n\u001b[1;32m 1107\u001b[0m \u001b[38;5;66;03m# this function, and just call forward.\u001b[39;00m\n\u001b[1;32m 1108\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m (\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_backward_hooks \u001b[38;5;129;01mor\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_forward_hooks \u001b[38;5;129;01mor\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_forward_pre_hooks \u001b[38;5;129;01mor\u001b[39;00m _global_backward_hooks\n\u001b[1;32m 1109\u001b[0m \u001b[38;5;129;01mor\u001b[39;00m _global_forward_hooks \u001b[38;5;129;01mor\u001b[39;00m _global_forward_pre_hooks):\n\u001b[0;32m-> 1110\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[43mforward_call\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[38;5;28;43minput\u001b[39;49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43mkwargs\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 1111\u001b[0m \u001b[38;5;66;03m# Do not call functions when jit is used\u001b[39;00m\n\u001b[1;32m 1112\u001b[0m full_backward_hooks, non_full_backward_hooks \u001b[38;5;241m=\u001b[39m [], []\n",
|
233 |
-
"File \u001b[0;32m~/mambaforge/lib/python3.9/site-packages/torch/nn/modules/activation.py:670\u001b[0m, in \u001b[0;36mGELU.forward\u001b[0;34m(self, input)\u001b[0m\n\u001b[1;32m 669\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21mforward\u001b[39m(\u001b[38;5;28mself\u001b[39m, \u001b[38;5;28minput\u001b[39m: Tensor) \u001b[38;5;241m-\u001b[39m\u001b[38;5;241m>\u001b[39m Tensor:\n\u001b[0;32m--> 670\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[43mF\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mgelu\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;28;43minput\u001b[39;49m\u001b[43m)\u001b[49m\n",
|
234 |
-
"File \u001b[0;32m~/git/fastai/fastai/torch_core.py:341\u001b[0m, in \u001b[0;36mTensorBase.__torch_function__\u001b[0;34m(self, func, types, args, kwargs)\u001b[0m\n\u001b[1;32m 339\u001b[0m convert\u001b[38;5;241m=\u001b[39m\u001b[38;5;28;01mFalse\u001b[39;00m\n\u001b[1;32m 340\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m _torch_handled(args, \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_opt, func): convert,types \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mtype\u001b[39m(\u001b[38;5;28mself\u001b[39m),(torch\u001b[38;5;241m.\u001b[39mTensor,)\n\u001b[0;32m--> 341\u001b[0m res \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;43msuper\u001b[39;49m\u001b[43m(\u001b[49m\u001b[43m)\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m__torch_function__\u001b[49m\u001b[43m(\u001b[49m\u001b[43mfunc\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mtypes\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43margs\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43margs\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mkwargs\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mkwargs\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 342\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m convert: res \u001b[38;5;241m=\u001b[39m convert(res)\n\u001b[1;32m 343\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;28misinstance\u001b[39m(res, TensorBase): res\u001b[38;5;241m.\u001b[39mset_meta(\u001b[38;5;28mself\u001b[39m, as_copy\u001b[38;5;241m=\u001b[39m\u001b[38;5;28;01mTrue\u001b[39;00m)\n",
|
235 |
-
"File \u001b[0;32m~/mambaforge/lib/python3.9/site-packages/torch/_tensor.py:1142\u001b[0m, in \u001b[0;36mTensor.__torch_function__\u001b[0;34m(cls, func, types, args, kwargs)\u001b[0m\n\u001b[1;32m 1139\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28mNotImplemented\u001b[39m\n\u001b[1;32m 1141\u001b[0m \u001b[38;5;28;01mwith\u001b[39;00m _C\u001b[38;5;241m.\u001b[39mDisableTorchFunction():\n\u001b[0;32m-> 1142\u001b[0m ret \u001b[38;5;241m=\u001b[39m \u001b[43mfunc\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43margs\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43mkwargs\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 1143\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m func \u001b[38;5;129;01min\u001b[39;00m get_default_nowrap_functions():\n\u001b[1;32m 1144\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m ret\n",
|
236 |
-
"\u001b[0;31mRuntimeError\u001b[0m: CUDA out of memory. Tried to allocate 74.00 MiB (GPU 0; 4.00 GiB total capacity; 3.31 GiB already allocated; 0 bytes free; 3.47 GiB reserved in total by PyTorch) If reserved memory is >> allocated memory try setting max_split_size_mb to avoid fragmentation. See documentation for Memory Management and PYTORCH_CUDA_ALLOC_CONF"
|
237 |
-
]
|
238 |
-
}
|
239 |
-
],
|
240 |
-
"source": [
|
241 |
-
"learn.fine_tune(1)"
|
242 |
-
]
|
243 |
-
},
|
244 |
-
{
|
245 |
-
"cell_type": "code",
|
246 |
-
"execution_count": 5,
|
247 |
-
"id": "c107f724",
|
248 |
-
"metadata": {},
|
249 |
-
"outputs": [],
|
250 |
-
"source": [
|
251 |
-
"learn = vision_learner(dls, resnet18, metrics=error_rate)"
|
252 |
-
]
|
253 |
-
},
|
254 |
-
{
|
255 |
-
"cell_type": "code",
|
256 |
-
"execution_count": 6,
|
257 |
-
"id": "552c2f57",
|
258 |
-
"metadata": {},
|
259 |
-
"outputs": [
|
260 |
{
|
261 |
"data": {
|
262 |
"text/html": [
|
@@ -297,65 +130,24 @@
|
|
297 |
" <tbody>\n",
|
298 |
" <tr>\n",
|
299 |
" <td>0</td>\n",
|
300 |
-
" <td>
|
301 |
-
" <td>
|
302 |
-
" <td>0.
|
303 |
-
" <td>00:
|
304 |
" </tr>\n",
|
305 |
-
"
|
306 |
-
"</
|
307 |
-
|
308 |
-
"
|
309 |
-
"<
|
310 |
-
|
311 |
-
},
|
312 |
-
"metadata": {},
|
313 |
-
"output_type": "display_data"
|
314 |
-
},
|
315 |
-
{
|
316 |
-
"data": {
|
317 |
-
"text/html": [
|
318 |
-
"\n",
|
319 |
-
"<style>\n",
|
320 |
-
" /* Turns off some styling */\n",
|
321 |
-
" progress {\n",
|
322 |
-
" /* gets rid of default border in Firefox and Opera. */\n",
|
323 |
-
" border: none;\n",
|
324 |
-
" /* Needs to be in here for Safari polyfill so background images work as expected. */\n",
|
325 |
-
" background-size: auto;\n",
|
326 |
-
" }\n",
|
327 |
-
" .progress-bar-interrupted, .progress-bar-interrupted::-webkit-progress-bar {\n",
|
328 |
-
" background: #F44336;\n",
|
329 |
-
" }\n",
|
330 |
-
"</style>\n"
|
331 |
-
],
|
332 |
-
"text/plain": [
|
333 |
-
"<IPython.core.display.HTML object>"
|
334 |
-
]
|
335 |
-
},
|
336 |
-
"metadata": {},
|
337 |
-
"output_type": "display_data"
|
338 |
-
},
|
339 |
-
{
|
340 |
-
"data": {
|
341 |
-
"text/html": [
|
342 |
-
"<table border=\"1\" class=\"dataframe\">\n",
|
343 |
-
" <thead>\n",
|
344 |
-
" <tr style=\"text-align: left;\">\n",
|
345 |
-
" <th>epoch</th>\n",
|
346 |
-
" <th>train_loss</th>\n",
|
347 |
-
" <th>valid_loss</th>\n",
|
348 |
-
" <th>error_rate</th>\n",
|
349 |
-
" <th>time</th>\n",
|
350 |
" </tr>\n",
|
351 |
-
" </thead>\n",
|
352 |
-
" <tbody>\n",
|
353 |
" <tr>\n",
|
354 |
-
" <td>
|
355 |
-
" <td>
|
356 |
-
" <td>0.
|
357 |
-
" <td>0.
|
358 |
-
" <td>00:
|
359 |
" </tr>\n",
|
360 |
" </tbody>\n",
|
361 |
"</table>"
|
@@ -369,22 +161,23 @@
|
|
369 |
}
|
370 |
],
|
371 |
"source": [
|
372 |
-
"learn
|
|
|
373 |
]
|
374 |
},
|
375 |
{
|
376 |
"cell_type": "code",
|
377 |
-
"execution_count":
|
378 |
"id": "5171c7fc",
|
379 |
"metadata": {},
|
380 |
"outputs": [],
|
381 |
"source": [
|
382 |
-
"learn.export('model.
|
383 |
]
|
384 |
},
|
385 |
{
|
386 |
"cell_type": "code",
|
387 |
-
"execution_count":
|
388 |
"id": "3295ef11",
|
389 |
"metadata": {},
|
390 |
"outputs": [
|
@@ -395,7 +188,7 @@
|
|
395 |
"PILImage mode=RGB size=192x191"
|
396 |
]
|
397 |
},
|
398 |
-
"execution_count":
|
399 |
"metadata": {},
|
400 |
"output_type": "execute_result"
|
401 |
}
|
@@ -408,7 +201,7 @@
|
|
408 |
},
|
409 |
{
|
410 |
"cell_type": "code",
|
411 |
-
"execution_count":
|
412 |
"id": "ae2bc6ac",
|
413 |
"metadata": {},
|
414 |
"outputs": [],
|
@@ -419,7 +212,7 @@
|
|
419 |
},
|
420 |
{
|
421 |
"cell_type": "code",
|
422 |
-
"execution_count":
|
423 |
"id": "6e0bf9da",
|
424 |
"metadata": {
|
425 |
"scrolled": false
|
@@ -462,10 +255,10 @@
|
|
462 |
{
|
463 |
"data": {
|
464 |
"text/plain": [
|
465 |
-
"('False', TensorBase(0), TensorBase([9.
|
466 |
]
|
467 |
},
|
468 |
-
"execution_count":
|
469 |
"metadata": {},
|
470 |
"output_type": "execute_result"
|
471 |
}
|
@@ -476,7 +269,7 @@
|
|
476 |
},
|
477 |
{
|
478 |
"cell_type": "code",
|
479 |
-
"execution_count":
|
480 |
"id": "0419ed3a",
|
481 |
"metadata": {},
|
482 |
"outputs": [],
|
@@ -491,7 +284,7 @@
|
|
491 |
},
|
492 |
{
|
493 |
"cell_type": "code",
|
494 |
-
"execution_count":
|
495 |
"id": "762dec00",
|
496 |
"metadata": {},
|
497 |
"outputs": [
|
@@ -532,10 +325,10 @@
|
|
532 |
{
|
533 |
"data": {
|
534 |
"text/plain": [
|
535 |
-
"{'Dog': 0.
|
536 |
]
|
537 |
},
|
538 |
-
"execution_count":
|
539 |
"metadata": {},
|
540 |
"output_type": "execute_result"
|
541 |
}
|
@@ -546,15 +339,17 @@
|
|
546 |
},
|
547 |
{
|
548 |
"cell_type": "code",
|
549 |
-
"execution_count":
|
550 |
"id": "0518a30a",
|
551 |
-
"metadata": {
|
|
|
|
|
552 |
"outputs": [
|
553 |
{
|
554 |
"name": "stdout",
|
555 |
"output_type": "stream",
|
556 |
"text": [
|
557 |
-
"Running on local URL: http://127.0.0.1:
|
558 |
"\n",
|
559 |
"To create a public link, set `share=True` in `launch()`.\n"
|
560 |
]
|
@@ -566,7 +361,7 @@
|
|
566 |
" <iframe\n",
|
567 |
" width=\"900\"\n",
|
568 |
" height=\"500\"\n",
|
569 |
-
" src=\"http://127.0.0.1:
|
570 |
" frameborder=\"0\"\n",
|
571 |
" allowfullscreen\n",
|
572 |
" \n",
|
@@ -574,7 +369,7 @@
|
|
574 |
" "
|
575 |
],
|
576 |
"text/plain": [
|
577 |
-
"<IPython.lib.display.IFrame at
|
578 |
]
|
579 |
},
|
580 |
"metadata": {},
|
@@ -583,48 +378,14 @@
|
|
583 |
{
|
584 |
"data": {
|
585 |
"text/plain": [
|
586 |
-
"(<fastapi.applications.FastAPI at
|
587 |
-
" 'http://127.0.0.1:
|
588 |
" None)"
|
589 |
]
|
590 |
},
|
591 |
-
"execution_count":
|
592 |
"metadata": {},
|
593 |
"output_type": "execute_result"
|
594 |
-
},
|
595 |
-
{
|
596 |
-
"data": {
|
597 |
-
"text/html": [
|
598 |
-
"\n",
|
599 |
-
"<style>\n",
|
600 |
-
" /* Turns off some styling */\n",
|
601 |
-
" progress {\n",
|
602 |
-
" /* gets rid of default border in Firefox and Opera. */\n",
|
603 |
-
" border: none;\n",
|
604 |
-
" /* Needs to be in here for Safari polyfill so background images work as expected. */\n",
|
605 |
-
" background-size: auto;\n",
|
606 |
-
" }\n",
|
607 |
-
" .progress-bar-interrupted, .progress-bar-interrupted::-webkit-progress-bar {\n",
|
608 |
-
" background: #F44336;\n",
|
609 |
-
" }\n",
|
610 |
-
"</style>\n"
|
611 |
-
],
|
612 |
-
"text/plain": [
|
613 |
-
"<IPython.core.display.HTML object>"
|
614 |
-
]
|
615 |
-
},
|
616 |
-
"metadata": {},
|
617 |
-
"output_type": "display_data"
|
618 |
-
},
|
619 |
-
{
|
620 |
-
"data": {
|
621 |
-
"text/html": [],
|
622 |
-
"text/plain": [
|
623 |
-
"<IPython.core.display.HTML object>"
|
624 |
-
]
|
625 |
-
},
|
626 |
-
"metadata": {},
|
627 |
-
"output_type": "display_data"
|
628 |
}
|
629 |
],
|
630 |
"source": [
|
@@ -639,7 +400,7 @@
|
|
639 |
},
|
640 |
{
|
641 |
"cell_type": "code",
|
642 |
-
"execution_count":
|
643 |
"id": "103be39f",
|
644 |
"metadata": {},
|
645 |
"outputs": [],
|
@@ -651,7 +412,7 @@
|
|
651 |
},
|
652 |
{
|
653 |
"cell_type": "code",
|
654 |
-
"execution_count":
|
655 |
"id": "fd962acc",
|
656 |
"metadata": {},
|
657 |
"outputs": [],
|
@@ -667,7 +428,7 @@
|
|
667 |
},
|
668 |
{
|
669 |
"cell_type": "code",
|
670 |
-
"execution_count":
|
671 |
"id": "a55f921b",
|
672 |
"metadata": {
|
673 |
"scrolled": true
|
@@ -678,14 +439,14 @@
|
|
678 |
"text/plain": [
|
679 |
"{'data': [{'label': 'Cat',\n",
|
680 |
" 'confidences': [{'label': 'Cat', 'confidence': 1.0},\n",
|
681 |
-
" {'label': 'Dog', 'confidence':
|
682 |
" 'flag_index': None,\n",
|
683 |
" 'updated_state': None,\n",
|
684 |
-
" 'durations': [
|
685 |
-
" 'avg_durations': [
|
686 |
]
|
687 |
},
|
688 |
-
"execution_count":
|
689 |
"metadata": {},
|
690 |
"output_type": "execute_result"
|
691 |
}
|
@@ -721,7 +482,20 @@
|
|
721 |
"name": "python",
|
722 |
"nbconvert_exporter": "python",
|
723 |
"pygments_lexer": "ipython3",
|
724 |
-
"version": "3.9.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
725 |
}
|
726 |
},
|
727 |
"nbformat": 4,
|
|
|
2 |
"cells": [
|
3 |
{
|
4 |
"cell_type": "code",
|
5 |
+
"execution_count": 2,
|
6 |
"id": "44eb0ad3",
|
7 |
"metadata": {},
|
8 |
"outputs": [],
|
|
|
10 |
"#export\n",
|
11 |
"from fastai.vision.all import *\n",
|
12 |
"import gradio as gr\n",
|
13 |
+
"\n",
|
14 |
+
"def is_cat(x): return x[0].isupper()"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
15 |
]
|
16 |
},
|
17 |
{
|
|
|
25 |
"\n",
|
26 |
"dls = ImageDataLoaders.from_name_func('.',\n",
|
27 |
" get_image_files(path), valid_pct=0.2, seed=42,\n",
|
28 |
+
" label_func=is_cat,\n",
|
29 |
+
" item_tfms=Resize(192, method='squish'))"
|
30 |
]
|
31 |
},
|
32 |
{
|
33 |
"cell_type": "code",
|
34 |
"execution_count": 4,
|
35 |
+
"id": "c107f724",
|
36 |
"metadata": {},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
37 |
"outputs": [
|
38 |
{
|
39 |
"data": {
|
|
|
75 |
" <tbody>\n",
|
76 |
" <tr>\n",
|
77 |
" <td>0</td>\n",
|
78 |
+
" <td>0.217549</td>\n",
|
79 |
+
" <td>0.094998</td>\n",
|
80 |
+
" <td>0.026387</td>\n",
|
81 |
+
" <td>00:05</td>\n",
|
82 |
" </tr>\n",
|
83 |
" </tbody>\n",
|
84 |
"</table>"
|
|
|
90 |
"metadata": {},
|
91 |
"output_type": "display_data"
|
92 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
93 |
{
|
94 |
"data": {
|
95 |
"text/html": [
|
|
|
130 |
" <tbody>\n",
|
131 |
" <tr>\n",
|
132 |
" <td>0</td>\n",
|
133 |
+
" <td>0.095330</td>\n",
|
134 |
+
" <td>0.042852</td>\n",
|
135 |
+
" <td>0.013532</td>\n",
|
136 |
+
" <td>00:06</td>\n",
|
137 |
" </tr>\n",
|
138 |
+
" <tr>\n",
|
139 |
+
" <td>1</td>\n",
|
140 |
+
" <td>0.036632</td>\n",
|
141 |
+
" <td>0.046426</td>\n",
|
142 |
+
" <td>0.016915</td>\n",
|
143 |
+
" <td>00:05</td>\n",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
144 |
" </tr>\n",
|
|
|
|
|
145 |
" <tr>\n",
|
146 |
+
" <td>2</td>\n",
|
147 |
+
" <td>0.019293</td>\n",
|
148 |
+
" <td>0.038611</td>\n",
|
149 |
+
" <td>0.013532</td>\n",
|
150 |
+
" <td>00:05</td>\n",
|
151 |
" </tr>\n",
|
152 |
" </tbody>\n",
|
153 |
"</table>"
|
|
|
161 |
}
|
162 |
],
|
163 |
"source": [
|
164 |
+
"learn = vision_learner(dls, resnet18, metrics=error_rate)\n",
|
165 |
+
"learn.fine_tune(3)"
|
166 |
]
|
167 |
},
|
168 |
{
|
169 |
"cell_type": "code",
|
170 |
+
"execution_count": 5,
|
171 |
"id": "5171c7fc",
|
172 |
"metadata": {},
|
173 |
"outputs": [],
|
174 |
"source": [
|
175 |
+
"learn.export('model.pkl')"
|
176 |
]
|
177 |
},
|
178 |
{
|
179 |
"cell_type": "code",
|
180 |
+
"execution_count": 6,
|
181 |
"id": "3295ef11",
|
182 |
"metadata": {},
|
183 |
"outputs": [
|
|
|
188 |
"PILImage mode=RGB size=192x191"
|
189 |
]
|
190 |
},
|
191 |
+
"execution_count": 6,
|
192 |
"metadata": {},
|
193 |
"output_type": "execute_result"
|
194 |
}
|
|
|
201 |
},
|
202 |
{
|
203 |
"cell_type": "code",
|
204 |
+
"execution_count": 7,
|
205 |
"id": "ae2bc6ac",
|
206 |
"metadata": {},
|
207 |
"outputs": [],
|
|
|
212 |
},
|
213 |
{
|
214 |
"cell_type": "code",
|
215 |
+
"execution_count": 8,
|
216 |
"id": "6e0bf9da",
|
217 |
"metadata": {
|
218 |
"scrolled": false
|
|
|
255 |
{
|
256 |
"data": {
|
257 |
"text/plain": [
|
258 |
+
"('False', TensorBase(0), TensorBase([9.9993e-01, 6.6811e-05]))"
|
259 |
]
|
260 |
},
|
261 |
+
"execution_count": 8,
|
262 |
"metadata": {},
|
263 |
"output_type": "execute_result"
|
264 |
}
|
|
|
269 |
},
|
270 |
{
|
271 |
"cell_type": "code",
|
272 |
+
"execution_count": 9,
|
273 |
"id": "0419ed3a",
|
274 |
"metadata": {},
|
275 |
"outputs": [],
|
|
|
284 |
},
|
285 |
{
|
286 |
"cell_type": "code",
|
287 |
+
"execution_count": 10,
|
288 |
"id": "762dec00",
|
289 |
"metadata": {},
|
290 |
"outputs": [
|
|
|
325 |
{
|
326 |
"data": {
|
327 |
"text/plain": [
|
328 |
+
"{'Dog': 0.9999332427978516, 'Cat': 6.681094237137586e-05}"
|
329 |
]
|
330 |
},
|
331 |
+
"execution_count": 10,
|
332 |
"metadata": {},
|
333 |
"output_type": "execute_result"
|
334 |
}
|
|
|
339 |
},
|
340 |
{
|
341 |
"cell_type": "code",
|
342 |
+
"execution_count": 10,
|
343 |
"id": "0518a30a",
|
344 |
+
"metadata": {
|
345 |
+
"collapsed": true
|
346 |
+
},
|
347 |
"outputs": [
|
348 |
{
|
349 |
"name": "stdout",
|
350 |
"output_type": "stream",
|
351 |
"text": [
|
352 |
+
"Running on local URL: http://127.0.0.1:7860/\n",
|
353 |
"\n",
|
354 |
"To create a public link, set `share=True` in `launch()`.\n"
|
355 |
]
|
|
|
361 |
" <iframe\n",
|
362 |
" width=\"900\"\n",
|
363 |
" height=\"500\"\n",
|
364 |
+
" src=\"http://127.0.0.1:7860/\"\n",
|
365 |
" frameborder=\"0\"\n",
|
366 |
" allowfullscreen\n",
|
367 |
" \n",
|
|
|
369 |
" "
|
370 |
],
|
371 |
"text/plain": [
|
372 |
+
"<IPython.lib.display.IFrame at 0x7f98552d6340>"
|
373 |
]
|
374 |
},
|
375 |
"metadata": {},
|
|
|
378 |
{
|
379 |
"data": {
|
380 |
"text/plain": [
|
381 |
+
"(<fastapi.applications.FastAPI at 0x7f986cf492b0>,\n",
|
382 |
+
" 'http://127.0.0.1:7860/',\n",
|
383 |
" None)"
|
384 |
]
|
385 |
},
|
386 |
+
"execution_count": 10,
|
387 |
"metadata": {},
|
388 |
"output_type": "execute_result"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
389 |
}
|
390 |
],
|
391 |
"source": [
|
|
|
400 |
},
|
401 |
{
|
402 |
"cell_type": "code",
|
403 |
+
"execution_count": 11,
|
404 |
"id": "103be39f",
|
405 |
"metadata": {},
|
406 |
"outputs": [],
|
|
|
412 |
},
|
413 |
{
|
414 |
"cell_type": "code",
|
415 |
+
"execution_count": 12,
|
416 |
"id": "fd962acc",
|
417 |
"metadata": {},
|
418 |
"outputs": [],
|
|
|
428 |
},
|
429 |
{
|
430 |
"cell_type": "code",
|
431 |
+
"execution_count": 13,
|
432 |
"id": "a55f921b",
|
433 |
"metadata": {
|
434 |
"scrolled": true
|
|
|
439 |
"text/plain": [
|
440 |
"{'data': [{'label': 'Cat',\n",
|
441 |
" 'confidences': [{'label': 'Cat', 'confidence': 1.0},\n",
|
442 |
+
" {'label': 'Dog', 'confidence': 2.655391640078719e-13}]}],\n",
|
443 |
" 'flag_index': None,\n",
|
444 |
" 'updated_state': None,\n",
|
445 |
+
" 'durations': [0.0977640151977539],\n",
|
446 |
+
" 'avg_durations': [0.0977640151977539]}"
|
447 |
]
|
448 |
},
|
449 |
+
"execution_count": 13,
|
450 |
"metadata": {},
|
451 |
"output_type": "execute_result"
|
452 |
}
|
|
|
482 |
"name": "python",
|
483 |
"nbconvert_exporter": "python",
|
484 |
"pygments_lexer": "ipython3",
|
485 |
+
"version": "3.9.5"
|
486 |
+
},
|
487 |
+
"toc": {
|
488 |
+
"base_numbering": 1,
|
489 |
+
"nav_menu": {},
|
490 |
+
"number_sections": false,
|
491 |
+
"sideBar": true,
|
492 |
+
"skip_h1_title": false,
|
493 |
+
"title_cell": "Table of Contents",
|
494 |
+
"title_sidebar": "Contents",
|
495 |
+
"toc_cell": false,
|
496 |
+
"toc_position": {},
|
497 |
+
"toc_section_display": true,
|
498 |
+
"toc_window_display": false
|
499 |
}
|
500 |
},
|
501 |
"nbformat": 4,
|
app.py
CHANGED
@@ -19,7 +19,7 @@ def classify_image(img):
|
|
19 |
return dict(zip(categories, map(float,probs)))
|
20 |
|
21 |
# Cell
|
22 |
-
image = gr.inputs.Image(shape=(
|
23 |
label = gr.outputs.Label()
|
24 |
examples = ['dog.jpg', 'cat.jpg', 'dunno.jpg']
|
25 |
|
|
|
19 |
return dict(zip(categories, map(float,probs)))
|
20 |
|
21 |
# Cell
|
22 |
+
image = gr.inputs.Image(shape=(192, 192))
|
23 |
label = gr.outputs.Label()
|
24 |
examples = ['dog.jpg', 'cat.jpg', 'dunno.jpg']
|
25 |
|
model.pkl
CHANGED
@@ -1,3 +1,3 @@
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
-
oid sha256:
|
3 |
-
size
|
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:656a52c3cd69a13f3a23f8c1eefa1333a0b7f0509adc60e1bec6e4f9662a4e22
|
3 |
+
size 47062571
|