Spaces:
Runtime error
Runtime error
Ryan Lee
commited on
Commit
·
2a9a2bf
1
Parent(s):
c0de0b3
new start
Browse files- .DS_Store +0 -0
- .ipynb_checkpoints/app-checkpoint.ipynb +33 -0
- app.ipynb +33 -0
- app/app.py +0 -24
.DS_Store
ADDED
|
Binary file (6.15 kB). View file
|
|
|
.ipynb_checkpoints/app-checkpoint.ipynb
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"cells": [
|
| 3 |
+
{
|
| 4 |
+
"cell_type": "code",
|
| 5 |
+
"execution_count": null,
|
| 6 |
+
"id": "6725f79d",
|
| 7 |
+
"metadata": {},
|
| 8 |
+
"outputs": [],
|
| 9 |
+
"source": []
|
| 10 |
+
}
|
| 11 |
+
],
|
| 12 |
+
"metadata": {
|
| 13 |
+
"kernelspec": {
|
| 14 |
+
"display_name": "Python 3 (ipykernel)",
|
| 15 |
+
"language": "python",
|
| 16 |
+
"name": "python3"
|
| 17 |
+
},
|
| 18 |
+
"language_info": {
|
| 19 |
+
"codemirror_mode": {
|
| 20 |
+
"name": "ipython",
|
| 21 |
+
"version": 3
|
| 22 |
+
},
|
| 23 |
+
"file_extension": ".py",
|
| 24 |
+
"mimetype": "text/x-python",
|
| 25 |
+
"name": "python",
|
| 26 |
+
"nbconvert_exporter": "python",
|
| 27 |
+
"pygments_lexer": "ipython3",
|
| 28 |
+
"version": "3.10.9"
|
| 29 |
+
}
|
| 30 |
+
},
|
| 31 |
+
"nbformat": 4,
|
| 32 |
+
"nbformat_minor": 5
|
| 33 |
+
}
|
app.ipynb
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"cells": [
|
| 3 |
+
{
|
| 4 |
+
"cell_type": "code",
|
| 5 |
+
"execution_count": null,
|
| 6 |
+
"id": "6725f79d",
|
| 7 |
+
"metadata": {},
|
| 8 |
+
"outputs": [],
|
| 9 |
+
"source": []
|
| 10 |
+
}
|
| 11 |
+
],
|
| 12 |
+
"metadata": {
|
| 13 |
+
"kernelspec": {
|
| 14 |
+
"display_name": "Python 3 (ipykernel)",
|
| 15 |
+
"language": "python",
|
| 16 |
+
"name": "python3"
|
| 17 |
+
},
|
| 18 |
+
"language_info": {
|
| 19 |
+
"codemirror_mode": {
|
| 20 |
+
"name": "ipython",
|
| 21 |
+
"version": 3
|
| 22 |
+
},
|
| 23 |
+
"file_extension": ".py",
|
| 24 |
+
"mimetype": "text/x-python",
|
| 25 |
+
"name": "python",
|
| 26 |
+
"nbconvert_exporter": "python",
|
| 27 |
+
"pygments_lexer": "ipython3",
|
| 28 |
+
"version": "3.10.9"
|
| 29 |
+
}
|
| 30 |
+
},
|
| 31 |
+
"nbformat": 4,
|
| 32 |
+
"nbformat_minor": 5
|
| 33 |
+
}
|
app/app.py
DELETED
|
@@ -1,24 +0,0 @@
|
|
| 1 |
-
# AUTOGENERATED! DO NOT EDIT! File to edit: ../dogvcat_test.ipynb.
|
| 2 |
-
|
| 3 |
-
# %% auto 0
|
| 4 |
-
__all__ = ['learn', 'categories', 'image', 'label', 'examples', 'intf', 'classify_image']
|
| 5 |
-
|
| 6 |
-
# %% ../dogvcat_test.ipynb 2
|
| 7 |
-
learn = load_learner('model.pkl')
|
| 8 |
-
|
| 9 |
-
# %% ../dogvcat_test.ipynb 4
|
| 10 |
-
categories = ('Dog', 'Cat')
|
| 11 |
-
|
| 12 |
-
def classify_image(img):
|
| 13 |
-
pred,idx,probs = learn.predict(img)
|
| 14 |
-
#format the output of learn.predict. dict creates dictionary, zip associates the labels with the probabilities and map converts the tensor into a float
|
| 15 |
-
return dict(zip(categories, map(float,probs)))
|
| 16 |
-
|
| 17 |
-
# %% ../dogvcat_test.ipynb 6
|
| 18 |
-
image = gr.inputs.Image(shape=(192,192))
|
| 19 |
-
label = gr.outputs.Label()
|
| 20 |
-
examples = ['dog.jpeg', 'cat.jpg', 'dunno.jpeg']
|
| 21 |
-
|
| 22 |
-
intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples)
|
| 23 |
-
intf.launch(inline=False)
|
| 24 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|