Spaces:
Runtime error
Runtime error
fix blogpost site
Browse files- .ipynb_checkpoints/train-checkpoint.ipynb +94 -10
- train.ipynb +26 -164
.ipynb_checkpoints/train-checkpoint.ipynb
CHANGED
@@ -18,17 +18,18 @@
|
|
18 |
},
|
19 |
{
|
20 |
"cell_type": "code",
|
21 |
-
"execution_count":
|
22 |
"id": "ef4ffc95-6051-4354-af16-25477b279657",
|
23 |
"metadata": {},
|
24 |
"outputs": [],
|
25 |
"source": [
|
|
|
26 |
"learn = load_learner('export.pkl')"
|
27 |
]
|
28 |
},
|
29 |
{
|
30 |
"cell_type": "code",
|
31 |
-
"execution_count":
|
32 |
"id": "49289d4b-7e8c-4264-bb03-8a0d851caf1c",
|
33 |
"metadata": {},
|
34 |
"outputs": [],
|
@@ -42,7 +43,7 @@
|
|
42 |
},
|
43 |
{
|
44 |
"cell_type": "code",
|
45 |
-
"execution_count":
|
46 |
"id": "a6b53fe8-ded5-4048-afd7-e488dc884aec",
|
47 |
"metadata": {},
|
48 |
"outputs": [
|
@@ -50,43 +51,126 @@
|
|
50 |
"name": "stdout",
|
51 |
"output_type": "stream",
|
52 |
"text": [
|
|
|
53 |
"american_pit_bull_terrier_52.jpg\n",
|
54 |
"staffordshire_bull_terrier_129.jpg\n",
|
55 |
"wheaten_terrier_138.jpg\n",
|
56 |
-
"
|
|
|
57 |
"yorkshire_terrier_189.jpg\n",
|
58 |
"Abyssinian_67.jpg\n",
|
|
|
59 |
"basset_hound_12.jpg\n",
|
60 |
"american_bulldog_24.jpg\n",
|
|
|
|
|
61 |
"beagle_120.jpg\n",
|
62 |
"staffordshire_bull_terrier_173.jpg\n",
|
63 |
"beagle_125.jpg\n",
|
|
|
64 |
"Bengal_21.jpg\n",
|
|
|
|
|
65 |
"basset_hound_17.jpg\n",
|
66 |
-
"
|
67 |
"Abyssinian_7.jpg\n",
|
|
|
|
|
68 |
"american_bulldog_83.jpg\n",
|
69 |
"Birman_103.jpg\n",
|
|
|
70 |
"Bengal_19.jpg\n",
|
71 |
"american_pit_bull_terrier_76.jpg\n",
|
72 |
"yorkshire_terrier_196.jpg\n",
|
73 |
-
"wheaten_terrier_137.jpg\n"
|
|
|
74 |
]
|
75 |
}
|
76 |
],
|
77 |
"source": [
|
78 |
"import os\n",
|
79 |
-
"for root, dirs, files in os.walk(r'
|
80 |
" for filename in files:\n",
|
81 |
" print(filename)"
|
82 |
]
|
83 |
},
|
84 |
{
|
85 |
"cell_type": "code",
|
86 |
-
"execution_count":
|
87 |
"id": "62fe5dc0-5fd1-4cc7-af8d-a325e3915173",
|
88 |
"metadata": {},
|
89 |
-
"outputs": [
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
90 |
"source": [
|
91 |
"import gradio as gr\n",
|
92 |
"\n",
|
@@ -94,7 +178,7 @@
|
|
94 |
"description = \"A pet breed classifier trained on the Oxford Pets dataset\"\n",
|
95 |
"interpretation='default'\n",
|
96 |
"# examples = ['siamese.jpg', 'kitten.jpg']\n",
|
97 |
-
"examples = files\n",
|
98 |
"article=\"<p style='text-align: center'><a href='https://dicksonneoh.com' target='_blank'>Blog post</a></p>\"\n",
|
99 |
"enable_queue=True\n",
|
100 |
"\n",
|
|
|
18 |
},
|
19 |
{
|
20 |
"cell_type": "code",
|
21 |
+
"execution_count": 4,
|
22 |
"id": "ef4ffc95-6051-4354-af16-25477b279657",
|
23 |
"metadata": {},
|
24 |
"outputs": [],
|
25 |
"source": [
|
26 |
+
"from fastai.vision.all import *\n",
|
27 |
"learn = load_learner('export.pkl')"
|
28 |
]
|
29 |
},
|
30 |
{
|
31 |
"cell_type": "code",
|
32 |
+
"execution_count": 5,
|
33 |
"id": "49289d4b-7e8c-4264-bb03-8a0d851caf1c",
|
34 |
"metadata": {},
|
35 |
"outputs": [],
|
|
|
43 |
},
|
44 |
{
|
45 |
"cell_type": "code",
|
46 |
+
"execution_count": 18,
|
47 |
"id": "a6b53fe8-ded5-4048-afd7-e488dc884aec",
|
48 |
"metadata": {},
|
49 |
"outputs": [
|
|
|
51 |
"name": "stdout",
|
52 |
"output_type": "stream",
|
53 |
"text": [
|
54 |
+
"Bombay_19.jpg\n",
|
55 |
"american_pit_bull_terrier_52.jpg\n",
|
56 |
"staffordshire_bull_terrier_129.jpg\n",
|
57 |
"wheaten_terrier_138.jpg\n",
|
58 |
+
"Egyptian_Mau_57.jpg\n",
|
59 |
+
"chihuahua_93.jpg\n",
|
60 |
"yorkshire_terrier_189.jpg\n",
|
61 |
"Abyssinian_67.jpg\n",
|
62 |
+
"Egyptian_Mau_63.jpg\n",
|
63 |
"basset_hound_12.jpg\n",
|
64 |
"american_bulldog_24.jpg\n",
|
65 |
+
"Bengal_109.jpg\n",
|
66 |
+
"British_Shorthair_57.jpg\n",
|
67 |
"beagle_120.jpg\n",
|
68 |
"staffordshire_bull_terrier_173.jpg\n",
|
69 |
"beagle_125.jpg\n",
|
70 |
+
"Birman_113.jpg\n",
|
71 |
"Bengal_21.jpg\n",
|
72 |
+
"British_Shorthair_61.jpg\n",
|
73 |
+
"Bombay_25.jpg\n",
|
74 |
"basset_hound_17.jpg\n",
|
75 |
+
"Abyssinian_29.jpg\n",
|
76 |
"Abyssinian_7.jpg\n",
|
77 |
+
"Bengal_108.jpg\n",
|
78 |
+
"Abyssinian_27.jpg\n",
|
79 |
"american_bulldog_83.jpg\n",
|
80 |
"Birman_103.jpg\n",
|
81 |
+
"chihuahua_94.jpg\n",
|
82 |
"Bengal_19.jpg\n",
|
83 |
"american_pit_bull_terrier_76.jpg\n",
|
84 |
"yorkshire_terrier_196.jpg\n",
|
85 |
+
"wheaten_terrier_137.jpg\n",
|
86 |
+
"Birman_120.jpg\n"
|
87 |
]
|
88 |
}
|
89 |
],
|
90 |
"source": [
|
91 |
"import os\n",
|
92 |
+
"for root, dirs, files in os.walk(r'sample_images/'):\n",
|
93 |
" for filename in files:\n",
|
94 |
" print(filename)"
|
95 |
]
|
96 |
},
|
97 |
{
|
98 |
"cell_type": "code",
|
99 |
+
"execution_count": 16,
|
100 |
"id": "62fe5dc0-5fd1-4cc7-af8d-a325e3915173",
|
101 |
"metadata": {},
|
102 |
+
"outputs": [
|
103 |
+
{
|
104 |
+
"name": "stdout",
|
105 |
+
"output_type": "stream",
|
106 |
+
"text": [
|
107 |
+
"Running on local URL: http://127.0.0.1:7864/\n",
|
108 |
+
"Running on public URL: https://45906.gradio.app\n",
|
109 |
+
"\n",
|
110 |
+
"This share link will expire in 72 hours. To get longer links, send an email to: [email protected]\n"
|
111 |
+
]
|
112 |
+
},
|
113 |
+
{
|
114 |
+
"data": {
|
115 |
+
"text/html": [
|
116 |
+
"\n",
|
117 |
+
" <iframe\n",
|
118 |
+
" width=\"900\"\n",
|
119 |
+
" height=\"500\"\n",
|
120 |
+
" src=\"https://45906.gradio.app\"\n",
|
121 |
+
" frameborder=\"0\"\n",
|
122 |
+
" allowfullscreen\n",
|
123 |
+
" \n",
|
124 |
+
" ></iframe>\n",
|
125 |
+
" "
|
126 |
+
],
|
127 |
+
"text/plain": [
|
128 |
+
"<IPython.lib.display.IFrame at 0x7f4be08c8dc0>"
|
129 |
+
]
|
130 |
+
},
|
131 |
+
"metadata": {},
|
132 |
+
"output_type": "display_data"
|
133 |
+
},
|
134 |
+
{
|
135 |
+
"data": {
|
136 |
+
"text/plain": [
|
137 |
+
"(<Flask 'gradio.networking'>,\n",
|
138 |
+
" 'http://127.0.0.1:7864/',\n",
|
139 |
+
" 'https://45906.gradio.app')"
|
140 |
+
]
|
141 |
+
},
|
142 |
+
"execution_count": 16,
|
143 |
+
"metadata": {},
|
144 |
+
"output_type": "execute_result"
|
145 |
+
},
|
146 |
+
{
|
147 |
+
"name": "stderr",
|
148 |
+
"output_type": "stream",
|
149 |
+
"text": [
|
150 |
+
"[2021-11-19 20:18:31,342] ERROR in app: Exception on /file/sample_images/staffordshire_bull_terrier_172.jpg [GET]\n",
|
151 |
+
"Traceback (most recent call last):\n",
|
152 |
+
" File \"/home/dnth/anaconda3/envs/gradio/lib/python3.8/site-packages/flask/app.py\", line 2073, in wsgi_app\n",
|
153 |
+
" response = self.full_dispatch_request()\n",
|
154 |
+
" File \"/home/dnth/anaconda3/envs/gradio/lib/python3.8/site-packages/flask/app.py\", line 1518, in full_dispatch_request\n",
|
155 |
+
" rv = self.handle_user_exception(e)\n",
|
156 |
+
" File \"/home/dnth/anaconda3/envs/gradio/lib/python3.8/site-packages/flask_cors/extension.py\", line 165, in wrapped_function\n",
|
157 |
+
" return cors_after_request(app.make_response(f(*args, **kwargs)))\n",
|
158 |
+
" File \"/home/dnth/anaconda3/envs/gradio/lib/python3.8/site-packages/flask/app.py\", line 1516, in full_dispatch_request\n",
|
159 |
+
" rv = self.dispatch_request()\n",
|
160 |
+
" File \"/home/dnth/anaconda3/envs/gradio/lib/python3.8/site-packages/flask/app.py\", line 1502, in dispatch_request\n",
|
161 |
+
" return self.ensure_sync(self.view_functions[rule.endpoint])(**req.view_args)\n",
|
162 |
+
" File \"/home/dnth/anaconda3/envs/gradio/lib/python3.8/site-packages/gradio/networking.py\", line 93, in wrapper\n",
|
163 |
+
" return func(*args, **kwargs)\n",
|
164 |
+
" File \"/home/dnth/anaconda3/envs/gradio/lib/python3.8/site-packages/gradio/networking.py\", line 386, in file\n",
|
165 |
+
" return send_file(os.path.join(app.cwd, path))\n",
|
166 |
+
" File \"/home/dnth/anaconda3/envs/gradio/lib/python3.8/site-packages/flask/helpers.py\", line 612, in send_file\n",
|
167 |
+
" return werkzeug.utils.send_file(\n",
|
168 |
+
" File \"/home/dnth/anaconda3/envs/gradio/lib/python3.8/site-packages/werkzeug/utils.py\", line 701, in send_file\n",
|
169 |
+
" stat = os.stat(path)\n",
|
170 |
+
"FileNotFoundError: [Errno 2] No such file or directory: '/home/dnth/Desktop/webdemos/webdemo-pets-classifier/sample_images/staffordshire_bull_terrier_172.jpg'\n"
|
171 |
+
]
|
172 |
+
}
|
173 |
+
],
|
174 |
"source": [
|
175 |
"import gradio as gr\n",
|
176 |
"\n",
|
|
|
178 |
"description = \"A pet breed classifier trained on the Oxford Pets dataset\"\n",
|
179 |
"interpretation='default'\n",
|
180 |
"# examples = ['siamese.jpg', 'kitten.jpg']\n",
|
181 |
+
"examples = [\"sample_images/\"+file for file in files] \n",
|
182 |
"article=\"<p style='text-align: center'><a href='https://dicksonneoh.com' target='_blank'>Blog post</a></p>\"\n",
|
183 |
"enable_queue=True\n",
|
184 |
"\n",
|
train.ipynb
CHANGED
@@ -43,7 +43,7 @@
|
|
43 |
},
|
44 |
{
|
45 |
"cell_type": "code",
|
46 |
-
"execution_count":
|
47 |
"id": "a6b53fe8-ded5-4048-afd7-e488dc884aec",
|
48 |
"metadata": {},
|
49 |
"outputs": [
|
@@ -51,40 +51,52 @@
|
|
51 |
"name": "stdout",
|
52 |
"output_type": "stream",
|
53 |
"text": [
|
|
|
54 |
"american_pit_bull_terrier_52.jpg\n",
|
55 |
"staffordshire_bull_terrier_129.jpg\n",
|
56 |
"wheaten_terrier_138.jpg\n",
|
57 |
-
"
|
|
|
58 |
"yorkshire_terrier_189.jpg\n",
|
59 |
"Abyssinian_67.jpg\n",
|
|
|
60 |
"basset_hound_12.jpg\n",
|
61 |
"american_bulldog_24.jpg\n",
|
|
|
|
|
62 |
"beagle_120.jpg\n",
|
63 |
"staffordshire_bull_terrier_173.jpg\n",
|
64 |
"beagle_125.jpg\n",
|
|
|
65 |
"Bengal_21.jpg\n",
|
|
|
|
|
66 |
"basset_hound_17.jpg\n",
|
67 |
-
"
|
68 |
"Abyssinian_7.jpg\n",
|
|
|
|
|
69 |
"american_bulldog_83.jpg\n",
|
70 |
"Birman_103.jpg\n",
|
|
|
71 |
"Bengal_19.jpg\n",
|
72 |
"american_pit_bull_terrier_76.jpg\n",
|
73 |
"yorkshire_terrier_196.jpg\n",
|
74 |
-
"wheaten_terrier_137.jpg\n"
|
|
|
75 |
]
|
76 |
}
|
77 |
],
|
78 |
"source": [
|
79 |
"import os\n",
|
80 |
-
"for root, dirs, files in os.walk(r'
|
81 |
" for filename in files:\n",
|
82 |
" print(filename)"
|
83 |
]
|
84 |
},
|
85 |
{
|
86 |
"cell_type": "code",
|
87 |
-
"execution_count":
|
88 |
"id": "62fe5dc0-5fd1-4cc7-af8d-a325e3915173",
|
89 |
"metadata": {},
|
90 |
"outputs": [
|
@@ -92,8 +104,8 @@
|
|
92 |
"name": "stdout",
|
93 |
"output_type": "stream",
|
94 |
"text": [
|
95 |
-
"Running on local URL: http://127.0.0.1:
|
96 |
-
"Running on public URL: https://
|
97 |
"\n",
|
98 |
"This share link will expire in 72 hours. To get longer links, send an email to: [email protected]\n"
|
99 |
]
|
@@ -105,7 +117,7 @@
|
|
105 |
" <iframe\n",
|
106 |
" width=\"900\"\n",
|
107 |
" height=\"500\"\n",
|
108 |
-
" src=\"https://
|
109 |
" frameborder=\"0\"\n",
|
110 |
" allowfullscreen\n",
|
111 |
" \n",
|
@@ -113,7 +125,7 @@
|
|
113 |
" "
|
114 |
],
|
115 |
"text/plain": [
|
116 |
-
"<IPython.lib.display.IFrame at
|
117 |
]
|
118 |
},
|
119 |
"metadata": {},
|
@@ -123,11 +135,11 @@
|
|
123 |
"data": {
|
124 |
"text/plain": [
|
125 |
"(<Flask 'gradio.networking'>,\n",
|
126 |
-
" 'http://127.0.0.1:
|
127 |
-
" 'https://
|
128 |
]
|
129 |
},
|
130 |
-
"execution_count":
|
131 |
"metadata": {},
|
132 |
"output_type": "execute_result"
|
133 |
},
|
@@ -135,7 +147,7 @@
|
|
135 |
"name": "stderr",
|
136 |
"output_type": "stream",
|
137 |
"text": [
|
138 |
-
"[2021-11-19 20:
|
139 |
"Traceback (most recent call last):\n",
|
140 |
" File \"/home/dnth/anaconda3/envs/gradio/lib/python3.8/site-packages/flask/app.py\", line 2073, in wsgi_app\n",
|
141 |
" response = self.full_dispatch_request()\n",
|
@@ -157,156 +169,6 @@
|
|
157 |
" stat = os.stat(path)\n",
|
158 |
"FileNotFoundError: [Errno 2] No such file or directory: '/home/dnth/Desktop/webdemos/webdemo-pets-classifier/sample_images/staffordshire_bull_terrier_172.jpg'\n"
|
159 |
]
|
160 |
-
},
|
161 |
-
{
|
162 |
-
"data": {
|
163 |
-
"text/html": [],
|
164 |
-
"text/plain": [
|
165 |
-
"<IPython.core.display.HTML object>"
|
166 |
-
]
|
167 |
-
},
|
168 |
-
"metadata": {},
|
169 |
-
"output_type": "display_data"
|
170 |
-
},
|
171 |
-
{
|
172 |
-
"name": "stderr",
|
173 |
-
"output_type": "stream",
|
174 |
-
"text": [
|
175 |
-
"[2021-11-19 20:09:37,305] ERROR in app: Exception on /file/sample_images/staffordshire_bull_terrier_172.jpg [GET]\n",
|
176 |
-
"Traceback (most recent call last):\n",
|
177 |
-
" File \"/home/dnth/anaconda3/envs/gradio/lib/python3.8/site-packages/flask/app.py\", line 2073, in wsgi_app\n",
|
178 |
-
" response = self.full_dispatch_request()\n",
|
179 |
-
" File \"/home/dnth/anaconda3/envs/gradio/lib/python3.8/site-packages/flask/app.py\", line 1518, in full_dispatch_request\n",
|
180 |
-
" rv = self.handle_user_exception(e)\n",
|
181 |
-
" File \"/home/dnth/anaconda3/envs/gradio/lib/python3.8/site-packages/flask_cors/extension.py\", line 165, in wrapped_function\n",
|
182 |
-
" return cors_after_request(app.make_response(f(*args, **kwargs)))\n",
|
183 |
-
" File \"/home/dnth/anaconda3/envs/gradio/lib/python3.8/site-packages/flask/app.py\", line 1516, in full_dispatch_request\n",
|
184 |
-
" rv = self.dispatch_request()\n",
|
185 |
-
" File \"/home/dnth/anaconda3/envs/gradio/lib/python3.8/site-packages/flask/app.py\", line 1502, in dispatch_request\n",
|
186 |
-
" return self.ensure_sync(self.view_functions[rule.endpoint])(**req.view_args)\n",
|
187 |
-
" File \"/home/dnth/anaconda3/envs/gradio/lib/python3.8/site-packages/gradio/networking.py\", line 93, in wrapper\n",
|
188 |
-
" return func(*args, **kwargs)\n",
|
189 |
-
" File \"/home/dnth/anaconda3/envs/gradio/lib/python3.8/site-packages/gradio/networking.py\", line 386, in file\n",
|
190 |
-
" return send_file(os.path.join(app.cwd, path))\n",
|
191 |
-
" File \"/home/dnth/anaconda3/envs/gradio/lib/python3.8/site-packages/flask/helpers.py\", line 612, in send_file\n",
|
192 |
-
" return werkzeug.utils.send_file(\n",
|
193 |
-
" File \"/home/dnth/anaconda3/envs/gradio/lib/python3.8/site-packages/werkzeug/utils.py\", line 701, in send_file\n",
|
194 |
-
" stat = os.stat(path)\n",
|
195 |
-
"FileNotFoundError: [Errno 2] No such file or directory: '/home/dnth/Desktop/webdemos/webdemo-pets-classifier/sample_images/staffordshire_bull_terrier_172.jpg'\n"
|
196 |
-
]
|
197 |
-
},
|
198 |
-
{
|
199 |
-
"data": {
|
200 |
-
"text/html": [],
|
201 |
-
"text/plain": [
|
202 |
-
"<IPython.core.display.HTML object>"
|
203 |
-
]
|
204 |
-
},
|
205 |
-
"metadata": {},
|
206 |
-
"output_type": "display_data"
|
207 |
-
},
|
208 |
-
{
|
209 |
-
"name": "stderr",
|
210 |
-
"output_type": "stream",
|
211 |
-
"text": [
|
212 |
-
"[2021-11-19 20:09:39,059] ERROR in app: Exception on /api/interpret/ [POST]\n",
|
213 |
-
"Traceback (most recent call last):\n",
|
214 |
-
" File \"/home/dnth/anaconda3/envs/gradio/lib/python3.8/site-packages/gradio/inputs.py\", line 795, in _segment_by_slic\n",
|
215 |
-
" from skimage.segmentation import slic\n",
|
216 |
-
"ModuleNotFoundError: No module named 'skimage'\n",
|
217 |
-
"\n",
|
218 |
-
"During handling of the above exception, another exception occurred:\n",
|
219 |
-
"\n",
|
220 |
-
"Traceback (most recent call last):\n",
|
221 |
-
" File \"/home/dnth/anaconda3/envs/gradio/lib/python3.8/site-packages/flask/app.py\", line 2073, in wsgi_app\n",
|
222 |
-
" response = self.full_dispatch_request()\n",
|
223 |
-
" File \"/home/dnth/anaconda3/envs/gradio/lib/python3.8/site-packages/flask/app.py\", line 1518, in full_dispatch_request\n",
|
224 |
-
" rv = self.handle_user_exception(e)\n",
|
225 |
-
" File \"/home/dnth/anaconda3/envs/gradio/lib/python3.8/site-packages/flask_cors/extension.py\", line 165, in wrapped_function\n",
|
226 |
-
" return cors_after_request(app.make_response(f(*args, **kwargs)))\n",
|
227 |
-
" File \"/home/dnth/anaconda3/envs/gradio/lib/python3.8/site-packages/flask/app.py\", line 1516, in full_dispatch_request\n",
|
228 |
-
" rv = self.dispatch_request()\n",
|
229 |
-
" File \"/home/dnth/anaconda3/envs/gradio/lib/python3.8/site-packages/flask/app.py\", line 1502, in dispatch_request\n",
|
230 |
-
" return self.ensure_sync(self.view_functions[rule.endpoint])(**req.view_args)\n",
|
231 |
-
" File \"/home/dnth/anaconda3/envs/gradio/lib/python3.8/site-packages/gradio/networking.py\", line 93, in wrapper\n",
|
232 |
-
" return func(*args, **kwargs)\n",
|
233 |
-
" File \"/home/dnth/anaconda3/envs/gradio/lib/python3.8/site-packages/gradio/networking.py\", line 368, in interpret\n",
|
234 |
-
" interpretation_scores, alternative_outputs = app.interface.interpret(\n",
|
235 |
-
" File \"/home/dnth/anaconda3/envs/gradio/lib/python3.8/site-packages/gradio/interface.py\", line 393, in interpret\n",
|
236 |
-
" tokens, neighbor_values, masks = input_component.tokenize(\n",
|
237 |
-
" File \"/home/dnth/anaconda3/envs/gradio/lib/python3.8/site-packages/gradio/inputs.py\", line 819, in tokenize\n",
|
238 |
-
" segments_slic, resized_and_cropped_image = self._segment_by_slic(x)\n",
|
239 |
-
" File \"/home/dnth/anaconda3/envs/gradio/lib/python3.8/site-packages/gradio/inputs.py\", line 797, in _segment_by_slic\n",
|
240 |
-
" raise ValueError(\n",
|
241 |
-
"ValueError: Error: running this interpretation for images requires scikit-image, please install it first.\n"
|
242 |
-
]
|
243 |
-
},
|
244 |
-
{
|
245 |
-
"data": {
|
246 |
-
"text/html": [],
|
247 |
-
"text/plain": [
|
248 |
-
"<IPython.core.display.HTML object>"
|
249 |
-
]
|
250 |
-
},
|
251 |
-
"metadata": {},
|
252 |
-
"output_type": "display_data"
|
253 |
-
},
|
254 |
-
{
|
255 |
-
"data": {
|
256 |
-
"text/html": [],
|
257 |
-
"text/plain": [
|
258 |
-
"<IPython.core.display.HTML object>"
|
259 |
-
]
|
260 |
-
},
|
261 |
-
"metadata": {},
|
262 |
-
"output_type": "display_data"
|
263 |
-
},
|
264 |
-
{
|
265 |
-
"data": {
|
266 |
-
"text/html": [],
|
267 |
-
"text/plain": [
|
268 |
-
"<IPython.core.display.HTML object>"
|
269 |
-
]
|
270 |
-
},
|
271 |
-
"metadata": {},
|
272 |
-
"output_type": "display_data"
|
273 |
-
},
|
274 |
-
{
|
275 |
-
"name": "stderr",
|
276 |
-
"output_type": "stream",
|
277 |
-
"text": [
|
278 |
-
"[2021-11-19 20:09:57,928] ERROR in app: Exception on /file/sample_images/staffordshire_bull_terrier_130.jpg [GET]\n",
|
279 |
-
"Traceback (most recent call last):\n",
|
280 |
-
" File \"/home/dnth/anaconda3/envs/gradio/lib/python3.8/site-packages/flask/app.py\", line 2073, in wsgi_app\n",
|
281 |
-
" response = self.full_dispatch_request()\n",
|
282 |
-
" File \"/home/dnth/anaconda3/envs/gradio/lib/python3.8/site-packages/flask/app.py\", line 1518, in full_dispatch_request\n",
|
283 |
-
" rv = self.handle_user_exception(e)\n",
|
284 |
-
" File \"/home/dnth/anaconda3/envs/gradio/lib/python3.8/site-packages/flask_cors/extension.py\", line 165, in wrapped_function\n",
|
285 |
-
" return cors_after_request(app.make_response(f(*args, **kwargs)))\n",
|
286 |
-
" File \"/home/dnth/anaconda3/envs/gradio/lib/python3.8/site-packages/flask/app.py\", line 1516, in full_dispatch_request\n",
|
287 |
-
" rv = self.dispatch_request()\n",
|
288 |
-
" File \"/home/dnth/anaconda3/envs/gradio/lib/python3.8/site-packages/flask/app.py\", line 1502, in dispatch_request\n",
|
289 |
-
" return self.ensure_sync(self.view_functions[rule.endpoint])(**req.view_args)\n",
|
290 |
-
" File \"/home/dnth/anaconda3/envs/gradio/lib/python3.8/site-packages/gradio/networking.py\", line 93, in wrapper\n",
|
291 |
-
" return func(*args, **kwargs)\n",
|
292 |
-
" File \"/home/dnth/anaconda3/envs/gradio/lib/python3.8/site-packages/gradio/networking.py\", line 386, in file\n",
|
293 |
-
" return send_file(os.path.join(app.cwd, path))\n",
|
294 |
-
" File \"/home/dnth/anaconda3/envs/gradio/lib/python3.8/site-packages/flask/helpers.py\", line 612, in send_file\n",
|
295 |
-
" return werkzeug.utils.send_file(\n",
|
296 |
-
" File \"/home/dnth/anaconda3/envs/gradio/lib/python3.8/site-packages/werkzeug/utils.py\", line 701, in send_file\n",
|
297 |
-
" stat = os.stat(path)\n",
|
298 |
-
"FileNotFoundError: [Errno 2] No such file or directory: '/home/dnth/Desktop/webdemos/webdemo-pets-classifier/sample_images/staffordshire_bull_terrier_130.jpg'\n"
|
299 |
-
]
|
300 |
-
},
|
301 |
-
{
|
302 |
-
"data": {
|
303 |
-
"text/html": [],
|
304 |
-
"text/plain": [
|
305 |
-
"<IPython.core.display.HTML object>"
|
306 |
-
]
|
307 |
-
},
|
308 |
-
"metadata": {},
|
309 |
-
"output_type": "display_data"
|
310 |
}
|
311 |
],
|
312 |
"source": [
|
|
|
43 |
},
|
44 |
{
|
45 |
"cell_type": "code",
|
46 |
+
"execution_count": 18,
|
47 |
"id": "a6b53fe8-ded5-4048-afd7-e488dc884aec",
|
48 |
"metadata": {},
|
49 |
"outputs": [
|
|
|
51 |
"name": "stdout",
|
52 |
"output_type": "stream",
|
53 |
"text": [
|
54 |
+
"Bombay_19.jpg\n",
|
55 |
"american_pit_bull_terrier_52.jpg\n",
|
56 |
"staffordshire_bull_terrier_129.jpg\n",
|
57 |
"wheaten_terrier_138.jpg\n",
|
58 |
+
"Egyptian_Mau_57.jpg\n",
|
59 |
+
"chihuahua_93.jpg\n",
|
60 |
"yorkshire_terrier_189.jpg\n",
|
61 |
"Abyssinian_67.jpg\n",
|
62 |
+
"Egyptian_Mau_63.jpg\n",
|
63 |
"basset_hound_12.jpg\n",
|
64 |
"american_bulldog_24.jpg\n",
|
65 |
+
"Bengal_109.jpg\n",
|
66 |
+
"British_Shorthair_57.jpg\n",
|
67 |
"beagle_120.jpg\n",
|
68 |
"staffordshire_bull_terrier_173.jpg\n",
|
69 |
"beagle_125.jpg\n",
|
70 |
+
"Birman_113.jpg\n",
|
71 |
"Bengal_21.jpg\n",
|
72 |
+
"British_Shorthair_61.jpg\n",
|
73 |
+
"Bombay_25.jpg\n",
|
74 |
"basset_hound_17.jpg\n",
|
75 |
+
"Abyssinian_29.jpg\n",
|
76 |
"Abyssinian_7.jpg\n",
|
77 |
+
"Bengal_108.jpg\n",
|
78 |
+
"Abyssinian_27.jpg\n",
|
79 |
"american_bulldog_83.jpg\n",
|
80 |
"Birman_103.jpg\n",
|
81 |
+
"chihuahua_94.jpg\n",
|
82 |
"Bengal_19.jpg\n",
|
83 |
"american_pit_bull_terrier_76.jpg\n",
|
84 |
"yorkshire_terrier_196.jpg\n",
|
85 |
+
"wheaten_terrier_137.jpg\n",
|
86 |
+
"Birman_120.jpg\n"
|
87 |
]
|
88 |
}
|
89 |
],
|
90 |
"source": [
|
91 |
"import os\n",
|
92 |
+
"for root, dirs, files in os.walk(r'sample_images/'):\n",
|
93 |
" for filename in files:\n",
|
94 |
" print(filename)"
|
95 |
]
|
96 |
},
|
97 |
{
|
98 |
"cell_type": "code",
|
99 |
+
"execution_count": 16,
|
100 |
"id": "62fe5dc0-5fd1-4cc7-af8d-a325e3915173",
|
101 |
"metadata": {},
|
102 |
"outputs": [
|
|
|
104 |
"name": "stdout",
|
105 |
"output_type": "stream",
|
106 |
"text": [
|
107 |
+
"Running on local URL: http://127.0.0.1:7864/\n",
|
108 |
+
"Running on public URL: https://45906.gradio.app\n",
|
109 |
"\n",
|
110 |
"This share link will expire in 72 hours. To get longer links, send an email to: [email protected]\n"
|
111 |
]
|
|
|
117 |
" <iframe\n",
|
118 |
" width=\"900\"\n",
|
119 |
" height=\"500\"\n",
|
120 |
+
" src=\"https://45906.gradio.app\"\n",
|
121 |
" frameborder=\"0\"\n",
|
122 |
" allowfullscreen\n",
|
123 |
" \n",
|
|
|
125 |
" "
|
126 |
],
|
127 |
"text/plain": [
|
128 |
+
"<IPython.lib.display.IFrame at 0x7f4be08c8dc0>"
|
129 |
]
|
130 |
},
|
131 |
"metadata": {},
|
|
|
135 |
"data": {
|
136 |
"text/plain": [
|
137 |
"(<Flask 'gradio.networking'>,\n",
|
138 |
+
" 'http://127.0.0.1:7864/',\n",
|
139 |
+
" 'https://45906.gradio.app')"
|
140 |
]
|
141 |
},
|
142 |
+
"execution_count": 16,
|
143 |
"metadata": {},
|
144 |
"output_type": "execute_result"
|
145 |
},
|
|
|
147 |
"name": "stderr",
|
148 |
"output_type": "stream",
|
149 |
"text": [
|
150 |
+
"[2021-11-19 20:18:31,342] ERROR in app: Exception on /file/sample_images/staffordshire_bull_terrier_172.jpg [GET]\n",
|
151 |
"Traceback (most recent call last):\n",
|
152 |
" File \"/home/dnth/anaconda3/envs/gradio/lib/python3.8/site-packages/flask/app.py\", line 2073, in wsgi_app\n",
|
153 |
" response = self.full_dispatch_request()\n",
|
|
|
169 |
" stat = os.stat(path)\n",
|
170 |
"FileNotFoundError: [Errno 2] No such file or directory: '/home/dnth/Desktop/webdemos/webdemo-pets-classifier/sample_images/staffordshire_bull_terrier_172.jpg'\n"
|
171 |
]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
172 |
}
|
173 |
],
|
174 |
"source": [
|