flashfaster commited on
Commit
34fe474
·
1 Parent(s): e258662

Removed deprecated `inputs` and `outputs`

Browse files
Files changed (2) hide show
  1. app.py +2 -2
  2. pets.ipynb +93 -85
app.py CHANGED
@@ -25,8 +25,8 @@ def classify_image(img):
25
  return dict(zip(categories, map(float, probs)))
26
 
27
 
28
- image = gr.inputs.Image(shape=(192, 192))
29
- label = gr.outputs.Label()
30
  examples = ['dog.jpeg', 'cat.jpeg', 'wot.jpeg']
31
 
32
 
 
25
  return dict(zip(categories, map(float, probs)))
26
 
27
 
28
+ image = gr.Image(shape=(192, 192))
29
+ label = gr.Label()
30
  examples = ['dog.jpeg', 'cat.jpeg', 'wot.jpeg']
31
 
32
 
pets.ipynb CHANGED
@@ -9,7 +9,7 @@
9
  },
10
  {
11
  "cell_type": "code",
12
- "execution_count": 1,
13
  "metadata": {},
14
  "outputs": [],
15
  "source": [
@@ -24,7 +24,7 @@
24
  },
25
  {
26
  "cell_type": "code",
27
- "execution_count": 2,
28
  "metadata": {},
29
  "outputs": [
30
  {
@@ -35,7 +35,7 @@
35
  "PILImage mode=RGB size=192x108"
36
  ]
37
  },
38
- "execution_count": 2,
39
  "metadata": {},
40
  "output_type": "execute_result"
41
  }
@@ -48,7 +48,7 @@
48
  },
49
  {
50
  "cell_type": "code",
51
- "execution_count": 3,
52
  "metadata": {},
53
  "outputs": [],
54
  "source": [
@@ -58,7 +58,7 @@
58
  },
59
  {
60
  "cell_type": "code",
61
- "execution_count": 4,
62
  "metadata": {},
63
  "outputs": [
64
  {
@@ -104,7 +104,7 @@
104
  "('False', tensor(0), tensor([1.0000e+00, 9.8498e-07]))"
105
  ]
106
  },
107
- "execution_count": 4,
108
  "metadata": {},
109
  "output_type": "execute_result"
110
  }
@@ -115,7 +115,7 @@
115
  },
116
  {
117
  "cell_type": "code",
118
- "execution_count": 5,
119
  "metadata": {},
120
  "outputs": [],
121
  "source": [
@@ -129,7 +129,7 @@
129
  },
130
  {
131
  "cell_type": "code",
132
- "execution_count": 6,
133
  "metadata": {},
134
  "outputs": [
135
  {
@@ -161,7 +161,14 @@
161
  },
162
  {
163
  "data": {
164
- "text/html": [],
 
 
 
 
 
 
 
165
  "text/plain": [
166
  "<IPython.core.display.HTML object>"
167
  ]
@@ -175,7 +182,7 @@
175
  "{'Dog': 0.9999990463256836, 'Cat': 9.849827620200813e-07}"
176
  ]
177
  },
178
- "execution_count": 6,
179
  "metadata": {},
180
  "output_type": "execute_result"
181
  }
@@ -186,23 +193,9 @@
186
  },
187
  {
188
  "cell_type": "code",
189
- "execution_count": 9,
190
  "metadata": {},
191
  "outputs": [
192
- {
193
- "name": "stderr",
194
- "output_type": "stream",
195
- "text": [
196
- "/var/folders/23/fchp9d7d3zs1g2bfgb98hns80000gn/T/ipykernel_57597/1476562385.py:2: GradioDeprecationWarning: Usage of gradio.inputs is deprecated, and will not be supported in the future, please import your component from gradio.components\n",
197
- " image = gr.inputs.Image(shape=(192, 192))\n",
198
- "/var/folders/23/fchp9d7d3zs1g2bfgb98hns80000gn/T/ipykernel_57597/1476562385.py:2: GradioDeprecationWarning: `optional` parameter is deprecated, and it has no effect\n",
199
- " image = gr.inputs.Image(shape=(192, 192))\n",
200
- "/var/folders/23/fchp9d7d3zs1g2bfgb98hns80000gn/T/ipykernel_57597/1476562385.py:3: GradioDeprecationWarning: Usage of gradio.outputs is deprecated, and will not be supported in the future, please import your components from gradio.components\n",
201
- " label = gr.outputs.Label()\n",
202
- "/var/folders/23/fchp9d7d3zs1g2bfgb98hns80000gn/T/ipykernel_57597/1476562385.py:3: GradioUnusedKwargWarning: You have unused kwarg parameters in Label, please remove them: {'type': 'auto'}\n",
203
- " label = gr.outputs.Label()\n"
204
- ]
205
- },
206
  {
207
  "name": "stdout",
208
  "output_type": "stream",
@@ -216,74 +209,89 @@
216
  "data": {
217
  "text/plain": []
218
  },
219
- "execution_count": 9,
220
  "metadata": {},
221
  "output_type": "execute_result"
222
  },
223
  {
224
- "name": "stderr",
225
- "output_type": "stream",
226
- "text": [
227
- "Traceback (most recent call last):\n",
228
- " File \"/Users/nikhilb/fastai/course/pets/venv/lib/python3.11/site-packages/gradio/routes.py\", line 534, in predict\n",
229
- " output = await route_utils.call_process_api(\n",
230
- " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n",
231
- " File \"/Users/nikhilb/fastai/course/pets/venv/lib/python3.11/site-packages/gradio/route_utils.py\", line 226, in call_process_api\n",
232
- " output = await app.get_blocks().process_api(\n",
233
- " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n",
234
- " File \"/Users/nikhilb/fastai/course/pets/venv/lib/python3.11/site-packages/gradio/blocks.py\", line 1550, in process_api\n",
235
- " result = await self.call_function(\n",
236
- " ^^^^^^^^^^^^^^^^^^^^^^^^^\n",
237
- " File \"/Users/nikhilb/fastai/course/pets/venv/lib/python3.11/site-packages/gradio/blocks.py\", line 1185, in call_function\n",
238
- " prediction = await anyio.to_thread.run_sync(\n",
239
- " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n",
240
- " File \"/Users/nikhilb/fastai/course/pets/venv/lib/python3.11/site-packages/anyio/to_thread.py\", line 56, in run_sync\n",
241
- " return await get_async_backend().run_sync_in_worker_thread(\n",
242
- " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n",
243
- " File \"/Users/nikhilb/fastai/course/pets/venv/lib/python3.11/site-packages/anyio/_backends/_asyncio.py\", line 2144, in run_sync_in_worker_thread\n",
244
- " return await future\n",
245
- " ^^^^^^^^^^^^\n",
246
- " File \"/Users/nikhilb/fastai/course/pets/venv/lib/python3.11/site-packages/anyio/_backends/_asyncio.py\", line 851, in run\n",
247
- " result = context.run(func, *args)\n",
248
- " ^^^^^^^^^^^^^^^^^^^^^^^^\n",
249
- " File \"/Users/nikhilb/fastai/course/pets/venv/lib/python3.11/site-packages/gradio/utils.py\", line 661, in wrapper\n",
250
- " response = f(*args, **kwargs)\n",
251
- " ^^^^^^^^^^^^^^^^^^\n",
252
- " File \"/var/folders/23/fchp9d7d3zs1g2bfgb98hns80000gn/T/ipykernel_57597/2178911619.py\", line 5, in classify_image\n",
253
- " pred, idx, probs = learn.predict(img)\n",
254
- " ^^^^^^^^^^^^^^^^^^\n",
255
- " File \"/Users/nikhilb/fastai/course/pets/venv/lib/python3.11/site-packages/fastai/learner.py\", line 320, in predict\n",
256
- " dl = self.dls.test_dl([item], rm_type_tfms=rm_type_tfms, num_workers=0)\n",
257
- " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n",
258
- " File \"/Users/nikhilb/fastai/course/pets/venv/lib/python3.11/site-packages/fastai/data/core.py\", line 524, in test_dl\n",
259
- " test_ds = test_set(self.valid_ds, test_items, rm_tfms=rm_type_tfms, with_labels=with_labels\n",
260
- " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n",
261
- " File \"/Users/nikhilb/fastai/course/pets/venv/lib/python3.11/site-packages/fastai/data/core.py\", line 503, in test_set\n",
262
- " if rm_tfms is None: rm_tfms = [tl.infer_idx(get_first(test_items)) for tl in test_tls]\n",
263
- " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n",
264
- " File \"/Users/nikhilb/fastai/course/pets/venv/lib/python3.11/site-packages/fastai/data/core.py\", line 503, in <listcomp>\n",
265
- " if rm_tfms is None: rm_tfms = [tl.infer_idx(get_first(test_items)) for tl in test_tls]\n",
266
- " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n",
267
- " File \"/Users/nikhilb/fastai/course/pets/venv/lib/python3.11/site-packages/fastai/data/core.py\", line 397, in infer_idx\n",
268
- " assert idx < len(self.types), f\"Expected an input of type in \\n{pretty_types}\\n but got {type(x)}\"\n",
269
- " ^^^^^^^^^^^^^^^^^^^^^\n",
270
- "AssertionError: Expected an input of type in \n",
271
- " - <class 'pathlib.PosixPath'>\n",
272
- " - <class 'pathlib.Path'>\n",
273
- " - <class 'str'>\n",
274
- " - <class 'torch.Tensor'>\n",
275
- " - <class 'numpy.ndarray'>\n",
276
- " - <class 'bytes'>\n",
277
- " - <class 'PIL.Image.Image'>\n",
278
- " - <class 'fastai.vision.core.PILImage'>\n",
279
- " but got <class 'NoneType'>\n"
280
- ]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
281
  }
282
  ],
283
  "source": [
284
  "#|export\n",
285
- "image = gr.inputs.Image(shape=(192, 192))\n",
286
- "label = gr.outputs.Label()\n",
287
  "examples = ['dog.jpeg', 'cat.jpeg', 'wot.jpeg']\n",
288
  "\n",
289
  "\n",
 
9
  },
10
  {
11
  "cell_type": "code",
12
+ "execution_count": 5,
13
  "metadata": {},
14
  "outputs": [],
15
  "source": [
 
24
  },
25
  {
26
  "cell_type": "code",
27
+ "execution_count": 6,
28
  "metadata": {},
29
  "outputs": [
30
  {
 
35
  "PILImage mode=RGB size=192x108"
36
  ]
37
  },
38
+ "execution_count": 6,
39
  "metadata": {},
40
  "output_type": "execute_result"
41
  }
 
48
  },
49
  {
50
  "cell_type": "code",
51
+ "execution_count": 7,
52
  "metadata": {},
53
  "outputs": [],
54
  "source": [
 
58
  },
59
  {
60
  "cell_type": "code",
61
+ "execution_count": 8,
62
  "metadata": {},
63
  "outputs": [
64
  {
 
104
  "('False', tensor(0), tensor([1.0000e+00, 9.8498e-07]))"
105
  ]
106
  },
107
+ "execution_count": 8,
108
  "metadata": {},
109
  "output_type": "execute_result"
110
  }
 
115
  },
116
  {
117
  "cell_type": "code",
118
+ "execution_count": 9,
119
  "metadata": {},
120
  "outputs": [],
121
  "source": [
 
129
  },
130
  {
131
  "cell_type": "code",
132
+ "execution_count": 10,
133
  "metadata": {},
134
  "outputs": [
135
  {
 
161
  },
162
  {
163
  "data": {
164
+ "text/html": [
165
+ "\n",
166
+ " <div>\n",
167
+ " <progress value='0' class='' max='1' style='width:300px; height:20px; vertical-align: middle;'></progress>\n",
168
+ " 0.00% [0/1 00:00&lt;?]\n",
169
+ " </div>\n",
170
+ " "
171
+ ],
172
  "text/plain": [
173
  "<IPython.core.display.HTML object>"
174
  ]
 
182
  "{'Dog': 0.9999990463256836, 'Cat': 9.849827620200813e-07}"
183
  ]
184
  },
185
+ "execution_count": 10,
186
  "metadata": {},
187
  "output_type": "execute_result"
188
  }
 
193
  },
194
  {
195
  "cell_type": "code",
196
+ "execution_count": null,
197
  "metadata": {},
198
  "outputs": [
 
 
 
 
 
 
 
 
 
 
 
 
 
 
199
  {
200
  "name": "stdout",
201
  "output_type": "stream",
 
209
  "data": {
210
  "text/plain": []
211
  },
212
+ "execution_count": 11,
213
  "metadata": {},
214
  "output_type": "execute_result"
215
  },
216
  {
217
+ "data": {
218
+ "text/html": [
219
+ "\n",
220
+ "<style>\n",
221
+ " /* Turns off some styling */\n",
222
+ " progress {\n",
223
+ " /* gets rid of default border in Firefox and Opera. */\n",
224
+ " border: none;\n",
225
+ " /* Needs to be in here for Safari polyfill so background images work as expected. */\n",
226
+ " background-size: auto;\n",
227
+ " }\n",
228
+ " progress:not([value]), progress:not([value])::-webkit-progress-bar {\n",
229
+ " background: repeating-linear-gradient(45deg, #7e7e7e, #7e7e7e 10px, #5c5c5c 10px, #5c5c5c 20px);\n",
230
+ " }\n",
231
+ " .progress-bar-interrupted, .progress-bar-interrupted::-webkit-progress-bar {\n",
232
+ " background: #F44336;\n",
233
+ " }\n",
234
+ "</style>\n"
235
+ ],
236
+ "text/plain": [
237
+ "<IPython.core.display.HTML object>"
238
+ ]
239
+ },
240
+ "metadata": {},
241
+ "output_type": "display_data"
242
+ },
243
+ {
244
+ "data": {
245
+ "text/html": [],
246
+ "text/plain": [
247
+ "<IPython.core.display.HTML object>"
248
+ ]
249
+ },
250
+ "metadata": {},
251
+ "output_type": "display_data"
252
+ },
253
+ {
254
+ "data": {
255
+ "text/html": [
256
+ "\n",
257
+ "<style>\n",
258
+ " /* Turns off some styling */\n",
259
+ " progress {\n",
260
+ " /* gets rid of default border in Firefox and Opera. */\n",
261
+ " border: none;\n",
262
+ " /* Needs to be in here for Safari polyfill so background images work as expected. */\n",
263
+ " background-size: auto;\n",
264
+ " }\n",
265
+ " progress:not([value]), progress:not([value])::-webkit-progress-bar {\n",
266
+ " background: repeating-linear-gradient(45deg, #7e7e7e, #7e7e7e 10px, #5c5c5c 10px, #5c5c5c 20px);\n",
267
+ " }\n",
268
+ " .progress-bar-interrupted, .progress-bar-interrupted::-webkit-progress-bar {\n",
269
+ " background: #F44336;\n",
270
+ " }\n",
271
+ "</style>\n"
272
+ ],
273
+ "text/plain": [
274
+ "<IPython.core.display.HTML object>"
275
+ ]
276
+ },
277
+ "metadata": {},
278
+ "output_type": "display_data"
279
+ },
280
+ {
281
+ "data": {
282
+ "text/html": [],
283
+ "text/plain": [
284
+ "<IPython.core.display.HTML object>"
285
+ ]
286
+ },
287
+ "metadata": {},
288
+ "output_type": "display_data"
289
  }
290
  ],
291
  "source": [
292
  "#|export\n",
293
+ "image = gr.Image(shape=(192, 192))\n",
294
+ "label = gr.Label()\n",
295
  "examples = ['dog.jpeg', 'cat.jpeg', 'wot.jpeg']\n",
296
  "\n",
297
  "\n",