Spaces:
Sleeping
Sleeping
- test deploy 1
Browse files- .gitattributes +4 -0
- app.ipynb +134 -0
- app.py +14 -4
- giant_0.jpg +3 -0
- giant_1.jpg +3 -0
- model.pkl +3 -0
- red_0.jpg +3 -0
- red_1.jpg +3 -0
.gitattributes
CHANGED
@@ -33,3 +33,7 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
|
|
|
|
33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
36 |
+
giant_0.jpg filter=lfs diff=lfs merge=lfs -text
|
37 |
+
giant_1.jpg filter=lfs diff=lfs merge=lfs -text
|
38 |
+
red_0.jpg filter=lfs diff=lfs merge=lfs -text
|
39 |
+
red_1.jpg filter=lfs diff=lfs merge=lfs -text
|
app.ipynb
ADDED
@@ -0,0 +1,134 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"cells": [
|
3 |
+
{
|
4 |
+
"cell_type": "code",
|
5 |
+
"execution_count": null,
|
6 |
+
"metadata": {},
|
7 |
+
"outputs": [],
|
8 |
+
"source": [
|
9 |
+
"#| default_exp app"
|
10 |
+
]
|
11 |
+
},
|
12 |
+
{
|
13 |
+
"cell_type": "code",
|
14 |
+
"execution_count": 1,
|
15 |
+
"metadata": {},
|
16 |
+
"outputs": [
|
17 |
+
{
|
18 |
+
"name": "stderr",
|
19 |
+
"output_type": "stream",
|
20 |
+
"text": [
|
21 |
+
"d:\\miniconda3\\envs\\fai\\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",
|
22 |
+
" from .autonotebook import tqdm as notebook_tqdm\n"
|
23 |
+
]
|
24 |
+
}
|
25 |
+
],
|
26 |
+
"source": [
|
27 |
+
"#| export\n",
|
28 |
+
"from fastai.vision.all import *\n",
|
29 |
+
"import gradio as gr\n",
|
30 |
+
"\n",
|
31 |
+
"# def is_giant_panda(x): return x[0].isupper()"
|
32 |
+
]
|
33 |
+
},
|
34 |
+
{
|
35 |
+
"cell_type": "code",
|
36 |
+
"execution_count": 6,
|
37 |
+
"metadata": {},
|
38 |
+
"outputs": [],
|
39 |
+
"source": [
|
40 |
+
"im = PILImage.create('giant_0.jpg')\n",
|
41 |
+
"im = im.to_thumb(192)"
|
42 |
+
]
|
43 |
+
},
|
44 |
+
{
|
45 |
+
"cell_type": "code",
|
46 |
+
"execution_count": null,
|
47 |
+
"metadata": {},
|
48 |
+
"outputs": [],
|
49 |
+
"source": [
|
50 |
+
"#| export\n",
|
51 |
+
"learn = load_learner('model.pkl')"
|
52 |
+
]
|
53 |
+
},
|
54 |
+
{
|
55 |
+
"cell_type": "code",
|
56 |
+
"execution_count": null,
|
57 |
+
"metadata": {},
|
58 |
+
"outputs": [],
|
59 |
+
"source": [
|
60 |
+
"learn.predict(im)"
|
61 |
+
]
|
62 |
+
},
|
63 |
+
{
|
64 |
+
"cell_type": "code",
|
65 |
+
"execution_count": null,
|
66 |
+
"metadata": {},
|
67 |
+
"outputs": [],
|
68 |
+
"source": [
|
69 |
+
"#| export\n",
|
70 |
+
"categories = 'Giant panda', 'Red panda'\n",
|
71 |
+
"\n",
|
72 |
+
"def classify_image(img):\n",
|
73 |
+
" pred, idx, probs = learn.predict(img)\n",
|
74 |
+
" return dict(zip(categories, map(float, probs)))"
|
75 |
+
]
|
76 |
+
},
|
77 |
+
{
|
78 |
+
"cell_type": "code",
|
79 |
+
"execution_count": null,
|
80 |
+
"metadata": {},
|
81 |
+
"outputs": [],
|
82 |
+
"source": [
|
83 |
+
"classify_image(im)"
|
84 |
+
]
|
85 |
+
},
|
86 |
+
{
|
87 |
+
"cell_type": "code",
|
88 |
+
"execution_count": null,
|
89 |
+
"metadata": {},
|
90 |
+
"outputs": [],
|
91 |
+
"source": [
|
92 |
+
"#| export\n",
|
93 |
+
"image = gr.inputs.Image(shape=(192, 192))\n",
|
94 |
+
"label = gr.outputs.Label()\n",
|
95 |
+
"\n",
|
96 |
+
"examples = ['giant_0.jpg', 'red_0.jpg', 'giant_1.jpg', 'red_1.jpg']\n",
|
97 |
+
"interface = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples)\n",
|
98 |
+
"interface.launch(inline=False)"
|
99 |
+
]
|
100 |
+
},
|
101 |
+
{
|
102 |
+
"cell_type": "code",
|
103 |
+
"execution_count": null,
|
104 |
+
"metadata": {},
|
105 |
+
"outputs": [],
|
106 |
+
"source": [
|
107 |
+
"from nbdev.export import notebook2script\n",
|
108 |
+
"\n",
|
109 |
+
"notebook2script('app.ipynb')"
|
110 |
+
]
|
111 |
+
}
|
112 |
+
],
|
113 |
+
"metadata": {
|
114 |
+
"kernelspec": {
|
115 |
+
"display_name": "fai",
|
116 |
+
"language": "python",
|
117 |
+
"name": "python3"
|
118 |
+
},
|
119 |
+
"language_info": {
|
120 |
+
"codemirror_mode": {
|
121 |
+
"name": "ipython",
|
122 |
+
"version": 3
|
123 |
+
},
|
124 |
+
"file_extension": ".py",
|
125 |
+
"mimetype": "text/x-python",
|
126 |
+
"name": "python",
|
127 |
+
"nbconvert_exporter": "python",
|
128 |
+
"pygments_lexer": "ipython3",
|
129 |
+
"version": "3.11.8"
|
130 |
+
}
|
131 |
+
},
|
132 |
+
"nbformat": 4,
|
133 |
+
"nbformat_minor": 2
|
134 |
+
}
|
app.py
CHANGED
@@ -1,7 +1,17 @@
|
|
|
|
1 |
import gradio as gr
|
2 |
|
3 |
-
|
4 |
-
return "Hello " + name + "!!"
|
5 |
|
6 |
-
|
7 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from fastai.vision.all import *
|
2 |
import gradio as gr
|
3 |
|
4 |
+
categories = 'Giant panda', 'Red panda'
|
|
|
5 |
|
6 |
+
def classify_image(img):
|
7 |
+
pred, idx, probs = learn.predict(img)
|
8 |
+
return dict(zip(categories, map(float, probs)))
|
9 |
+
|
10 |
+
learn = load_learner('model.pkl')
|
11 |
+
|
12 |
+
image = gr.inputs.Image(shape=(192, 192))
|
13 |
+
label = gr.outputs.Label()
|
14 |
+
|
15 |
+
examples = ['giant_0.jpg', 'red_0.jpg', 'giant_1.jpg', 'red_1.jpg']
|
16 |
+
interface = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples)
|
17 |
+
interface.launch(inline=False)
|
giant_0.jpg
ADDED
Git LFS Details
|
giant_1.jpg
ADDED
Git LFS Details
|
model.pkl
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:d4baab030dd958a944a65758fc8848880ce0d0a96dbad1661ec9a17592ebc2ac
|
3 |
+
size 46964486
|
red_0.jpg
ADDED
Git LFS Details
|
red_1.jpg
ADDED
Git LFS Details
|