trtrgfh
commited on
Commit
·
64226e9
1
Parent(s):
83ea7ba
cutomize gardio app
Browse files- app.ipynb +29 -4
- app.py +11 -3
- flagged/img/tmpj8t3miuy.jpg +0 -0
- flagged/log.csv +2 -0
- flagged/output/tmpvesdv1ch.json +1 -0
- requirements.txt +2 -1
app.ipynb
CHANGED
|
@@ -191,9 +191,32 @@
|
|
| 191 |
"classify_image(im)"
|
| 192 |
]
|
| 193 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 194 |
{
|
| 195 |
"cell_type": "code",
|
| 196 |
"execution_count": 8,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 197 |
"id": "6ed6b1ad",
|
| 198 |
"metadata": {},
|
| 199 |
"outputs": [
|
|
@@ -208,6 +231,8 @@
|
|
| 208 |
"/home/yehao_ubuntu/mambaforge/lib/python3.10/site-packages/gradio/outputs.py:197: UserWarning: Usage of gradio.outputs is deprecated, and will not be supported in the future, please import your components from gradio.components\n",
|
| 209 |
" warnings.warn(\n",
|
| 210 |
"/home/yehao_ubuntu/mambaforge/lib/python3.10/site-packages/gradio/deprecation.py:40: UserWarning: The 'type' parameter has been deprecated. Use the Number component instead.\n",
|
|
|
|
|
|
|
| 211 |
" warnings.warn(value)\n"
|
| 212 |
]
|
| 213 |
},
|
|
@@ -215,7 +240,7 @@
|
|
| 215 |
"name": "stdout",
|
| 216 |
"output_type": "stream",
|
| 217 |
"text": [
|
| 218 |
-
"Running on local URL: http://127.0.0.1:
|
| 219 |
"\n",
|
| 220 |
"To create a public link, set `share=True` in `launch()`.\n"
|
| 221 |
]
|
|
@@ -224,7 +249,7 @@
|
|
| 224 |
"data": {
|
| 225 |
"text/plain": []
|
| 226 |
},
|
| 227 |
-
"execution_count":
|
| 228 |
"metadata": {},
|
| 229 |
"output_type": "execute_result"
|
| 230 |
}
|
|
@@ -235,7 +260,7 @@
|
|
| 235 |
"label = gr.outputs.Label()\n",
|
| 236 |
"examples = [\"dog1.jpg\", \"dog2.jpg\", \"dog3.jpg\", \"cat1.jpg\", \"cat2.jpg\"]\n",
|
| 237 |
"\n",
|
| 238 |
-
"intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples)\n",
|
| 239 |
"intf.launch(inline=False)"
|
| 240 |
]
|
| 241 |
},
|
|
@@ -249,7 +274,7 @@
|
|
| 249 |
},
|
| 250 |
{
|
| 251 |
"cell_type": "code",
|
| 252 |
-
"execution_count":
|
| 253 |
"id": "83142b64",
|
| 254 |
"metadata": {},
|
| 255 |
"outputs": [
|
|
|
|
| 191 |
"classify_image(im)"
|
| 192 |
]
|
| 193 |
},
|
| 194 |
+
{
|
| 195 |
+
"cell_type": "markdown",
|
| 196 |
+
"id": "491f209b",
|
| 197 |
+
"metadata": {},
|
| 198 |
+
"source": [
|
| 199 |
+
"# Customizing Gradio app"
|
| 200 |
+
]
|
| 201 |
+
},
|
| 202 |
{
|
| 203 |
"cell_type": "code",
|
| 204 |
"execution_count": 8,
|
| 205 |
+
"id": "03269867",
|
| 206 |
+
"metadata": {},
|
| 207 |
+
"outputs": [],
|
| 208 |
+
"source": [
|
| 209 |
+
"#|export\n",
|
| 210 |
+
"title = \"Cat or Dog Classifier\"\n",
|
| 211 |
+
"description = \"A Cat or Dog classifier trained on the Oxford Pets dataset with fastai. Created as a demo for Gradio and HuggingFace Spaces.\"\n",
|
| 212 |
+
"article=\"<p style='text-align: center'><a href='https://tmabraham.github.io/blog/gradio_hf_spaces_tutorial' target='_blank'>Blog post</a></p>\"\n",
|
| 213 |
+
"interpretation='default'\n",
|
| 214 |
+
"enable_queue=True"
|
| 215 |
+
]
|
| 216 |
+
},
|
| 217 |
+
{
|
| 218 |
+
"cell_type": "code",
|
| 219 |
+
"execution_count": 9,
|
| 220 |
"id": "6ed6b1ad",
|
| 221 |
"metadata": {},
|
| 222 |
"outputs": [
|
|
|
|
| 231 |
"/home/yehao_ubuntu/mambaforge/lib/python3.10/site-packages/gradio/outputs.py:197: UserWarning: Usage of gradio.outputs is deprecated, and will not be supported in the future, please import your components from gradio.components\n",
|
| 232 |
" warnings.warn(\n",
|
| 233 |
"/home/yehao_ubuntu/mambaforge/lib/python3.10/site-packages/gradio/deprecation.py:40: UserWarning: The 'type' parameter has been deprecated. Use the Number component instead.\n",
|
| 234 |
+
" warnings.warn(value)\n",
|
| 235 |
+
"/home/yehao_ubuntu/mambaforge/lib/python3.10/site-packages/gradio/deprecation.py:40: UserWarning: `enable_queue` is deprecated in `Interface()`, please use it within `launch()` instead.\n",
|
| 236 |
" warnings.warn(value)\n"
|
| 237 |
]
|
| 238 |
},
|
|
|
|
| 240 |
"name": "stdout",
|
| 241 |
"output_type": "stream",
|
| 242 |
"text": [
|
| 243 |
+
"Running on local URL: http://127.0.0.1:7860\n",
|
| 244 |
"\n",
|
| 245 |
"To create a public link, set `share=True` in `launch()`.\n"
|
| 246 |
]
|
|
|
|
| 249 |
"data": {
|
| 250 |
"text/plain": []
|
| 251 |
},
|
| 252 |
+
"execution_count": 9,
|
| 253 |
"metadata": {},
|
| 254 |
"output_type": "execute_result"
|
| 255 |
}
|
|
|
|
| 260 |
"label = gr.outputs.Label()\n",
|
| 261 |
"examples = [\"dog1.jpg\", \"dog2.jpg\", \"dog3.jpg\", \"cat1.jpg\", \"cat2.jpg\"]\n",
|
| 262 |
"\n",
|
| 263 |
+
"intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples, title=title, description=description, article=article, interpretation=interpretation, enable_queue=enable_queue)\n",
|
| 264 |
"intf.launch(inline=False)"
|
| 265 |
]
|
| 266 |
},
|
|
|
|
| 274 |
},
|
| 275 |
{
|
| 276 |
"cell_type": "code",
|
| 277 |
+
"execution_count": 10,
|
| 278 |
"id": "83142b64",
|
| 279 |
"metadata": {},
|
| 280 |
"outputs": [
|
app.py
CHANGED
|
@@ -1,7 +1,8 @@
|
|
| 1 |
# AUTOGENERATED! DO NOT EDIT! File to edit: app.ipynb.
|
| 2 |
|
| 3 |
# %% auto 0
|
| 4 |
-
__all__ = ['learn', 'categories', '
|
|
|
|
| 5 |
|
| 6 |
# %% app.ipynb 1
|
| 7 |
from fastai.vision.all import *
|
|
@@ -20,10 +21,17 @@ def classify_image(img):
|
|
| 20 |
pred, idx, probs = learn.predict(img)
|
| 21 |
return dict(zip(categories, map(float, probs)))
|
| 22 |
|
| 23 |
-
# %% app.ipynb
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 24 |
image = gr.inputs.Image(shape=(192, 192))
|
| 25 |
label = gr.outputs.Label()
|
| 26 |
examples = ["dog1.jpg", "dog2.jpg", "dog3.jpg", "cat1.jpg", "cat2.jpg"]
|
| 27 |
|
| 28 |
-
intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples)
|
| 29 |
intf.launch(inline=False)
|
|
|
|
| 1 |
# AUTOGENERATED! DO NOT EDIT! File to edit: app.ipynb.
|
| 2 |
|
| 3 |
# %% auto 0
|
| 4 |
+
__all__ = ['learn', 'categories', 'title', 'description', 'article', 'interpretation', 'enable_queue', 'image', 'label',
|
| 5 |
+
'examples', 'intf', 'is_cat', 'classify_image']
|
| 6 |
|
| 7 |
# %% app.ipynb 1
|
| 8 |
from fastai.vision.all import *
|
|
|
|
| 21 |
pred, idx, probs = learn.predict(img)
|
| 22 |
return dict(zip(categories, map(float, probs)))
|
| 23 |
|
| 24 |
+
# %% app.ipynb 8
|
| 25 |
+
title = "Cat or Dog Classifier"
|
| 26 |
+
description = "A Cat or Dog classifier trained on the Oxford Pets dataset with fastai. Created as a demo for Gradio and HuggingFace Spaces."
|
| 27 |
+
article="<p style='text-align: center'><a href='https://tmabraham.github.io/blog/gradio_hf_spaces_tutorial' target='_blank'>Blog post</a></p>"
|
| 28 |
+
interpretation='default'
|
| 29 |
+
enable_queue=True
|
| 30 |
+
|
| 31 |
+
# %% app.ipynb 9
|
| 32 |
image = gr.inputs.Image(shape=(192, 192))
|
| 33 |
label = gr.outputs.Label()
|
| 34 |
examples = ["dog1.jpg", "dog2.jpg", "dog3.jpg", "cat1.jpg", "cat2.jpg"]
|
| 35 |
|
| 36 |
+
intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples, title=title, description=description, article=article, interpretation=interpretation, enable_queue=enable_queue)
|
| 37 |
intf.launch(inline=False)
|
flagged/img/tmpj8t3miuy.jpg
ADDED
|
flagged/log.csv
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
img,output,flag,username,timestamp
|
| 2 |
+
/home/yehao_ubuntu/testing2/flagged/img/tmpj8t3miuy.jpg,/home/yehao_ubuntu/testing2/flagged/output/tmpvesdv1ch.json,,,2023-04-22 22:44:25.804158
|
flagged/output/tmpvesdv1ch.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"label": "Cat", "confidences": [{"label": "Cat", "confidence": 1}, {"label": "Dog", "confidence": 2.119180919635255e-08}]}
|
requirements.txt
CHANGED
|
@@ -2,4 +2,5 @@ fastai
|
|
| 2 |
torch
|
| 3 |
gradio
|
| 4 |
numpy
|
| 5 |
-
pandas
|
|
|
|
|
|
| 2 |
torch
|
| 3 |
gradio
|
| 4 |
numpy
|
| 5 |
+
pandas
|
| 6 |
+
scikit-image
|