Spaces:
Runtime error
Runtime error
chuckfinca
commited on
Commit
•
f72940a
1
Parent(s):
740d542
Gets notebook code exports working. Prepares app.py for Spaces
Browse files- app.py +41 -0
- lesson_2.ipynb +189 -323
app.py
ADDED
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# AUTOGENERATED! DO NOT EDIT! File to edit: lesson_2.ipynb.
|
2 |
+
|
3 |
+
# %% auto 0
|
4 |
+
__all__ = ['dls', 'labels', 'interface', 'predict']
|
5 |
+
|
6 |
+
# %% lesson_2.ipynb 4
|
7 |
+
from fastai.vision.all import *
|
8 |
+
from fastai.collab import *
|
9 |
+
|
10 |
+
if os.path.isfile('export.pkl'):
|
11 |
+
learn: Learner = load_learner('export.pkl')
|
12 |
+
else:
|
13 |
+
path = untar_data(URLs.PETS)
|
14 |
+
dls = ImageDataLoaders.from_name_re(path, get_image_files(path/'images'), pat='(.+)_\d+.jpg', item_tfms=Resize(460), batch_tfms=aug_transforms(size=224, min_scale=0.75))
|
15 |
+
learn = vision_learner(dls, models.resnet50, metrics=accuracy)
|
16 |
+
learn.fine_tune(1)
|
17 |
+
learn.path = Path('.')
|
18 |
+
learn.export()
|
19 |
+
|
20 |
+
# %% lesson_2.ipynb 5
|
21 |
+
dls: DataLoaders = learn.dls
|
22 |
+
labels = dls.vocab
|
23 |
+
|
24 |
+
def predict(image):
|
25 |
+
image = PILImage.create(image)
|
26 |
+
prediction, prediction_index, probabilities = learn.predict(image)
|
27 |
+
return { labels[i]: float(probabilities[i]) for i in range(len(labels))}
|
28 |
+
|
29 |
+
|
30 |
+
# %% lesson_2.ipynb 7
|
31 |
+
import gradio
|
32 |
+
interface = gradio.Interface(
|
33 |
+
fn=predict,
|
34 |
+
inputs=gradio.Image(height=512, width=512),
|
35 |
+
outputs=gradio.Label(num_top_classes=3),
|
36 |
+
title="Dog Breed Classifier",
|
37 |
+
description="Upload a photo of a dog and we'll tell you the likely breeds",
|
38 |
+
article="This is Roman, he's a Red Nosed Pitbull (aka. American Pit-Bull Terrier) from New Orleans.\n\nTo try out the classifier, tap on his image to load him into the input box above and then press submit.",
|
39 |
+
examples=['roman.png']
|
40 |
+
)
|
41 |
+
interface.launch(share=True)
|
lesson_2.ipynb
CHANGED
@@ -1,5 +1,23 @@
|
|
1 |
{
|
2 |
"cells": [
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
{
|
4 |
"cell_type": "markdown",
|
5 |
"id": "a8bd8621-65ae-4cb2-bdac-12c3b97a0de5",
|
@@ -10,400 +28,248 @@
|
|
10 |
"2) Add \"#|default_exp [file_name]\" to the top of your notebook\n",
|
11 |
"3) Add \"#|export\" to the top of each cell you want to export\n",
|
12 |
"4) run:\n",
|
|
|
13 |
" import nbdev\n",
|
14 |
-
"
|
15 |
-
"
|
|
|
|
|
16 |
]
|
17 |
},
|
18 |
{
|
19 |
-
"cell_type": "
|
20 |
-
"
|
21 |
-
"id": "533b4754-10d9-44bc-9894-a50523aec091",
|
22 |
"metadata": {},
|
23 |
-
"outputs": [],
|
24 |
"source": [
|
25 |
-
"
|
26 |
]
|
27 |
},
|
28 |
{
|
29 |
"cell_type": "code",
|
30 |
"execution_count": 2,
|
31 |
-
"id": "
|
32 |
"metadata": {},
|
33 |
"outputs": [
|
34 |
{
|
35 |
-
"name": "
|
36 |
"output_type": "stream",
|
37 |
"text": [
|
38 |
-
"
|
39 |
-
"
|
40 |
-
"
|
41 |
-
"
|
42 |
-
"Requirement already satisfied: execnb>=0.1.4 in /usr/local/lib/python3.9/site-packages (from nbdev) (0.1.5)\n",
|
43 |
-
"Requirement already satisfied: astunparse in /usr/local/lib/python3.9/site-packages (from nbdev) (1.6.3)\n",
|
44 |
-
"Requirement already satisfied: ghapi>=1.0.3 in /usr/local/lib/python3.9/site-packages (from nbdev) (1.0.4)\n",
|
45 |
-
"Requirement already satisfied: watchdog in /usr/local/lib/python3.9/site-packages (from nbdev) (4.0.0)\n",
|
46 |
-
"Requirement already satisfied: asttokens in /usr/local/lib/python3.9/site-packages (from nbdev) (2.4.1)\n",
|
47 |
-
"Requirement already satisfied: PyYAML in /usr/local/lib/python3.9/site-packages (from nbdev) (6.0.1)\n",
|
48 |
-
"Requirement already satisfied: ipython in /usr/local/lib/python3.9/site-packages (from execnb>=0.1.4->nbdev) (8.18.1)\n",
|
49 |
-
"Requirement already satisfied: pip in /usr/local/lib/python3.9/site-packages (from fastcore>=1.5.27->nbdev) (24.0)\n",
|
50 |
-
"Requirement already satisfied: packaging in /usr/local/lib/python3.9/site-packages (from fastcore>=1.5.27->nbdev) (23.0)\n",
|
51 |
-
"Requirement already satisfied: ipykernel>=4.5.1 in /usr/local/lib/python3.9/site-packages (from ipywidgets<=8.0.4->nbdev) (6.29.3)\n",
|
52 |
-
"Requirement already satisfied: traitlets>=4.3.1 in /usr/local/lib/python3.9/site-packages (from ipywidgets<=8.0.4->nbdev) (5.14.2)\n",
|
53 |
-
"Requirement already satisfied: widgetsnbextension~=4.0 in /usr/local/lib/python3.9/site-packages (from ipywidgets<=8.0.4->nbdev) (4.0.10)\n",
|
54 |
-
"Requirement already satisfied: jupyterlab-widgets~=3.0 in /usr/local/lib/python3.9/site-packages (from ipywidgets<=8.0.4->nbdev) (3.0.10)\n",
|
55 |
-
"Requirement already satisfied: six>=1.12.0 in /usr/local/lib/python3.9/site-packages (from asttokens->nbdev) (1.16.0)\n",
|
56 |
-
"Requirement already satisfied: wheel<1.0,>=0.23.0 in /usr/local/lib/python3.9/site-packages (from astunparse->nbdev) (0.41.3)\n",
|
57 |
-
"Requirement already satisfied: appnope in /usr/local/lib/python3.9/site-packages (from ipykernel>=4.5.1->ipywidgets<=8.0.4->nbdev) (0.1.4)\n",
|
58 |
-
"Requirement already satisfied: comm>=0.1.1 in /usr/local/lib/python3.9/site-packages (from ipykernel>=4.5.1->ipywidgets<=8.0.4->nbdev) (0.2.2)\n",
|
59 |
-
"Requirement already satisfied: debugpy>=1.6.5 in /usr/local/lib/python3.9/site-packages (from ipykernel>=4.5.1->ipywidgets<=8.0.4->nbdev) (1.8.1)\n",
|
60 |
-
"Requirement already satisfied: jupyter-client>=6.1.12 in /usr/local/lib/python3.9/site-packages (from ipykernel>=4.5.1->ipywidgets<=8.0.4->nbdev) (8.6.1)\n",
|
61 |
-
"Requirement already satisfied: jupyter-core!=5.0.*,>=4.12 in /usr/local/lib/python3.9/site-packages (from ipykernel>=4.5.1->ipywidgets<=8.0.4->nbdev) (5.7.2)\n",
|
62 |
-
"Requirement already satisfied: matplotlib-inline>=0.1 in /usr/local/lib/python3.9/site-packages (from ipykernel>=4.5.1->ipywidgets<=8.0.4->nbdev) (0.1.6)\n",
|
63 |
-
"Requirement already satisfied: nest-asyncio in /usr/local/lib/python3.9/site-packages (from ipykernel>=4.5.1->ipywidgets<=8.0.4->nbdev) (1.6.0)\n",
|
64 |
-
"Requirement already satisfied: psutil in /usr/local/lib/python3.9/site-packages (from ipykernel>=4.5.1->ipywidgets<=8.0.4->nbdev) (5.9.8)\n",
|
65 |
-
"Requirement already satisfied: pyzmq>=24 in /usr/local/lib/python3.9/site-packages (from ipykernel>=4.5.1->ipywidgets<=8.0.4->nbdev) (25.1.2)\n",
|
66 |
-
"Requirement already satisfied: tornado>=6.1 in /usr/local/lib/python3.9/site-packages (from ipykernel>=4.5.1->ipywidgets<=8.0.4->nbdev) (6.4)\n",
|
67 |
-
"Requirement already satisfied: decorator in /usr/local/lib/python3.9/site-packages (from ipython->execnb>=0.1.4->nbdev) (5.1.1)\n",
|
68 |
-
"Requirement already satisfied: jedi>=0.16 in /usr/local/lib/python3.9/site-packages (from ipython->execnb>=0.1.4->nbdev) (0.19.1)\n",
|
69 |
-
"Requirement already satisfied: prompt-toolkit<3.1.0,>=3.0.41 in /usr/local/lib/python3.9/site-packages (from ipython->execnb>=0.1.4->nbdev) (3.0.43)\n",
|
70 |
-
"Requirement already satisfied: pygments>=2.4.0 in /usr/local/lib/python3.9/site-packages (from ipython->execnb>=0.1.4->nbdev) (2.17.2)\n",
|
71 |
-
"Requirement already satisfied: stack-data in /usr/local/lib/python3.9/site-packages (from ipython->execnb>=0.1.4->nbdev) (0.6.3)\n",
|
72 |
-
"Requirement already satisfied: typing-extensions in /usr/local/lib/python3.9/site-packages (from ipython->execnb>=0.1.4->nbdev) (4.5.0)\n",
|
73 |
-
"Requirement already satisfied: exceptiongroup in /usr/local/lib/python3.9/site-packages (from ipython->execnb>=0.1.4->nbdev) (1.2.0)\n",
|
74 |
-
"Requirement already satisfied: pexpect>4.3 in /usr/local/lib/python3.9/site-packages (from ipython->execnb>=0.1.4->nbdev) (4.9.0)\n",
|
75 |
-
"Requirement already satisfied: parso<0.9.0,>=0.8.3 in /usr/local/lib/python3.9/site-packages (from jedi>=0.16->ipython->execnb>=0.1.4->nbdev) (0.8.3)\n",
|
76 |
-
"Requirement already satisfied: importlib-metadata>=4.8.3 in /usr/local/lib/python3.9/site-packages (from jupyter-client>=6.1.12->ipykernel>=4.5.1->ipywidgets<=8.0.4->nbdev) (6.8.0)\n",
|
77 |
-
"Requirement already satisfied: python-dateutil>=2.8.2 in /usr/local/lib/python3.9/site-packages (from jupyter-client>=6.1.12->ipykernel>=4.5.1->ipywidgets<=8.0.4->nbdev) (2.8.2)\n",
|
78 |
-
"Requirement already satisfied: platformdirs>=2.5 in /usr/local/lib/python3.9/site-packages (from jupyter-core!=5.0.*,>=4.12->ipykernel>=4.5.1->ipywidgets<=8.0.4->nbdev) (3.1.1)\n",
|
79 |
-
"Requirement already satisfied: ptyprocess>=0.5 in /usr/local/lib/python3.9/site-packages (from pexpect>4.3->ipython->execnb>=0.1.4->nbdev) (0.7.0)\n",
|
80 |
-
"Requirement already satisfied: wcwidth in /usr/local/lib/python3.9/site-packages (from prompt-toolkit<3.1.0,>=3.0.41->ipython->execnb>=0.1.4->nbdev) (0.2.13)\n",
|
81 |
-
"Requirement already satisfied: executing>=1.2.0 in /usr/local/lib/python3.9/site-packages (from stack-data->ipython->execnb>=0.1.4->nbdev) (2.0.1)\n",
|
82 |
-
"Requirement already satisfied: pure-eval in /usr/local/lib/python3.9/site-packages (from stack-data->ipython->execnb>=0.1.4->nbdev) (0.2.2)\n",
|
83 |
-
"Requirement already satisfied: zipp>=0.5 in /usr/local/lib/python3.9/site-packages (from importlib-metadata>=4.8.3->jupyter-client>=6.1.12->ipykernel>=4.5.1->ipywidgets<=8.0.4->nbdev) (3.17.0)\n",
|
84 |
-
"\u001b[33mDEPRECATION: Configuring installation scheme with distutils config files is deprecated and will no longer work in the near future. If you are using a Homebrew or Linuxbrew Python, please see discussion at https://github.com/Homebrew/homebrew-core/issues/76621\u001b[0m\u001b[33m\n",
|
85 |
-
"\u001b[0mNote: you may need to restart the kernel to use updated packages.\n"
|
86 |
]
|
87 |
}
|
88 |
],
|
89 |
"source": [
|
90 |
-
"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
91 |
]
|
92 |
},
|
93 |
{
|
94 |
"cell_type": "code",
|
95 |
-
"execution_count":
|
96 |
-
"id": "
|
97 |
"metadata": {},
|
98 |
-
"outputs": [
|
99 |
-
{
|
100 |
-
"ename": "NameError",
|
101 |
-
"evalue": "name 'mx' is not defined",
|
102 |
-
"output_type": "error",
|
103 |
-
"traceback": [
|
104 |
-
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
|
105 |
-
"\u001b[0;31mNameError\u001b[0m Traceback (most recent call last)",
|
106 |
-
"Cell \u001b[0;32mIn[6], line 2\u001b[0m\n\u001b[1;32m 1\u001b[0m \u001b[38;5;66;03m#|export\u001b[39;00m\n\u001b[0;32m----> 2\u001b[0m y \u001b[38;5;241m=\u001b[39m \u001b[43mmx\u001b[49m\n",
|
107 |
-
"\u001b[0;31mNameError\u001b[0m: name 'mx' is not defined"
|
108 |
-
]
|
109 |
-
}
|
110 |
-
],
|
111 |
"source": [
|
112 |
"#|export\n",
|
113 |
-
"
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
"jp-MarkdownHeadingCollapsed": true
|
121 |
-
},
|
122 |
-
"source": [
|
123 |
-
"# section header"
|
124 |
]
|
125 |
},
|
126 |
{
|
127 |
"cell_type": "code",
|
128 |
-
"execution_count":
|
129 |
-
"id": "
|
130 |
"metadata": {},
|
131 |
"outputs": [
|
132 |
{
|
133 |
-
"
|
134 |
-
"
|
135 |
-
"
|
136 |
-
|
137 |
-
"\
|
138 |
-
"
|
139 |
-
"
|
140 |
-
"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
141 |
]
|
142 |
}
|
143 |
],
|
144 |
"source": [
|
145 |
-
"
|
146 |
]
|
147 |
},
|
148 |
{
|
149 |
"cell_type": "code",
|
150 |
-
"execution_count":
|
151 |
-
"id": "
|
152 |
"metadata": {},
|
153 |
"outputs": [
|
154 |
{
|
155 |
-
"
|
156 |
-
"
|
157 |
-
"
|
158 |
-
|
159 |
-
"\
|
160 |
-
|
161 |
-
|
162 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
163 |
]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
164 |
}
|
165 |
],
|
166 |
"source": [
|
167 |
"#|export\n",
|
168 |
-
"
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
"
|
179 |
-
"\n",
|
180 |
-
"notebook_name = \"lesson_2.ipynb\"\n",
|
181 |
-
"export_destination = \".\" # the root directory\n",
|
182 |
-
"nbdev.export.nb_export(notebook_name, export_destination)"
|
183 |
-
]
|
184 |
-
},
|
185 |
-
{
|
186 |
-
"cell_type": "markdown",
|
187 |
-
"id": "6f087d39-106b-46a2-8623-f4429e2885f1",
|
188 |
-
"metadata": {},
|
189 |
-
"source": [
|
190 |
-
"# section 2"
|
191 |
]
|
192 |
},
|
193 |
{
|
194 |
"cell_type": "code",
|
195 |
-
"execution_count":
|
196 |
-
"id": "
|
197 |
"metadata": {},
|
198 |
"outputs": [
|
199 |
{
|
200 |
"name": "stdout",
|
201 |
"output_type": "stream",
|
202 |
"text": [
|
203 |
-
"
|
204 |
-
"--------------------------------- --------------\n",
|
205 |
-
"absl-py 2.0.0\n",
|
206 |
-
"anyio 4.3.0\n",
|
207 |
-
"appnope 0.1.4\n",
|
208 |
-
"argon2-cffi 23.1.0\n",
|
209 |
-
"argon2-cffi-bindings 21.2.0\n",
|
210 |
-
"arrow 1.3.0\n",
|
211 |
-
"asttokens 2.4.1\n",
|
212 |
-
"astunparse 1.6.3\n",
|
213 |
-
"async-lru 2.0.4\n",
|
214 |
-
"attrs 23.2.0\n",
|
215 |
-
"Babel 2.14.0\n",
|
216 |
-
"beautifulsoup4 4.12.3\n",
|
217 |
-
"black 23.1.0\n",
|
218 |
-
"bleach 6.1.0\n",
|
219 |
-
"blinker 1.7.0\n",
|
220 |
-
"cachetools 5.3.2\n",
|
221 |
-
"certifi 2023.11.17\n",
|
222 |
-
"cffi 1.16.0\n",
|
223 |
-
"charset-normalizer 3.3.2\n",
|
224 |
-
"click 8.1.3\n",
|
225 |
-
"comm 0.2.2\n",
|
226 |
-
"debugpy 1.8.1\n",
|
227 |
-
"decorator 5.1.1\n",
|
228 |
-
"defusedxml 0.7.1\n",
|
229 |
-
"exceptiongroup 1.2.0\n",
|
230 |
-
"execnb 0.1.5\n",
|
231 |
-
"executing 2.0.1\n",
|
232 |
-
"fastcore 1.5.29\n",
|
233 |
-
"fastjsonschema 2.19.1\n",
|
234 |
-
"filelock 3.13.1\n",
|
235 |
-
"Flask 3.0.0\n",
|
236 |
-
"flatbuffers 23.5.26\n",
|
237 |
-
"fqdn 1.5.1\n",
|
238 |
-
"fsspec 2024.2.0\n",
|
239 |
-
"gast 0.5.4\n",
|
240 |
-
"ghapi 1.0.4\n",
|
241 |
-
"google-auth 2.23.4\n",
|
242 |
-
"google-auth-oauthlib 1.1.0\n",
|
243 |
-
"google-pasta 0.2.0\n",
|
244 |
-
"grpcio 1.59.3\n",
|
245 |
-
"h11 0.14.0\n",
|
246 |
-
"h5py 3.10.0\n",
|
247 |
-
"httpcore 1.0.4\n",
|
248 |
-
"httpx 0.27.0\n",
|
249 |
-
"huggingface-hub 0.20.3\n",
|
250 |
-
"idna 3.6\n",
|
251 |
-
"importlib-metadata 6.8.0\n",
|
252 |
-
"ipykernel 6.29.3\n",
|
253 |
-
"ipython 8.18.1\n",
|
254 |
-
"ipython-genutils 0.2.0\n",
|
255 |
-
"ipywidgets 8.0.4\n",
|
256 |
-
"isoduration 20.11.0\n",
|
257 |
-
"itsdangerous 2.1.2\n",
|
258 |
-
"jedi 0.19.1\n",
|
259 |
-
"Jinja2 3.1.2\n",
|
260 |
-
"joblib 1.3.2\n",
|
261 |
-
"json5 0.9.24\n",
|
262 |
-
"jsonpointer 2.4\n",
|
263 |
-
"jsonschema 4.21.1\n",
|
264 |
-
"jsonschema-specifications 2023.12.1\n",
|
265 |
-
"jupyter 1.0.0\n",
|
266 |
-
"jupyter_client 8.6.1\n",
|
267 |
-
"jupyter-console 6.6.3\n",
|
268 |
-
"jupyter-contrib-core 0.4.2\n",
|
269 |
-
"jupyter-contrib-nbextensions 0.7.0\n",
|
270 |
-
"jupyter_core 5.7.2\n",
|
271 |
-
"jupyter-events 0.9.1\n",
|
272 |
-
"jupyter-highlight-selected-word 0.2.0\n",
|
273 |
-
"jupyter-lsp 2.2.4\n",
|
274 |
-
"jupyter-nbextensions-configurator 0.6.3\n",
|
275 |
-
"jupyter_server 2.13.0\n",
|
276 |
-
"jupyter_server_terminals 0.5.3\n",
|
277 |
-
"jupyterlab 4.1.5\n",
|
278 |
-
"jupyterlab_pygments 0.3.0\n",
|
279 |
-
"jupyterlab_server 2.25.4\n",
|
280 |
-
"jupyterlab_widgets 3.0.10\n",
|
281 |
-
"kaggle 1.6.6\n",
|
282 |
-
"keras 2.15.0\n",
|
283 |
-
"libclang 16.0.6\n",
|
284 |
-
"lxml 5.1.0\n",
|
285 |
-
"Markdown 3.5.1\n",
|
286 |
-
"MarkupSafe 2.1.3\n",
|
287 |
-
"matplotlib-inline 0.1.6\n",
|
288 |
-
"mistune 3.0.2\n",
|
289 |
-
"ml-dtypes 0.2.0\n",
|
290 |
-
"mypy-extensions 1.0.0\n",
|
291 |
-
"nbclient 0.10.0\n",
|
292 |
-
"nbconvert 7.16.2\n",
|
293 |
-
"nbdev 2.3.13\n",
|
294 |
-
"nbformat 5.10.3\n",
|
295 |
-
"nest-asyncio 1.6.0\n",
|
296 |
-
"notebook 7.1.2\n",
|
297 |
-
"notebook_shim 0.2.4\n",
|
298 |
-
"numpy 1.26.2\n",
|
299 |
-
"oauthlib 3.2.2\n",
|
300 |
-
"opencv-python 4.9.0.80\n",
|
301 |
-
"opt-einsum 3.3.0\n",
|
302 |
-
"overrides 7.7.0\n",
|
303 |
-
"packaging 23.0\n",
|
304 |
-
"pandocfilters 1.5.1\n",
|
305 |
-
"parso 0.8.3\n",
|
306 |
-
"pathspec 0.11.1\n",
|
307 |
-
"pexpect 4.9.0\n",
|
308 |
-
"pip 24.0\n",
|
309 |
-
"platformdirs 3.1.1\n",
|
310 |
-
"prometheus_client 0.20.0\n",
|
311 |
-
"prompt-toolkit 3.0.43\n",
|
312 |
-
"protobuf 4.23.4\n",
|
313 |
-
"psutil 5.9.8\n",
|
314 |
-
"ptyprocess 0.7.0\n",
|
315 |
-
"pure-eval 0.2.2\n",
|
316 |
-
"pyasn1 0.5.1\n",
|
317 |
-
"pyasn1-modules 0.3.0\n",
|
318 |
-
"pycparser 2.21\n",
|
319 |
-
"pydot 1.4.2\n",
|
320 |
-
"Pygments 2.17.2\n",
|
321 |
-
"pyparsing 3.1.1\n",
|
322 |
-
"python-dateutil 2.8.2\n",
|
323 |
-
"python-json-logger 2.0.7\n",
|
324 |
-
"python-slugify 8.0.4\n",
|
325 |
-
"PyYAML 6.0.1\n",
|
326 |
-
"pyzmq 25.1.2\n",
|
327 |
-
"qtconsole 5.5.1\n",
|
328 |
-
"QtPy 2.4.1\n",
|
329 |
-
"referencing 0.34.0\n",
|
330 |
-
"requests 2.31.0\n",
|
331 |
-
"requests-oauthlib 1.3.1\n",
|
332 |
-
"rfc3339-validator 0.1.4\n",
|
333 |
-
"rfc3986-validator 0.1.1\n",
|
334 |
-
"rpds-py 0.18.0\n",
|
335 |
-
"rsa 4.9\n",
|
336 |
-
"scikit-learn 1.3.2\n",
|
337 |
-
"scipy 1.11.4\n",
|
338 |
-
"Send2Trash 1.8.2\n",
|
339 |
-
"setuptools 68.2.2\n",
|
340 |
-
"simpleai 0.8.3\n",
|
341 |
-
"six 1.16.0\n",
|
342 |
-
"sniffio 1.3.1\n",
|
343 |
-
"soupsieve 2.5\n",
|
344 |
-
"stack-data 0.6.3\n",
|
345 |
-
"tensorboard 2.15.1\n",
|
346 |
-
"tensorboard-data-server 0.7.2\n",
|
347 |
-
"tensorflow 2.15.0\n",
|
348 |
-
"tensorflow-estimator 2.15.0\n",
|
349 |
-
"tensorflow-io-gcs-filesystem 0.34.0\n",
|
350 |
-
"termcolor 2.3.0\n",
|
351 |
-
"terminado 0.18.1\n",
|
352 |
-
"text-unidecode 1.3\n",
|
353 |
-
"threadpoolctl 3.2.0\n",
|
354 |
-
"tinycss2 1.2.1\n",
|
355 |
-
"tomli 2.0.1\n",
|
356 |
-
"tornado 6.4\n",
|
357 |
-
"tqdm 4.66.2\n",
|
358 |
-
"traitlets 5.14.2\n",
|
359 |
-
"types-python-dateutil 2.9.0.20240316\n",
|
360 |
-
"typing_extensions 4.5.0\n",
|
361 |
-
"uri-template 1.3.0\n",
|
362 |
-
"urllib3 2.1.0\n",
|
363 |
-
"watchdog 4.0.0\n",
|
364 |
-
"wcwidth 0.2.13\n",
|
365 |
-
"webcolors 1.13\n",
|
366 |
-
"webencodings 0.5.1\n",
|
367 |
-
"websocket-client 1.7.0\n",
|
368 |
-
"Werkzeug 3.0.1\n",
|
369 |
-
"wheel 0.41.3\n",
|
370 |
-
"widgetsnbextension 4.0.10\n",
|
371 |
-
"wrapt 1.14.1\n",
|
372 |
-
"zipp 3.17.0\n",
|
373 |
"Note: you may need to restart the kernel to use updated packages.\n"
|
374 |
]
|
375 |
}
|
376 |
],
|
377 |
"source": [
|
378 |
-
"pip
|
379 |
]
|
380 |
},
|
381 |
{
|
382 |
"cell_type": "code",
|
383 |
-
"execution_count":
|
384 |
-
"id": "
|
385 |
"metadata": {},
|
386 |
-
"outputs": [
|
387 |
-
{
|
388 |
-
"ename": "NameError",
|
389 |
-
"evalue": "name 'untar_data' is not defined",
|
390 |
-
"output_type": "error",
|
391 |
-
"traceback": [
|
392 |
-
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
|
393 |
-
"\u001b[0;31mNameError\u001b[0m Traceback (most recent call last)",
|
394 |
-
"Cell \u001b[0;32mIn[8], line 2\u001b[0m\n\u001b[1;32m 1\u001b[0m \u001b[38;5;28;01mfrom\u001b[39;00m \u001b[38;5;21;01mfastcore\u001b[39;00m\u001b[38;5;21;01m.\u001b[39;00m\u001b[38;5;21;01mall\u001b[39;00m \u001b[38;5;28;01mimport\u001b[39;00m \u001b[38;5;241m*\u001b[39m\n\u001b[0;32m----> 2\u001b[0m path \u001b[38;5;241m=\u001b[39m \u001b[43muntar_data\u001b[49m(URLs\u001b[38;5;241m.\u001b[39mPETS)\n\u001b[1;32m 3\u001b[0m dls \u001b[38;5;241m=\u001b[39m ImageDataLoaders\u001b[38;5;241m.\u001b[39mfrom_name_re(path, get_image_files(path\u001b[38;5;241m/\u001b[39m\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mimages\u001b[39m\u001b[38;5;124m'\u001b[39m), pat\u001b[38;5;241m=\u001b[39m\u001b[38;5;124m'\u001b[39m\u001b[38;5;124m(.+)_\u001b[39m\u001b[38;5;124m\\\u001b[39m\u001b[38;5;124md+.jpg\u001b[39m\u001b[38;5;124m'\u001b[39m, item_tfms\u001b[38;5;241m=\u001b[39mResize(\u001b[38;5;241m460\u001b[39m), batch_tfms\u001b[38;5;241m=\u001b[39maug_transforms(size\u001b[38;5;241m=\u001b[39m\u001b[38;5;241m224\u001b[39m, min_scale\u001b[38;5;241m=\u001b[39m\u001b[38;5;241m0.75\u001b[39m))\n\u001b[1;32m 4\u001b[0m learn \u001b[38;5;241m=\u001b[39m vision_learner(dls, models\u001b[38;5;241m.\u001b[39mresnet50, metrics\u001b[38;5;241m=\u001b[39maccuracy)\n",
|
395 |
-
"\u001b[0;31mNameError\u001b[0m: name 'untar_data' is not defined"
|
396 |
-
]
|
397 |
-
}
|
398 |
-
],
|
399 |
"source": [
|
400 |
-
"
|
401 |
-
"
|
402 |
-
"
|
403 |
-
"
|
404 |
-
"
|
405 |
-
"learn.path = Path('.')\n",
|
406 |
-
"learn.export()"
|
407 |
]
|
408 |
}
|
409 |
],
|
|
|
1 |
{
|
2 |
"cells": [
|
3 |
+
{
|
4 |
+
"cell_type": "code",
|
5 |
+
"execution_count": 1,
|
6 |
+
"id": "2904c251",
|
7 |
+
"metadata": {},
|
8 |
+
"outputs": [],
|
9 |
+
"source": [
|
10 |
+
"#|default_exp app"
|
11 |
+
]
|
12 |
+
},
|
13 |
+
{
|
14 |
+
"cell_type": "markdown",
|
15 |
+
"id": "8f566fe5",
|
16 |
+
"metadata": {},
|
17 |
+
"source": [
|
18 |
+
"# Export instructions"
|
19 |
+
]
|
20 |
+
},
|
21 |
{
|
22 |
"cell_type": "markdown",
|
23 |
"id": "a8bd8621-65ae-4cb2-bdac-12c3b97a0de5",
|
|
|
28 |
"2) Add \"#|default_exp [file_name]\" to the top of your notebook\n",
|
29 |
"3) Add \"#|export\" to the top of each cell you want to export\n",
|
30 |
"4) run:\n",
|
31 |
+
"```python\n",
|
32 |
" import nbdev\n",
|
33 |
+
" notebook_name = \"lesson_2.ipynb\"\n",
|
34 |
+
" export_destination = \".\" # the root directory\n",
|
35 |
+
" nbdev.export.nb_export(notebook_name, export_destination)\n",
|
36 |
+
"```"
|
37 |
]
|
38 |
},
|
39 |
{
|
40 |
+
"cell_type": "markdown",
|
41 |
+
"id": "6f087d39-106b-46a2-8623-f4429e2885f1",
|
|
|
42 |
"metadata": {},
|
|
|
43 |
"source": [
|
44 |
+
"# Code"
|
45 |
]
|
46 |
},
|
47 |
{
|
48 |
"cell_type": "code",
|
49 |
"execution_count": 2,
|
50 |
+
"id": "746c335b-5825-4032-9ee9-834d947ba01d",
|
51 |
"metadata": {},
|
52 |
"outputs": [
|
53 |
{
|
54 |
+
"name": "stderr",
|
55 |
"output_type": "stream",
|
56 |
"text": [
|
57 |
+
"/Users/charlesfeinn/miniforge-pypy3/envs/default/lib/python3.9/site-packages/torchvision/io/image.py:13: UserWarning: Failed to load image Python extension: 'dlopen(/Users/charlesfeinn/miniforge-pypy3/envs/default/lib/python3.9/site-packages/torchvision/image.so, 0x0006): Symbol not found: __ZN3c1017RegisterOperatorsD1Ev\n",
|
58 |
+
" Referenced from: <CC4BC91F-8B6A-3F9A-B9EB-A2B9D578E202> /Users/charlesfeinn/miniforge-pypy3/envs/default/lib/python3.9/site-packages/torchvision/image.so\n",
|
59 |
+
" Expected in: <B36C132B-E822-3FDA-9BEC-DD9DB8197D06> /Users/charlesfeinn/miniforge-pypy3/envs/default/lib/python3.9/site-packages/torch/lib/libtorch_cpu.dylib'If you don't plan on using image functionality from `torchvision.io`, you can ignore this warning. Otherwise, there might be something wrong with your environment. Did you have `libjpeg` or `libpng` installed before building `torchvision` from source?\n",
|
60 |
+
" warn(\n"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
61 |
]
|
62 |
}
|
63 |
],
|
64 |
"source": [
|
65 |
+
"#|export\n",
|
66 |
+
"from fastai.vision.all import *\n",
|
67 |
+
"from fastai.collab import *\n",
|
68 |
+
"\n",
|
69 |
+
"if os.path.isfile('export.pkl'):\n",
|
70 |
+
" learn: Learner = load_learner('export.pkl')\n",
|
71 |
+
"else:\n",
|
72 |
+
" path = untar_data(URLs.PETS)\n",
|
73 |
+
" dls = ImageDataLoaders.from_name_re(path, get_image_files(path/'images'), pat='(.+)_\\d+.jpg', item_tfms=Resize(460), batch_tfms=aug_transforms(size=224, min_scale=0.75))\n",
|
74 |
+
" learn = vision_learner(dls, models.resnet50, metrics=accuracy)\n",
|
75 |
+
" learn.fine_tune(1)\n",
|
76 |
+
" learn.path = Path('.')\n",
|
77 |
+
" learn.export()"
|
78 |
]
|
79 |
},
|
80 |
{
|
81 |
"cell_type": "code",
|
82 |
+
"execution_count": 3,
|
83 |
+
"id": "d670bc7e",
|
84 |
"metadata": {},
|
85 |
+
"outputs": [],
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
86 |
"source": [
|
87 |
"#|export\n",
|
88 |
+
"dls: DataLoaders = learn.dls\n",
|
89 |
+
"labels = dls.vocab\n",
|
90 |
+
"\n",
|
91 |
+
"def predict(image):\n",
|
92 |
+
" image = PILImage.create(image)\n",
|
93 |
+
" prediction, prediction_index, probabilities = learn.predict(image)\n",
|
94 |
+
" return { labels[i]: float(probabilities[i]) for i in range(len(labels))}\n"
|
|
|
|
|
|
|
|
|
95 |
]
|
96 |
},
|
97 |
{
|
98 |
"cell_type": "code",
|
99 |
+
"execution_count": 4,
|
100 |
+
"id": "5be95314",
|
101 |
"metadata": {},
|
102 |
"outputs": [
|
103 |
{
|
104 |
+
"name": "stdout",
|
105 |
+
"output_type": "stream",
|
106 |
+
"text": [
|
107 |
+
"Requirement already satisfied: gradio in /Users/charlesfeinn/miniforge-pypy3/envs/default/lib/python3.9/site-packages (4.22.0)\n",
|
108 |
+
"Requirement already satisfied: aiofiles<24.0,>=22.0 in /Users/charlesfeinn/miniforge-pypy3/envs/default/lib/python3.9/site-packages (from gradio) (23.2.1)\n",
|
109 |
+
"Requirement already satisfied: altair<6.0,>=4.2.0 in /Users/charlesfeinn/miniforge-pypy3/envs/default/lib/python3.9/site-packages (from gradio) (5.2.0)\n",
|
110 |
+
"Requirement already satisfied: fastapi in /Users/charlesfeinn/miniforge-pypy3/envs/default/lib/python3.9/site-packages (from gradio) (0.110.0)\n",
|
111 |
+
"Requirement already satisfied: ffmpy in /Users/charlesfeinn/miniforge-pypy3/envs/default/lib/python3.9/site-packages (from gradio) (0.3.2)\n",
|
112 |
+
"Requirement already satisfied: gradio-client==0.13.0 in /Users/charlesfeinn/miniforge-pypy3/envs/default/lib/python3.9/site-packages (from gradio) (0.13.0)\n",
|
113 |
+
"Requirement already satisfied: httpx>=0.24.1 in /Users/charlesfeinn/miniforge-pypy3/envs/default/lib/python3.9/site-packages (from gradio) (0.27.0)\n",
|
114 |
+
"Requirement already satisfied: huggingface-hub>=0.19.3 in /Users/charlesfeinn/miniforge-pypy3/envs/default/lib/python3.9/site-packages (from gradio) (0.21.4)\n",
|
115 |
+
"Requirement already satisfied: importlib-resources<7.0,>=1.3 in /Users/charlesfeinn/miniforge-pypy3/envs/default/lib/python3.9/site-packages (from gradio) (6.1.1)\n",
|
116 |
+
"Requirement already satisfied: jinja2<4.0 in /Users/charlesfeinn/miniforge-pypy3/envs/default/lib/python3.9/site-packages (from gradio) (3.1.3)\n",
|
117 |
+
"Requirement already satisfied: markupsafe~=2.0 in /Users/charlesfeinn/miniforge-pypy3/envs/default/lib/python3.9/site-packages (from gradio) (2.1.3)\n",
|
118 |
+
"Requirement already satisfied: matplotlib~=3.0 in /Users/charlesfeinn/miniforge-pypy3/envs/default/lib/python3.9/site-packages (from gradio) (3.8.0)\n",
|
119 |
+
"Requirement already satisfied: numpy~=1.0 in /Users/charlesfeinn/miniforge-pypy3/envs/default/lib/python3.9/site-packages (from gradio) (1.26.4)\n",
|
120 |
+
"Requirement already satisfied: orjson~=3.0 in /Users/charlesfeinn/miniforge-pypy3/envs/default/lib/python3.9/site-packages (from gradio) (3.9.15)\n",
|
121 |
+
"Requirement already satisfied: packaging in /Users/charlesfeinn/miniforge-pypy3/envs/default/lib/python3.9/site-packages (from gradio) (23.2)\n",
|
122 |
+
"Requirement already satisfied: pandas<3.0,>=1.0 in /Users/charlesfeinn/miniforge-pypy3/envs/default/lib/python3.9/site-packages (from gradio) (2.2.1)\n",
|
123 |
+
"Requirement already satisfied: pillow<11.0,>=8.0 in /Users/charlesfeinn/miniforge-pypy3/envs/default/lib/python3.9/site-packages (from gradio) (10.2.0)\n",
|
124 |
+
"Requirement already satisfied: pydantic>=2.0 in /Users/charlesfeinn/miniforge-pypy3/envs/default/lib/python3.9/site-packages (from gradio) (2.5.3)\n",
|
125 |
+
"Requirement already satisfied: pydub in /Users/charlesfeinn/miniforge-pypy3/envs/default/lib/python3.9/site-packages (from gradio) (0.25.1)\n",
|
126 |
+
"Requirement already satisfied: python-multipart>=0.0.9 in /Users/charlesfeinn/miniforge-pypy3/envs/default/lib/python3.9/site-packages (from gradio) (0.0.9)\n",
|
127 |
+
"Requirement already satisfied: pyyaml<7.0,>=5.0 in /Users/charlesfeinn/miniforge-pypy3/envs/default/lib/python3.9/site-packages (from gradio) (6.0.1)\n",
|
128 |
+
"Requirement already satisfied: ruff>=0.2.2 in /Users/charlesfeinn/miniforge-pypy3/envs/default/lib/python3.9/site-packages (from gradio) (0.3.4)\n",
|
129 |
+
"Requirement already satisfied: semantic-version~=2.0 in /Users/charlesfeinn/miniforge-pypy3/envs/default/lib/python3.9/site-packages (from gradio) (2.10.0)\n",
|
130 |
+
"Requirement already satisfied: tomlkit==0.12.0 in /Users/charlesfeinn/miniforge-pypy3/envs/default/lib/python3.9/site-packages (from gradio) (0.12.0)\n",
|
131 |
+
"Requirement already satisfied: typer<1.0,>=0.9 in /Users/charlesfeinn/miniforge-pypy3/envs/default/lib/python3.9/site-packages (from typer[all]<1.0,>=0.9->gradio) (0.9.0)\n",
|
132 |
+
"Requirement already satisfied: typing-extensions~=4.0 in /Users/charlesfeinn/miniforge-pypy3/envs/default/lib/python3.9/site-packages (from gradio) (4.9.0)\n",
|
133 |
+
"Requirement already satisfied: uvicorn>=0.14.0 in /Users/charlesfeinn/miniforge-pypy3/envs/default/lib/python3.9/site-packages (from gradio) (0.29.0)\n",
|
134 |
+
"Requirement already satisfied: fsspec in /Users/charlesfeinn/miniforge-pypy3/envs/default/lib/python3.9/site-packages (from gradio-client==0.13.0->gradio) (2023.10.0)\n",
|
135 |
+
"Requirement already satisfied: websockets<12.0,>=10.0 in /Users/charlesfeinn/miniforge-pypy3/envs/default/lib/python3.9/site-packages (from gradio-client==0.13.0->gradio) (11.0.3)\n",
|
136 |
+
"Requirement already satisfied: jsonschema>=3.0 in /Users/charlesfeinn/miniforge-pypy3/envs/default/lib/python3.9/site-packages (from altair<6.0,>=4.2.0->gradio) (4.21.1)\n",
|
137 |
+
"Requirement already satisfied: toolz in /Users/charlesfeinn/miniforge-pypy3/envs/default/lib/python3.9/site-packages (from altair<6.0,>=4.2.0->gradio) (0.12.1)\n",
|
138 |
+
"Requirement already satisfied: anyio in /Users/charlesfeinn/miniforge-pypy3/envs/default/lib/python3.9/site-packages (from httpx>=0.24.1->gradio) (4.3.0)\n",
|
139 |
+
"Requirement already satisfied: certifi in /Users/charlesfeinn/miniforge-pypy3/envs/default/lib/python3.9/site-packages (from httpx>=0.24.1->gradio) (2024.2.2)\n",
|
140 |
+
"Requirement already satisfied: httpcore==1.* in /Users/charlesfeinn/miniforge-pypy3/envs/default/lib/python3.9/site-packages (from httpx>=0.24.1->gradio) (1.0.4)\n",
|
141 |
+
"Requirement already satisfied: idna in /Users/charlesfeinn/miniforge-pypy3/envs/default/lib/python3.9/site-packages (from httpx>=0.24.1->gradio) (3.4)\n",
|
142 |
+
"Requirement already satisfied: sniffio in /Users/charlesfeinn/miniforge-pypy3/envs/default/lib/python3.9/site-packages (from httpx>=0.24.1->gradio) (1.3.1)\n",
|
143 |
+
"Requirement already satisfied: h11<0.15,>=0.13 in /Users/charlesfeinn/miniforge-pypy3/envs/default/lib/python3.9/site-packages (from httpcore==1.*->httpx>=0.24.1->gradio) (0.14.0)\n",
|
144 |
+
"Requirement already satisfied: filelock in /Users/charlesfeinn/miniforge-pypy3/envs/default/lib/python3.9/site-packages (from huggingface-hub>=0.19.3->gradio) (3.13.1)\n",
|
145 |
+
"Requirement already satisfied: requests in /Users/charlesfeinn/miniforge-pypy3/envs/default/lib/python3.9/site-packages (from huggingface-hub>=0.19.3->gradio) (2.31.0)\n",
|
146 |
+
"Requirement already satisfied: tqdm>=4.42.1 in /Users/charlesfeinn/miniforge-pypy3/envs/default/lib/python3.9/site-packages (from huggingface-hub>=0.19.3->gradio) (4.65.0)\n",
|
147 |
+
"Requirement already satisfied: zipp>=3.1.0 in /Users/charlesfeinn/miniforge-pypy3/envs/default/lib/python3.9/site-packages (from importlib-resources<7.0,>=1.3->gradio) (3.17.0)\n",
|
148 |
+
"Requirement already satisfied: contourpy>=1.0.1 in /Users/charlesfeinn/miniforge-pypy3/envs/default/lib/python3.9/site-packages (from matplotlib~=3.0->gradio) (1.2.0)\n",
|
149 |
+
"Requirement already satisfied: cycler>=0.10 in /Users/charlesfeinn/miniforge-pypy3/envs/default/lib/python3.9/site-packages (from matplotlib~=3.0->gradio) (0.11.0)\n",
|
150 |
+
"Requirement already satisfied: fonttools>=4.22.0 in /Users/charlesfeinn/miniforge-pypy3/envs/default/lib/python3.9/site-packages (from matplotlib~=3.0->gradio) (4.25.0)\n",
|
151 |
+
"Requirement already satisfied: kiwisolver>=1.0.1 in /Users/charlesfeinn/miniforge-pypy3/envs/default/lib/python3.9/site-packages (from matplotlib~=3.0->gradio) (1.4.4)\n",
|
152 |
+
"Requirement already satisfied: pyparsing>=2.3.1 in /Users/charlesfeinn/miniforge-pypy3/envs/default/lib/python3.9/site-packages (from matplotlib~=3.0->gradio) (3.0.9)\n",
|
153 |
+
"Requirement already satisfied: python-dateutil>=2.7 in /Users/charlesfeinn/miniforge-pypy3/envs/default/lib/python3.9/site-packages (from matplotlib~=3.0->gradio) (2.8.2)\n",
|
154 |
+
"Requirement already satisfied: pytz>=2020.1 in /Users/charlesfeinn/miniforge-pypy3/envs/default/lib/python3.9/site-packages (from pandas<3.0,>=1.0->gradio) (2023.3.post1)\n",
|
155 |
+
"Requirement already satisfied: tzdata>=2022.7 in /Users/charlesfeinn/miniforge-pypy3/envs/default/lib/python3.9/site-packages (from pandas<3.0,>=1.0->gradio) (2023.3)\n",
|
156 |
+
"Requirement already satisfied: annotated-types>=0.4.0 in /Users/charlesfeinn/miniforge-pypy3/envs/default/lib/python3.9/site-packages (from pydantic>=2.0->gradio) (0.6.0)\n",
|
157 |
+
"Requirement already satisfied: pydantic-core==2.14.6 in /Users/charlesfeinn/miniforge-pypy3/envs/default/lib/python3.9/site-packages (from pydantic>=2.0->gradio) (2.14.6)\n",
|
158 |
+
"Requirement already satisfied: click<9.0.0,>=7.1.1 in /Users/charlesfeinn/miniforge-pypy3/envs/default/lib/python3.9/site-packages (from typer<1.0,>=0.9->typer[all]<1.0,>=0.9->gradio) (8.1.7)\n",
|
159 |
+
"Requirement already satisfied: colorama<0.5.0,>=0.4.3 in /Users/charlesfeinn/miniforge-pypy3/envs/default/lib/python3.9/site-packages (from typer[all]<1.0,>=0.9->gradio) (0.4.6)\n",
|
160 |
+
"Requirement already satisfied: shellingham<2.0.0,>=1.3.0 in /Users/charlesfeinn/miniforge-pypy3/envs/default/lib/python3.9/site-packages (from typer[all]<1.0,>=0.9->gradio) (1.5.0)\n",
|
161 |
+
"Requirement already satisfied: rich<14.0.0,>=10.11.0 in /Users/charlesfeinn/miniforge-pypy3/envs/default/lib/python3.9/site-packages (from typer[all]<1.0,>=0.9->gradio) (13.3.5)\n",
|
162 |
+
"Requirement already satisfied: starlette<0.37.0,>=0.36.3 in /Users/charlesfeinn/miniforge-pypy3/envs/default/lib/python3.9/site-packages (from fastapi->gradio) (0.36.3)\n",
|
163 |
+
"Requirement already satisfied: attrs>=22.2.0 in /Users/charlesfeinn/miniforge-pypy3/envs/default/lib/python3.9/site-packages (from jsonschema>=3.0->altair<6.0,>=4.2.0->gradio) (23.2.0)\n",
|
164 |
+
"Requirement already satisfied: jsonschema-specifications>=2023.03.6 in /Users/charlesfeinn/miniforge-pypy3/envs/default/lib/python3.9/site-packages (from jsonschema>=3.0->altair<6.0,>=4.2.0->gradio) (2023.12.1)\n",
|
165 |
+
"Requirement already satisfied: referencing>=0.28.4 in /Users/charlesfeinn/miniforge-pypy3/envs/default/lib/python3.9/site-packages (from jsonschema>=3.0->altair<6.0,>=4.2.0->gradio) (0.34.0)\n",
|
166 |
+
"Requirement already satisfied: rpds-py>=0.7.1 in /Users/charlesfeinn/miniforge-pypy3/envs/default/lib/python3.9/site-packages (from jsonschema>=3.0->altair<6.0,>=4.2.0->gradio) (0.18.0)\n",
|
167 |
+
"Requirement already satisfied: six>=1.5 in /Users/charlesfeinn/miniforge-pypy3/envs/default/lib/python3.9/site-packages (from python-dateutil>=2.7->matplotlib~=3.0->gradio) (1.16.0)\n",
|
168 |
+
"Requirement already satisfied: markdown-it-py<3.0.0,>=2.2.0 in /Users/charlesfeinn/miniforge-pypy3/envs/default/lib/python3.9/site-packages (from rich<14.0.0,>=10.11.0->typer[all]<1.0,>=0.9->gradio) (2.2.0)\n",
|
169 |
+
"Requirement already satisfied: pygments<3.0.0,>=2.13.0 in /Users/charlesfeinn/miniforge-pypy3/envs/default/lib/python3.9/site-packages (from rich<14.0.0,>=10.11.0->typer[all]<1.0,>=0.9->gradio) (2.15.1)\n",
|
170 |
+
"Requirement already satisfied: exceptiongroup>=1.0.2 in /Users/charlesfeinn/miniforge-pypy3/envs/default/lib/python3.9/site-packages (from anyio->httpx>=0.24.1->gradio) (1.2.0)\n",
|
171 |
+
"Requirement already satisfied: charset-normalizer<4,>=2 in /Users/charlesfeinn/miniforge-pypy3/envs/default/lib/python3.9/site-packages (from requests->huggingface-hub>=0.19.3->gradio) (2.0.4)\n",
|
172 |
+
"Requirement already satisfied: urllib3<3,>=1.21.1 in /Users/charlesfeinn/miniforge-pypy3/envs/default/lib/python3.9/site-packages (from requests->huggingface-hub>=0.19.3->gradio) (2.1.0)\n",
|
173 |
+
"Requirement already satisfied: mdurl~=0.1 in /Users/charlesfeinn/miniforge-pypy3/envs/default/lib/python3.9/site-packages (from markdown-it-py<3.0.0,>=2.2.0->rich<14.0.0,>=10.11.0->typer[all]<1.0,>=0.9->gradio) (0.1.0)\n",
|
174 |
+
"Note: you may need to restart the kernel to use updated packages.\n"
|
175 |
]
|
176 |
}
|
177 |
],
|
178 |
"source": [
|
179 |
+
"%pip install gradio"
|
180 |
]
|
181 |
},
|
182 |
{
|
183 |
"cell_type": "code",
|
184 |
+
"execution_count": 5,
|
185 |
+
"id": "e7e4c80c",
|
186 |
"metadata": {},
|
187 |
"outputs": [
|
188 |
{
|
189 |
+
"name": "stderr",
|
190 |
+
"output_type": "stream",
|
191 |
+
"text": [
|
192 |
+
"/Users/charlesfeinn/miniforge-pypy3/envs/default/lib/python3.9/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",
|
193 |
+
" from .autonotebook import tqdm as notebook_tqdm\n"
|
194 |
+
]
|
195 |
+
},
|
196 |
+
{
|
197 |
+
"name": "stdout",
|
198 |
+
"output_type": "stream",
|
199 |
+
"text": [
|
200 |
+
"Running on local URL: http://127.0.0.1:7860\n",
|
201 |
+
"Running on public URL: https://95de38d55a9ae84b0c.gradio.live\n",
|
202 |
+
"\n",
|
203 |
+
"This share link expires in 72 hours. For free permanent hosting and GPU upgrades, run `gradio deploy` from Terminal to deploy to Spaces (https://huggingface.co/spaces)\n"
|
204 |
]
|
205 |
+
},
|
206 |
+
{
|
207 |
+
"data": {
|
208 |
+
"text/html": [
|
209 |
+
"<div><iframe src=\"https://95de38d55a9ae84b0c.gradio.live\" width=\"100%\" height=\"500\" allow=\"autoplay; camera; microphone; clipboard-read; clipboard-write;\" frameborder=\"0\" allowfullscreen></iframe></div>"
|
210 |
+
],
|
211 |
+
"text/plain": [
|
212 |
+
"<IPython.core.display.HTML object>"
|
213 |
+
]
|
214 |
+
},
|
215 |
+
"metadata": {},
|
216 |
+
"output_type": "display_data"
|
217 |
+
},
|
218 |
+
{
|
219 |
+
"data": {
|
220 |
+
"text/plain": []
|
221 |
+
},
|
222 |
+
"execution_count": 5,
|
223 |
+
"metadata": {},
|
224 |
+
"output_type": "execute_result"
|
225 |
}
|
226 |
],
|
227 |
"source": [
|
228 |
"#|export\n",
|
229 |
+
"import gradio\n",
|
230 |
+
"interface = gradio.Interface(\n",
|
231 |
+
" fn=predict, \n",
|
232 |
+
" inputs=gradio.Image(height=512, width=512), \n",
|
233 |
+
" outputs=gradio.Label(num_top_classes=3),\n",
|
234 |
+
" title=\"Dog Breed Classifier\",\n",
|
235 |
+
" description=\"Upload a photo of a dog and we'll tell you the likely breeds\",\n",
|
236 |
+
" article=\"This is Roman, he's a Red Nosed Pitbull (aka. American Pit-Bull Terrier) from New Orleans.\\n\\nTo try out the classifier, tap on his image to load him into the input box above and then press submit.\",\n",
|
237 |
+
" examples=['roman.png']\n",
|
238 |
+
")\n",
|
239 |
+
"interface.launch(share=True)"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
240 |
]
|
241 |
},
|
242 |
{
|
243 |
"cell_type": "code",
|
244 |
+
"execution_count": 6,
|
245 |
+
"id": "807e0708",
|
246 |
"metadata": {},
|
247 |
"outputs": [
|
248 |
{
|
249 |
"name": "stdout",
|
250 |
"output_type": "stream",
|
251 |
"text": [
|
252 |
+
"Requirement already satisfied: jupyterlab-quarto in /Users/charlesfeinn/miniforge-pypy3/envs/default/lib/python3.9/site-packages (0.3.3)\n",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
253 |
"Note: you may need to restart the kernel to use updated packages.\n"
|
254 |
]
|
255 |
}
|
256 |
],
|
257 |
"source": [
|
258 |
+
"%pip install jupyterlab-quarto"
|
259 |
]
|
260 |
},
|
261 |
{
|
262 |
"cell_type": "code",
|
263 |
+
"execution_count": 7,
|
264 |
+
"id": "342a044e",
|
265 |
"metadata": {},
|
266 |
+
"outputs": [],
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
267 |
"source": [
|
268 |
+
"import nbdev\n",
|
269 |
+
"\n",
|
270 |
+
"notebook_name = \"lesson_2.ipynb\"\n",
|
271 |
+
"export_destination = \".\" # the root directory\n",
|
272 |
+
"nbdev.export.nb_export(notebook_name, export_destination)"
|
|
|
|
|
273 |
]
|
274 |
}
|
275 |
],
|