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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"cells": [
|
3 |
+
{
|
4 |
+
"cell_type": "code",
|
5 |
+
"execution_count": 1,
|
6 |
+
"id": "d153091f",
|
7 |
+
"metadata": {},
|
8 |
+
"outputs": [],
|
9 |
+
"source": [
|
10 |
+
"#|default_exp app"
|
11 |
+
]
|
12 |
+
},
|
13 |
+
{
|
14 |
+
"cell_type": "code",
|
15 |
+
"execution_count": 2,
|
16 |
+
"id": "185bb206",
|
17 |
+
"metadata": {},
|
18 |
+
"outputs": [],
|
19 |
+
"source": [
|
20 |
+
"#|export\n",
|
21 |
+
"from fastai.vision.all import *\n",
|
22 |
+
"import gradio as gr\n",
|
23 |
+
"\n",
|
24 |
+
"def is_Nike(x): return x[0].isupper()"
|
25 |
+
]
|
26 |
+
},
|
27 |
+
{
|
28 |
+
"cell_type": "code",
|
29 |
+
"execution_count": 4,
|
30 |
+
"id": "bb2a5155",
|
31 |
+
"metadata": {},
|
32 |
+
"outputs": [
|
33 |
+
{
|
34 |
+
"data": {
|
35 |
+
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAMAAAABcCAIAAAC3Gi1oAAABJGlDQ1BJQ0MgUHJvZmlsZQAAeJxjYGAycHRxcmUSYGDIzSspCnJ3UoiIjFJgP8/AxsDMAAaJycUFjgEBPiB2Xn5eKgMG+HaNgRFEX9YFmYUpjxdwJRcUlQDpP0BslJJanMzAwGgAZGeXlxQAxRnnANkiSdlg9gYQuygkyBnIPgJk86VD2FdA7CQI+wmIXQT0BJD9BaQ+Hcxm4gCbA2HLgNglqRUgexmc8wsqizLTM0oUDC0tLRUcU/KTUhWCK4tLUn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mode=RGB size=192x92"
|
38 |
+
]
|
39 |
+
},
|
40 |
+
"execution_count": 4,
|
41 |
+
"metadata": {},
|
42 |
+
"output_type": "execute_result"
|
43 |
+
}
|
44 |
+
],
|
45 |
+
"source": [
|
46 |
+
"im = PILImage.create('nike.jpg')\n",
|
47 |
+
"im.thumbnail((192, 192))\n",
|
48 |
+
"im"
|
49 |
+
]
|
50 |
+
},
|
51 |
+
{
|
52 |
+
"cell_type": "code",
|
53 |
+
"execution_count": 5,
|
54 |
+
"id": "9a347aa9",
|
55 |
+
"metadata": {},
|
56 |
+
"outputs": [],
|
57 |
+
"source": [
|
58 |
+
"#|export\n",
|
59 |
+
"learn = load_learner('model.pkl')"
|
60 |
+
]
|
61 |
+
},
|
62 |
+
{
|
63 |
+
"cell_type": "code",
|
64 |
+
"execution_count": 6,
|
65 |
+
"id": "e910c328",
|
66 |
+
"metadata": {},
|
67 |
+
"outputs": [
|
68 |
+
{
|
69 |
+
"data": {
|
70 |
+
"text/html": [
|
71 |
+
"\n",
|
72 |
+
"<style>\n",
|
73 |
+
" /* Turns off some styling */\n",
|
74 |
+
" progress {\n",
|
75 |
+
" /* gets rid of default border in Firefox and Opera. */\n",
|
76 |
+
" border: none;\n",
|
77 |
+
" /* Needs to be in here for Safari polyfill so background images work as expected. */\n",
|
78 |
+
" background-size: auto;\n",
|
79 |
+
" }\n",
|
80 |
+
" progress:not([value]), progress:not([value])::-webkit-progress-bar {\n",
|
81 |
+
" background: repeating-linear-gradient(45deg, #7e7e7e, #7e7e7e 10px, #5c5c5c 10px, #5c5c5c 20px);\n",
|
82 |
+
" }\n",
|
83 |
+
" .progress-bar-interrupted, .progress-bar-interrupted::-webkit-progress-bar {\n",
|
84 |
+
" background: #F44336;\n",
|
85 |
+
" }\n",
|
86 |
+
"</style>\n"
|
87 |
+
],
|
88 |
+
"text/plain": [
|
89 |
+
"<IPython.core.display.HTML object>"
|
90 |
+
]
|
91 |
+
},
|
92 |
+
"metadata": {},
|
93 |
+
"output_type": "display_data"
|
94 |
+
},
|
95 |
+
{
|
96 |
+
"data": {
|
97 |
+
"text/html": [],
|
98 |
+
"text/plain": [
|
99 |
+
"<IPython.core.display.HTML object>"
|
100 |
+
]
|
101 |
+
},
|
102 |
+
"metadata": {},
|
103 |
+
"output_type": "display_data"
|
104 |
+
},
|
105 |
+
{
|
106 |
+
"data": {
|
107 |
+
"text/plain": [
|
108 |
+
"('Nike', tensor(1), tensor([0.0123, 0.9846, 0.0030]))"
|
109 |
+
]
|
110 |
+
},
|
111 |
+
"execution_count": 6,
|
112 |
+
"metadata": {},
|
113 |
+
"output_type": "execute_result"
|
114 |
+
}
|
115 |
+
],
|
116 |
+
"source": [
|
117 |
+
"learn.predict(im)"
|
118 |
+
]
|
119 |
+
},
|
120 |
+
{
|
121 |
+
"cell_type": "code",
|
122 |
+
"execution_count": 7,
|
123 |
+
"id": "788ca2aa",
|
124 |
+
"metadata": {},
|
125 |
+
"outputs": [],
|
126 |
+
"source": [
|
127 |
+
"#|export\n",
|
128 |
+
"categories = ('Nike', 'Adidas', 'Vans')\n",
|
129 |
+
"\n",
|
130 |
+
"def classify_image(img):\n",
|
131 |
+
" pred,idx,probs = learn.predict(img)\n",
|
132 |
+
" return dict(zip(categories, map(float,probs)))"
|
133 |
+
]
|
134 |
+
},
|
135 |
+
{
|
136 |
+
"cell_type": "code",
|
137 |
+
"execution_count": 8,
|
138 |
+
"id": "3af72a0e",
|
139 |
+
"metadata": {},
|
140 |
+
"outputs": [
|
141 |
+
{
|
142 |
+
"data": {
|
143 |
+
"text/html": [
|
144 |
+
"\n",
|
145 |
+
"<style>\n",
|
146 |
+
" /* Turns off some styling */\n",
|
147 |
+
" progress {\n",
|
148 |
+
" /* gets rid of default border in Firefox and Opera. */\n",
|
149 |
+
" border: none;\n",
|
150 |
+
" /* Needs to be in here for Safari polyfill so background images work as expected. */\n",
|
151 |
+
" background-size: auto;\n",
|
152 |
+
" }\n",
|
153 |
+
" progress:not([value]), progress:not([value])::-webkit-progress-bar {\n",
|
154 |
+
" background: repeating-linear-gradient(45deg, #7e7e7e, #7e7e7e 10px, #5c5c5c 10px, #5c5c5c 20px);\n",
|
155 |
+
" }\n",
|
156 |
+
" .progress-bar-interrupted, .progress-bar-interrupted::-webkit-progress-bar {\n",
|
157 |
+
" background: #F44336;\n",
|
158 |
+
" }\n",
|
159 |
+
"</style>\n"
|
160 |
+
],
|
161 |
+
"text/plain": [
|
162 |
+
"<IPython.core.display.HTML object>"
|
163 |
+
]
|
164 |
+
},
|
165 |
+
"metadata": {},
|
166 |
+
"output_type": "display_data"
|
167 |
+
},
|
168 |
+
{
|
169 |
+
"data": {
|
170 |
+
"text/html": [],
|
171 |
+
"text/plain": [
|
172 |
+
"<IPython.core.display.HTML object>"
|
173 |
+
]
|
174 |
+
},
|
175 |
+
"metadata": {},
|
176 |
+
"output_type": "display_data"
|
177 |
+
},
|
178 |
+
{
|
179 |
+
"data": {
|
180 |
+
"text/plain": [
|
181 |
+
"{'Nike': 0.012349084950983524,\n",
|
182 |
+
" 'Adidas': 0.984638512134552,\n",
|
183 |
+
" 'Vans': 0.0030123384203761816}"
|
184 |
+
]
|
185 |
+
},
|
186 |
+
"execution_count": 8,
|
187 |
+
"metadata": {},
|
188 |
+
"output_type": "execute_result"
|
189 |
+
}
|
190 |
+
],
|
191 |
+
"source": [
|
192 |
+
"classify_image(im)"
|
193 |
+
]
|
194 |
+
},
|
195 |
+
{
|
196 |
+
"cell_type": "code",
|
197 |
+
"execution_count": 11,
|
198 |
+
"id": "14ea9dc4",
|
199 |
+
"metadata": {},
|
200 |
+
"outputs": [
|
201 |
+
{
|
202 |
+
"ename": "FileNotFoundError",
|
203 |
+
"evalue": "[Errno 2] No such file or directory: 'adidas_test.jpg'",
|
204 |
+
"output_type": "error",
|
205 |
+
"traceback": [
|
206 |
+
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
|
207 |
+
"\u001b[0;31mFileNotFoundError\u001b[0m Traceback (most recent call last)",
|
208 |
+
"Cell \u001b[0;32mIn[11], line 6\u001b[0m\n\u001b[1;32m 3\u001b[0m label \u001b[38;5;241m=\u001b[39m gr\u001b[38;5;241m.\u001b[39moutputs\u001b[38;5;241m.\u001b[39mLabel()\n\u001b[1;32m 4\u001b[0m examples \u001b[38;5;241m=\u001b[39m [\u001b[38;5;124m'\u001b[39m\u001b[38;5;124madidas_test.jpg\u001b[39m\u001b[38;5;124m'\u001b[39m, \u001b[38;5;124m'\u001b[39m\u001b[38;5;124mnike_teste.jpg\u001b[39m\u001b[38;5;124m'\u001b[39m, \u001b[38;5;124m'\u001b[39m\u001b[38;5;124mvans.jpg\u001b[39m\u001b[38;5;124m'\u001b[39m]\n\u001b[0;32m----> 6\u001b[0m intf \u001b[38;5;241m=\u001b[39m \u001b[43mgr\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mInterface\u001b[49m\u001b[43m(\u001b[49m\u001b[43mfn\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mclassify_image\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43minputs\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mimage\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43moutputs\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mlabel\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mexamples\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mexamples\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 7\u001b[0m intf\u001b[38;5;241m.\u001b[39mlaunch(inline\u001b[38;5;241m=\u001b[39m\u001b[38;5;28;01mFalse\u001b[39;00m)\n",
|
209 |
+
"File \u001b[0;32m/opt/mambaforge/envs/fastai/lib/python3.10/site-packages/gradio/interface.py:455\u001b[0m, in \u001b[0;36mInterface.__init__\u001b[0;34m(self, fn, inputs, outputs, examples, cache_examples, examples_per_page, live, interpretation, num_shap, title, description, article, thumbnail, theme, css, allow_flagging, flagging_options, flagging_dir, flagging_callback, analytics_enabled, batch, max_batch_size, _api_mode, **kwargs)\u001b[0m\n\u001b[1;32m 447\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mattach_interpretation_events(\n\u001b[1;32m 448\u001b[0m interpretation_btn,\n\u001b[1;32m 449\u001b[0m interpretation_set,\n\u001b[1;32m 450\u001b[0m input_component_column,\n\u001b[1;32m 451\u001b[0m interpret_component_column,\n\u001b[1;32m 452\u001b[0m )\n\u001b[1;32m 454\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mattach_flagging_events(flag_btns, clear_btn)\n\u001b[0;32m--> 455\u001b[0m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mrender_examples\u001b[49m\u001b[43m(\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 456\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mrender_article()\n\u001b[1;32m 458\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mconfig \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mget_config_file()\n",
|
210 |
+
"File \u001b[0;32m/opt/mambaforge/envs/fastai/lib/python3.10/site-packages/gradio/interface.py:771\u001b[0m, in \u001b[0;36mInterface.render_examples\u001b[0;34m(self)\u001b[0m\n\u001b[1;32m 765\u001b[0m non_state_inputs \u001b[38;5;241m=\u001b[39m [\n\u001b[1;32m 766\u001b[0m c \u001b[38;5;28;01mfor\u001b[39;00m c \u001b[38;5;129;01min\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39minput_components \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m \u001b[38;5;28misinstance\u001b[39m(c, State)\n\u001b[1;32m 767\u001b[0m ]\n\u001b[1;32m 768\u001b[0m non_state_outputs \u001b[38;5;241m=\u001b[39m [\n\u001b[1;32m 769\u001b[0m c \u001b[38;5;28;01mfor\u001b[39;00m c \u001b[38;5;129;01min\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39moutput_components \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m \u001b[38;5;28misinstance\u001b[39m(c, State)\n\u001b[1;32m 770\u001b[0m ]\n\u001b[0;32m--> 771\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mexamples_handler \u001b[38;5;241m=\u001b[39m \u001b[43mExamples\u001b[49m\u001b[43m(\u001b[49m\n\u001b[1;32m 772\u001b[0m \u001b[43m \u001b[49m\u001b[43mexamples\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[43mexamples\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 773\u001b[0m \u001b[43m \u001b[49m\u001b[43minputs\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mnon_state_inputs\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;66;43;03m# type: ignore\u001b[39;49;00m\n\u001b[1;32m 774\u001b[0m \u001b[43m \u001b[49m\u001b[43moutputs\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mnon_state_outputs\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;66;43;03m# type: ignore\u001b[39;49;00m\n\u001b[1;32m 775\u001b[0m \u001b[43m \u001b[49m\u001b[43mfn\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[43mfn\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 776\u001b[0m \u001b[43m \u001b[49m\u001b[43mcache_examples\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[43mcache_examples\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 777\u001b[0m \u001b[43m \u001b[49m\u001b[43mexamples_per_page\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[43mexamples_per_page\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 778\u001b[0m \u001b[43m \u001b[49m\u001b[43m_api_mode\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[43mapi_mode\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 779\u001b[0m \u001b[43m \u001b[49m\u001b[43mbatch\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[43mbatch\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 780\u001b[0m \u001b[43m\u001b[49m\u001b[43m)\u001b[49m\n",
|
211 |
+
"File \u001b[0;32m/opt/mambaforge/envs/fastai/lib/python3.10/site-packages/gradio/helpers.py:55\u001b[0m, in \u001b[0;36mcreate_examples\u001b[0;34m(examples, inputs, outputs, fn, cache_examples, examples_per_page, _api_mode, label, elem_id, run_on_click, preprocess, postprocess, batch)\u001b[0m\n\u001b[1;32m 39\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21mcreate_examples\u001b[39m(\n\u001b[1;32m 40\u001b[0m examples: List[Any] \u001b[38;5;241m|\u001b[39m List[List[Any]] \u001b[38;5;241m|\u001b[39m \u001b[38;5;28mstr\u001b[39m,\n\u001b[1;32m 41\u001b[0m inputs: IOComponent \u001b[38;5;241m|\u001b[39m List[IOComponent],\n\u001b[0;32m (...)\u001b[0m\n\u001b[1;32m 52\u001b[0m batch: \u001b[38;5;28mbool\u001b[39m \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;01mFalse\u001b[39;00m,\n\u001b[1;32m 53\u001b[0m ):\n\u001b[1;32m 54\u001b[0m \u001b[38;5;250m \u001b[39m\u001b[38;5;124;03m\"\"\"Top-level synchronous function that creates Examples. Provided for backwards compatibility, i.e. so that gr.Examples(...) can be used to create the Examples component.\"\"\"\u001b[39;00m\n\u001b[0;32m---> 55\u001b[0m examples_obj \u001b[38;5;241m=\u001b[39m \u001b[43mExamples\u001b[49m\u001b[43m(\u001b[49m\n\u001b[1;32m 56\u001b[0m \u001b[43m \u001b[49m\u001b[43mexamples\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mexamples\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 57\u001b[0m \u001b[43m \u001b[49m\u001b[43minputs\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43minputs\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 58\u001b[0m \u001b[43m \u001b[49m\u001b[43moutputs\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43moutputs\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 59\u001b[0m \u001b[43m \u001b[49m\u001b[43mfn\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mfn\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 60\u001b[0m \u001b[43m \u001b[49m\u001b[43mcache_examples\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mcache_examples\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 61\u001b[0m \u001b[43m \u001b[49m\u001b[43mexamples_per_page\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mexamples_per_page\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 62\u001b[0m \u001b[43m \u001b[49m\u001b[43m_api_mode\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43m_api_mode\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 63\u001b[0m \u001b[43m \u001b[49m\u001b[43mlabel\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mlabel\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 64\u001b[0m \u001b[43m \u001b[49m\u001b[43melem_id\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43melem_id\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 65\u001b[0m \u001b[43m \u001b[49m\u001b[43mrun_on_click\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mrun_on_click\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 66\u001b[0m \u001b[43m \u001b[49m\u001b[43mpreprocess\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mpreprocess\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 67\u001b[0m \u001b[43m \u001b[49m\u001b[43mpostprocess\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mpostprocess\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 68\u001b[0m \u001b[43m \u001b[49m\u001b[43mbatch\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mbatch\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 69\u001b[0m \u001b[43m \u001b[49m\u001b[43m_initiated_directly\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;28;43;01mFalse\u001b[39;49;00m\u001b[43m,\u001b[49m\n\u001b[1;32m 70\u001b[0m \u001b[43m \u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 71\u001b[0m client_utils\u001b[38;5;241m.\u001b[39msynchronize_async(examples_obj\u001b[38;5;241m.\u001b[39mcreate)\n\u001b[1;32m 72\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m examples_obj\n",
|
212 |
+
"File \u001b[0;32m/opt/mambaforge/envs/fastai/lib/python3.10/site-packages/gradio/helpers.py:202\u001b[0m, in \u001b[0;36mExamples.__init__\u001b[0;34m(self, examples, inputs, outputs, fn, cache_examples, examples_per_page, _api_mode, label, elem_id, run_on_click, preprocess, postprocess, batch, _initiated_directly)\u001b[0m\n\u001b[1;32m 199\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mbatch \u001b[38;5;241m=\u001b[39m batch\n\u001b[1;32m 201\u001b[0m \u001b[38;5;28;01mwith\u001b[39;00m utils\u001b[38;5;241m.\u001b[39mset_directory(working_directory):\n\u001b[0;32m--> 202\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mprocessed_examples \u001b[38;5;241m=\u001b[39m [\n\u001b[1;32m 203\u001b[0m [\n\u001b[1;32m 204\u001b[0m component\u001b[38;5;241m.\u001b[39mpostprocess(sample)\n\u001b[1;32m 205\u001b[0m \u001b[38;5;28;01mfor\u001b[39;00m component, sample \u001b[38;5;129;01min\u001b[39;00m \u001b[38;5;28mzip\u001b[39m(inputs, example)\n\u001b[1;32m 206\u001b[0m ]\n\u001b[1;32m 207\u001b[0m \u001b[38;5;28;01mfor\u001b[39;00m example \u001b[38;5;129;01min\u001b[39;00m examples\n\u001b[1;32m 208\u001b[0m ]\n\u001b[1;32m 209\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mnon_none_processed_examples \u001b[38;5;241m=\u001b[39m [\n\u001b[1;32m 210\u001b[0m [ex \u001b[38;5;28;01mfor\u001b[39;00m (ex, keep) \u001b[38;5;129;01min\u001b[39;00m \u001b[38;5;28mzip\u001b[39m(example, input_has_examples) \u001b[38;5;28;01mif\u001b[39;00m keep]\n\u001b[1;32m 211\u001b[0m \u001b[38;5;28;01mfor\u001b[39;00m example \u001b[38;5;129;01min\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mprocessed_examples\n\u001b[1;32m 212\u001b[0m ]\n\u001b[1;32m 213\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m cache_examples:\n",
|
213 |
+
"File \u001b[0;32m/opt/mambaforge/envs/fastai/lib/python3.10/site-packages/gradio/helpers.py:203\u001b[0m, in \u001b[0;36m<listcomp>\u001b[0;34m(.0)\u001b[0m\n\u001b[1;32m 199\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mbatch \u001b[38;5;241m=\u001b[39m batch\n\u001b[1;32m 201\u001b[0m \u001b[38;5;28;01mwith\u001b[39;00m utils\u001b[38;5;241m.\u001b[39mset_directory(working_directory):\n\u001b[1;32m 202\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mprocessed_examples \u001b[38;5;241m=\u001b[39m [\n\u001b[0;32m--> 203\u001b[0m [\n\u001b[1;32m 204\u001b[0m component\u001b[38;5;241m.\u001b[39mpostprocess(sample)\n\u001b[1;32m 205\u001b[0m \u001b[38;5;28;01mfor\u001b[39;00m component, sample \u001b[38;5;129;01min\u001b[39;00m \u001b[38;5;28mzip\u001b[39m(inputs, example)\n\u001b[1;32m 206\u001b[0m ]\n\u001b[1;32m 207\u001b[0m \u001b[38;5;28;01mfor\u001b[39;00m example \u001b[38;5;129;01min\u001b[39;00m examples\n\u001b[1;32m 208\u001b[0m ]\n\u001b[1;32m 209\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mnon_none_processed_examples \u001b[38;5;241m=\u001b[39m [\n\u001b[1;32m 210\u001b[0m [ex \u001b[38;5;28;01mfor\u001b[39;00m (ex, keep) \u001b[38;5;129;01min\u001b[39;00m \u001b[38;5;28mzip\u001b[39m(example, input_has_examples) \u001b[38;5;28;01mif\u001b[39;00m keep]\n\u001b[1;32m 211\u001b[0m \u001b[38;5;28;01mfor\u001b[39;00m example \u001b[38;5;129;01min\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mprocessed_examples\n\u001b[1;32m 212\u001b[0m ]\n\u001b[1;32m 213\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m cache_examples:\n",
|
214 |
+
"File \u001b[0;32m/opt/mambaforge/envs/fastai/lib/python3.10/site-packages/gradio/helpers.py:204\u001b[0m, in \u001b[0;36m<listcomp>\u001b[0;34m(.0)\u001b[0m\n\u001b[1;32m 199\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mbatch \u001b[38;5;241m=\u001b[39m batch\n\u001b[1;32m 201\u001b[0m \u001b[38;5;28;01mwith\u001b[39;00m utils\u001b[38;5;241m.\u001b[39mset_directory(working_directory):\n\u001b[1;32m 202\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mprocessed_examples \u001b[38;5;241m=\u001b[39m [\n\u001b[1;32m 203\u001b[0m [\n\u001b[0;32m--> 204\u001b[0m \u001b[43mcomponent\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mpostprocess\u001b[49m\u001b[43m(\u001b[49m\u001b[43msample\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 205\u001b[0m \u001b[38;5;28;01mfor\u001b[39;00m component, sample \u001b[38;5;129;01min\u001b[39;00m \u001b[38;5;28mzip\u001b[39m(inputs, example)\n\u001b[1;32m 206\u001b[0m ]\n\u001b[1;32m 207\u001b[0m \u001b[38;5;28;01mfor\u001b[39;00m example \u001b[38;5;129;01min\u001b[39;00m examples\n\u001b[1;32m 208\u001b[0m ]\n\u001b[1;32m 209\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mnon_none_processed_examples \u001b[38;5;241m=\u001b[39m [\n\u001b[1;32m 210\u001b[0m [ex \u001b[38;5;28;01mfor\u001b[39;00m (ex, keep) \u001b[38;5;129;01min\u001b[39;00m \u001b[38;5;28mzip\u001b[39m(example, input_has_examples) \u001b[38;5;28;01mif\u001b[39;00m keep]\n\u001b[1;32m 211\u001b[0m \u001b[38;5;28;01mfor\u001b[39;00m example \u001b[38;5;129;01min\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mprocessed_examples\n\u001b[1;32m 212\u001b[0m ]\n\u001b[1;32m 213\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m cache_examples:\n",
|
215 |
+
"File \u001b[0;32m/opt/mambaforge/envs/fastai/lib/python3.10/site-packages/gradio/components.py:1797\u001b[0m, in \u001b[0;36mImage.postprocess\u001b[0;34m(self, y)\u001b[0m\n\u001b[1;32m 1795\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m processing_utils\u001b[38;5;241m.\u001b[39mencode_pil_to_base64(y)\n\u001b[1;32m 1796\u001b[0m \u001b[38;5;28;01melif\u001b[39;00m \u001b[38;5;28misinstance\u001b[39m(y, (\u001b[38;5;28mstr\u001b[39m, Path)):\n\u001b[0;32m-> 1797\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[43mclient_utils\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mencode_url_or_file_to_base64\u001b[49m\u001b[43m(\u001b[49m\u001b[43my\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 1798\u001b[0m \u001b[38;5;28;01melse\u001b[39;00m:\n\u001b[1;32m 1799\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m \u001b[38;5;167;01mValueError\u001b[39;00m(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mCannot process this value as an Image\u001b[39m\u001b[38;5;124m\"\u001b[39m)\n",
|
216 |
+
"File \u001b[0;32m/opt/mambaforge/envs/fastai/lib/python3.10/site-packages/gradio_client/utils.py:277\u001b[0m, in \u001b[0;36mencode_url_or_file_to_base64\u001b[0;34m(path)\u001b[0m\n\u001b[1;32m 275\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m encode_url_to_base64(path)\n\u001b[1;32m 276\u001b[0m \u001b[38;5;28;01melse\u001b[39;00m:\n\u001b[0;32m--> 277\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[43mencode_file_to_base64\u001b[49m\u001b[43m(\u001b[49m\u001b[43mpath\u001b[49m\u001b[43m)\u001b[49m\n",
|
217 |
+
"File \u001b[0;32m/opt/mambaforge/envs/fastai/lib/python3.10/site-packages/gradio_client/utils.py:251\u001b[0m, in \u001b[0;36mencode_file_to_base64\u001b[0;34m(f)\u001b[0m\n\u001b[1;32m 250\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21mencode_file_to_base64\u001b[39m(f):\n\u001b[0;32m--> 251\u001b[0m \u001b[38;5;28;01mwith\u001b[39;00m \u001b[38;5;28;43mopen\u001b[39;49m\u001b[43m(\u001b[49m\u001b[43mf\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mrb\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m)\u001b[49m \u001b[38;5;28;01mas\u001b[39;00m file:\n\u001b[1;32m 252\u001b[0m encoded_string \u001b[38;5;241m=\u001b[39m base64\u001b[38;5;241m.\u001b[39mb64encode(file\u001b[38;5;241m.\u001b[39mread())\n\u001b[1;32m 253\u001b[0m base64_str \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mstr\u001b[39m(encoded_string, \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mutf-8\u001b[39m\u001b[38;5;124m\"\u001b[39m)\n",
|
218 |
+
"\u001b[0;31mFileNotFoundError\u001b[0m: [Errno 2] No such file or directory: 'adidas_test.jpg'"
|
219 |
+
]
|
220 |
+
}
|
221 |
+
],
|
222 |
+
"source": [
|
223 |
+
"#|export\n",
|
224 |
+
"image = gr.inputs.Image(shape=(192, 192))\n",
|
225 |
+
"label = gr.outputs.Label()\n",
|
226 |
+
"examples = ['adidas_test.jpg', 'nike_teste.jpg', 'vans.jpg']\n",
|
227 |
+
"\n",
|
228 |
+
"intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples)\n",
|
229 |
+
"intf.launch(inline=False)"
|
230 |
+
]
|
231 |
+
},
|
232 |
+
{
|
233 |
+
"cell_type": "code",
|
234 |
+
"execution_count": null,
|
235 |
+
"id": "bf707474",
|
236 |
+
"metadata": {},
|
237 |
+
"outputs": [],
|
238 |
+
"source": [
|
239 |
+
"m = learn.model"
|
240 |
+
]
|
241 |
+
}
|
242 |
+
],
|
243 |
+
"metadata": {
|
244 |
+
"kernelspec": {
|
245 |
+
"display_name": "Python 3 (ipykernel)",
|
246 |
+
"language": "python",
|
247 |
+
"name": "python3"
|
248 |
+
},
|
249 |
+
"language_info": {
|
250 |
+
"codemirror_mode": {
|
251 |
+
"name": "ipython",
|
252 |
+
"version": 3
|
253 |
+
},
|
254 |
+
"file_extension": ".py",
|
255 |
+
"mimetype": "text/x-python",
|
256 |
+
"name": "python",
|
257 |
+
"nbconvert_exporter": "python",
|
258 |
+
"pygments_lexer": "ipython3",
|
259 |
+
"version": "3.10.8"
|
260 |
+
}
|
261 |
+
},
|
262 |
+
"nbformat": 4,
|
263 |
+
"nbformat_minor": 5
|
264 |
+
}
|
model.pkl
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:1e285e7a987ac4b9bd0cc624c631ed429aa7fb0cf89f18fa698fb84924eb8024
|
3 |
+
size 46962373
|
nike_teste.jpg
ADDED
vans.jpg
ADDED