Dstd90 commited on
Commit
348515d
·
1 Parent(s): 6b26348

app rework1

Browse files
Files changed (2) hide show
  1. app.ipynb +88 -31
  2. app.py +9 -9
app.ipynb CHANGED
@@ -9,7 +9,7 @@
9
  "name": "stderr",
10
  "output_type": "stream",
11
  "text": [
12
- "c:\\Users\\USER\\Desktop\\WorkSpace\\MasterCourse\\scripts\\capstone project 2\\Shoe-Recognizer\\.venv\\lib\\site-packages\\tqdm\\auto.py:21: TqdmWarning: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html\n",
13
  " from .autonotebook import tqdm as notebook_tqdm\n"
14
  ]
15
  }
@@ -22,18 +22,18 @@
22
  },
23
  {
24
  "cell_type": "code",
25
- "execution_count": 2,
26
  "metadata": {},
27
  "outputs": [],
28
  "source": [
29
- "import pathlib\n",
30
- "temp = pathlib.PosixPath\n",
31
- "pathlib.PosixPath = pathlib.WindowsPath"
32
  ]
33
  },
34
  {
35
  "cell_type": "code",
36
- "execution_count": 3,
37
  "metadata": {},
38
  "outputs": [],
39
  "source": [
@@ -42,7 +42,7 @@
42
  },
43
  {
44
  "cell_type": "code",
45
- "execution_count": 4,
46
  "metadata": {},
47
  "outputs": [],
48
  "source": [
@@ -94,7 +94,7 @@
94
  },
95
  {
96
  "cell_type": "code",
97
- "execution_count": 5,
98
  "metadata": {},
99
  "outputs": [
100
  {
@@ -105,20 +105,20 @@
105
  "PILImage mode=RGB size=192x192"
106
  ]
107
  },
108
- "execution_count": 5,
109
  "metadata": {},
110
  "output_type": "execute_result"
111
  }
112
  ],
113
  "source": [
114
- "img = PILImage.create(f'test image\\image-01.jpg')\n",
115
  "img.thumbnail((192,192))\n",
116
  "img"
117
  ]
118
  },
119
  {
120
  "cell_type": "code",
121
- "execution_count": 6,
122
  "metadata": {},
123
  "outputs": [
124
  {
@@ -150,7 +150,14 @@
150
  },
151
  {
152
  "data": {
153
- "text/html": [],
 
 
 
 
 
 
 
154
  "text/plain": [
155
  "<IPython.core.display.HTML object>"
156
  ]
@@ -211,7 +218,7 @@
211
  " 'Wellington boots': 0.0001394600694766268}"
212
  ]
213
  },
214
- "execution_count": 6,
215
  "metadata": {},
216
  "output_type": "execute_result"
217
  }
@@ -222,20 +229,20 @@
222
  },
223
  {
224
  "cell_type": "code",
225
- "execution_count": 7,
226
  "metadata": {},
227
  "outputs": [
228
  {
229
  "name": "stderr",
230
  "output_type": "stream",
231
  "text": [
232
- "C:\\Users\\USER\\AppData\\Local\\Temp\\ipykernel_21356\\2721801947.py:1: GradioDeprecationWarning: Usage of gradio.inputs is deprecated, and will not be supported in the future, please import your component from gradio.components\n",
233
  " image = gr.inputs.Image(shape=(192,192))\n",
234
- "C:\\Users\\USER\\AppData\\Local\\Temp\\ipykernel_21356\\2721801947.py:1: GradioDeprecationWarning: `optional` parameter is deprecated, and it has no effect\n",
235
  " image = gr.inputs.Image(shape=(192,192))\n",
236
- "C:\\Users\\USER\\AppData\\Local\\Temp\\ipykernel_21356\\2721801947.py:2: GradioDeprecationWarning: Usage of gradio.outputs is deprecated, and will not be supported in the future, please import your components from gradio.components\n",
237
  " label = gr.outputs.Label()\n",
238
- "C:\\Users\\USER\\AppData\\Local\\Temp\\ipykernel_21356\\2721801947.py:2: GradioUnusedKwargWarning: You have unused kwarg parameters in Label, please remove them: {'type': 'auto'}\n",
239
  " label = gr.outputs.Label()\n"
240
  ]
241
  },
@@ -243,36 +250,86 @@
243
  "name": "stdout",
244
  "output_type": "stream",
245
  "text": [
246
- "Running on local URL: http://127.0.0.1:7865\n",
 
247
  "\n",
248
- "To create a public link, set `share=True` in `launch()`.\n"
249
  ]
250
  },
251
  {
252
  "data": {
253
  "text/plain": []
254
  },
255
- "execution_count": 7,
256
  "metadata": {},
257
  "output_type": "execute_result"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
258
  }
259
  ],
260
  "source": [
261
  "image = gr.inputs.Image(shape=(192,192))\n",
262
- "label = gr.outputs.Label()\n",
263
  "examples = [\n",
264
- " 'test image\\image-01.jpg',\n",
265
- " 'test image\\image-02.jpg',\n",
266
- " 'test image\\image-03.jpg',\n",
267
- " 'test image\\image-06.jpg',\n",
268
- " 'test image\\image-07.jpg',\n",
269
- " 'test image\\image-08.jpg',\n",
270
- " 'test image\\image-09.jpg',\n",
271
- " 'test image\\image-10.jpg' \n",
272
  " ]\n",
273
  "\n",
274
  "iface = gr.Interface(fn=recognize_image, inputs=image, outputs=label, examples=examples)\n",
275
- "iface.launch(inline=False)"
276
  ]
277
  },
278
  {
 
9
  "name": "stderr",
10
  "output_type": "stream",
11
  "text": [
12
+ "c:\\Users\\USER\\Desktop\\WorkSpace\\MasterCourse\\scripts\\capstone project 2\\Shoe-Type-Recognizer\\.venv\\lib\\site-packages\\tqdm\\auto.py:21: TqdmWarning: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html\n",
13
  " from .autonotebook import tqdm as notebook_tqdm\n"
14
  ]
15
  }
 
22
  },
23
  {
24
  "cell_type": "code",
25
+ "execution_count": 3,
26
  "metadata": {},
27
  "outputs": [],
28
  "source": [
29
+ "# import pathlib\n",
30
+ "# temp = pathlib.PosixPath\n",
31
+ "# pathlib.PosixPath = pathlib.WindowsPath"
32
  ]
33
  },
34
  {
35
  "cell_type": "code",
36
+ "execution_count": 4,
37
  "metadata": {},
38
  "outputs": [],
39
  "source": [
 
42
  },
43
  {
44
  "cell_type": "code",
45
+ "execution_count": 6,
46
  "metadata": {},
47
  "outputs": [],
48
  "source": [
 
94
  },
95
  {
96
  "cell_type": "code",
97
+ "execution_count": 8,
98
  "metadata": {},
99
  "outputs": [
100
  {
 
105
  "PILImage mode=RGB size=192x192"
106
  ]
107
  },
108
+ "execution_count": 8,
109
  "metadata": {},
110
  "output_type": "execute_result"
111
  }
112
  ],
113
  "source": [
114
+ "img = PILImage.create(f'test_image\\image-01.jpg')\n",
115
  "img.thumbnail((192,192))\n",
116
  "img"
117
  ]
118
  },
119
  {
120
  "cell_type": "code",
121
+ "execution_count": 9,
122
  "metadata": {},
123
  "outputs": [
124
  {
 
150
  },
151
  {
152
  "data": {
153
+ "text/html": [
154
+ "\n",
155
+ " <div>\n",
156
+ " <progress value='0' class='' max='1' style='width:300px; height:20px; vertical-align: middle;'></progress>\n",
157
+ " 0.00% [0/1 00:00&lt;?]\n",
158
+ " </div>\n",
159
+ " "
160
+ ],
161
  "text/plain": [
162
  "<IPython.core.display.HTML object>"
163
  ]
 
218
  " 'Wellington boots': 0.0001394600694766268}"
219
  ]
220
  },
221
+ "execution_count": 9,
222
  "metadata": {},
223
  "output_type": "execute_result"
224
  }
 
229
  },
230
  {
231
  "cell_type": "code",
232
+ "execution_count": null,
233
  "metadata": {},
234
  "outputs": [
235
  {
236
  "name": "stderr",
237
  "output_type": "stream",
238
  "text": [
239
+ "C:\\Users\\USER\\AppData\\Local\\Temp\\ipykernel_22668\\1824898195.py:1: GradioDeprecationWarning: Usage of gradio.inputs is deprecated, and will not be supported in the future, please import your component from gradio.components\n",
240
  " image = gr.inputs.Image(shape=(192,192))\n",
241
+ "C:\\Users\\USER\\AppData\\Local\\Temp\\ipykernel_22668\\1824898195.py:1: GradioDeprecationWarning: `optional` parameter is deprecated, and it has no effect\n",
242
  " image = gr.inputs.Image(shape=(192,192))\n",
243
+ "C:\\Users\\USER\\AppData\\Local\\Temp\\ipykernel_22668\\1824898195.py:2: GradioDeprecationWarning: Usage of gradio.outputs is deprecated, and will not be supported in the future, please import your components from gradio.components\n",
244
  " label = gr.outputs.Label()\n",
245
+ "C:\\Users\\USER\\AppData\\Local\\Temp\\ipykernel_22668\\1824898195.py:2: GradioUnusedKwargWarning: You have unused kwarg parameters in Label, please remove them: {'type': 'auto'}\n",
246
  " label = gr.outputs.Label()\n"
247
  ]
248
  },
 
250
  "name": "stdout",
251
  "output_type": "stream",
252
  "text": [
253
+ "Running on local URL: http://127.0.0.1:7861\n",
254
+ "Running on public URL: https://a7cb50ceef6c9d116c.gradio.live\n",
255
  "\n",
256
+ "This share link expires in 72 hours. For free permanent hosting and GPU upgrades, run `gradio deploy` from Terminal to deploy to Spaces (https://huggingface.co/spaces)\n"
257
  ]
258
  },
259
  {
260
  "data": {
261
  "text/plain": []
262
  },
263
+ "execution_count": 11,
264
  "metadata": {},
265
  "output_type": "execute_result"
266
+ },
267
+ {
268
+ "data": {
269
+ "text/html": [
270
+ "\n",
271
+ "<style>\n",
272
+ " /* Turns off some styling */\n",
273
+ " progress {\n",
274
+ " /* gets rid of default border in Firefox and Opera. */\n",
275
+ " border: none;\n",
276
+ " /* Needs to be in here for Safari polyfill so background images work as expected. */\n",
277
+ " background-size: auto;\n",
278
+ " }\n",
279
+ " progress:not([value]), progress:not([value])::-webkit-progress-bar {\n",
280
+ " background: repeating-linear-gradient(45deg, #7e7e7e, #7e7e7e 10px, #5c5c5c 10px, #5c5c5c 20px);\n",
281
+ " }\n",
282
+ " .progress-bar-interrupted, .progress-bar-interrupted::-webkit-progress-bar {\n",
283
+ " background: #F44336;\n",
284
+ " }\n",
285
+ "</style>\n"
286
+ ],
287
+ "text/plain": [
288
+ "<IPython.core.display.HTML object>"
289
+ ]
290
+ },
291
+ "metadata": {},
292
+ "output_type": "display_data"
293
+ },
294
+ {
295
+ "data": {
296
+ "text/html": [],
297
+ "text/plain": [
298
+ "<IPython.core.display.HTML object>"
299
+ ]
300
+ },
301
+ "metadata": {},
302
+ "output_type": "display_data"
303
+ },
304
+ {
305
+ "name": "stdout",
306
+ "output_type": "stream",
307
+ "text": [
308
+ "Chelsea Boot tensor([2.8313e-09, 1.1816e-09, 1.1724e-09, 5.0766e-09, 9.9998e-01, 7.6291e-09,\n",
309
+ " 1.5612e-07, 9.6842e-09, 7.2088e-09, 2.4661e-06, 1.6966e-08, 3.8857e-09,\n",
310
+ " 3.3738e-09, 3.4043e-08, 5.0392e-08, 2.8798e-09, 2.9660e-08, 2.4957e-10,\n",
311
+ " 7.2471e-09, 6.1177e-08, 3.9857e-07, 2.8386e-08, 1.3976e-07, 4.7899e-08,\n",
312
+ " 1.5551e-07, 1.4751e-07, 8.1831e-09, 2.6884e-08, 6.7308e-08, 1.9121e-08,\n",
313
+ " 8.1125e-08, 7.5008e-09, 1.8775e-08, 9.6297e-09, 3.3383e-06, 1.1778e-05])\n"
314
+ ]
315
  }
316
  ],
317
  "source": [
318
  "image = gr.inputs.Image(shape=(192,192))\n",
319
+ "label = gr.outputs.Label(num_top_classes=5)\n",
320
  "examples = [\n",
321
+ " 'test_image\\image-01.jpg',\n",
322
+ " 'test_image\\image-02.jpg',\n",
323
+ " 'test_image\\image-03.jpg',\n",
324
+ " 'test_image\\image-06.jpg',\n",
325
+ " 'test_image\\image-07.jpg',\n",
326
+ " 'test_image\\image-08.jpg',\n",
327
+ " 'test_image\\image-09.jpg',\n",
328
+ " 'test_image\\image-10.jpg' \n",
329
  " ]\n",
330
  "\n",
331
  "iface = gr.Interface(fn=recognize_image, inputs=image, outputs=label, examples=examples)\n",
332
+ "iface.launch(inline=False, share=True)"
333
  ]
334
  },
335
  {
app.py CHANGED
@@ -50,16 +50,16 @@ def recognize_image(image):
50
  return dict(zip(shoe_labels, map(float, probs)))
51
 
52
  image = gr.inputs.Image(shape=(192,192))
53
- label = gr.outputs.Label()
54
  examples = [
55
- 'test image\image-01.jpg',
56
- 'test image\image-02.jpg',
57
- 'test image\image-03.jpg',
58
- 'test image\image-06.jpg',
59
- 'test image\image-07.jpg',
60
- 'test image\image-08.jpg',
61
- 'test image\image-09.jpg',
62
- 'test image\image-10.jpg'
63
  ]
64
 
65
  iface = gr.Interface(fn=recognize_image, inputs=image, outputs=label, examples=examples)
 
50
  return dict(zip(shoe_labels, map(float, probs)))
51
 
52
  image = gr.inputs.Image(shape=(192,192))
53
+ label = gr.outputs.Label(num_top_classes=5)
54
  examples = [
55
+ 'test_image\image-01.jpg',
56
+ 'test_image\image-02.jpg',
57
+ 'test_image\image-03.jpg',
58
+ 'test_image\image-06.jpg',
59
+ 'test_image\image-07.jpg',
60
+ 'test_image\image-08.jpg',
61
+ 'test_image\image-09.jpg',
62
+ 'test_image\image-10.jpg'
63
  ]
64
 
65
  iface = gr.Interface(fn=recognize_image, inputs=image, outputs=label, examples=examples)