Spaces:
Runtime error
Runtime error
exiomius
commited on
Commit
•
6d41343
1
Parent(s):
648536d
Finished understanding how to convert notebooks into .py files
Browse files- .ipynb_checkpoints/app-checkpoint.ipynb +66 -23
- app.ipynb +38 -38
.ipynb_checkpoints/app-checkpoint.ipynb
CHANGED
@@ -2,19 +2,45 @@
|
|
2 |
"cells": [
|
3 |
{
|
4 |
"cell_type": "markdown",
|
5 |
-
"id": "
|
6 |
"metadata": {},
|
7 |
"source": [
|
8 |
-
"# "
|
|
|
9 |
]
|
10 |
},
|
11 |
{
|
12 |
"cell_type": "code",
|
13 |
"execution_count": 1,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
14 |
"id": "435a6f23",
|
15 |
"metadata": {},
|
16 |
"outputs": [],
|
17 |
"source": [
|
|
|
|
|
|
|
|
|
18 |
"#%pip install -q gradio\n",
|
19 |
"#%pip install fastbook\n",
|
20 |
"#%pip install -Uqq fastai"
|
@@ -22,11 +48,13 @@
|
|
22 |
},
|
23 |
{
|
24 |
"cell_type": "code",
|
25 |
-
"execution_count":
|
26 |
"id": "a89a7628",
|
27 |
"metadata": {},
|
28 |
"outputs": [],
|
29 |
"source": [
|
|
|
|
|
30 |
"import fastbook\n",
|
31 |
"fastbook.setup_book()\n",
|
32 |
"from fastbook import *\n",
|
@@ -37,26 +65,30 @@
|
|
37 |
},
|
38 |
{
|
39 |
"cell_type": "code",
|
40 |
-
"execution_count":
|
41 |
"id": "8c95d6bd",
|
42 |
"metadata": {},
|
43 |
"outputs": [],
|
44 |
"source": [
|
|
|
|
|
|
|
45 |
"#!pip uninstall Pillow\n",
|
46 |
-
"#!pip install Pillow
|
47 |
-
"# import PIL.Image\n",
|
48 |
-
"# if not hasattr(PIL.Image, 'Resampling'): # Pillow<9.0\n",
|
49 |
-
"# PIL.Image.Resampling = PIL.Image\n",
|
50 |
-
"# Now PIL.Image.Resampling.BICUBIC is always recognized."
|
51 |
]
|
52 |
},
|
53 |
{
|
54 |
"cell_type": "code",
|
55 |
-
"execution_count":
|
56 |
"id": "fe4889a5",
|
57 |
"metadata": {},
|
58 |
"outputs": [],
|
59 |
"source": [
|
|
|
|
|
|
|
|
|
|
|
60 |
"import pathlib\n",
|
61 |
"temp = pathlib.PosixPath\n",
|
62 |
"pathlib.PosixPath = pathlib.WindowsPath"
|
@@ -64,7 +96,7 @@
|
|
64 |
},
|
65 |
{
|
66 |
"cell_type": "code",
|
67 |
-
"execution_count":
|
68 |
"id": "d1d0d596",
|
69 |
"metadata": {},
|
70 |
"outputs": [
|
@@ -90,23 +122,17 @@
|
|
90 |
"\n",
|
91 |
"To create a public link, set `share=True` in `launch()`.\n"
|
92 |
]
|
93 |
-
},
|
94 |
-
{
|
95 |
-
"data": {
|
96 |
-
"text/plain": [
|
97 |
-
"(<gradio.routes.App at 0x2b7e98ecca0>, 'http://127.0.0.1:7860/', None)"
|
98 |
-
]
|
99 |
-
},
|
100 |
-
"execution_count": 5,
|
101 |
-
"metadata": {},
|
102 |
-
"output_type": "execute_result"
|
103 |
}
|
104 |
],
|
105 |
"source": [
|
106 |
-
"
|
107 |
-
"learn_inf.
|
|
|
108 |
"categories = learn_inf.dls.vocab\n",
|
109 |
"\n",
|
|
|
|
|
|
|
110 |
"def classify_image(img):\n",
|
111 |
" pred, idx, probs = learn_inf.predict(img)\n",
|
112 |
" return dict(zip(categories, map(float,probs)))\n",
|
@@ -118,6 +144,23 @@
|
|
118 |
"intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples)\n",
|
119 |
"intf.launch(inline=False)"
|
120 |
]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
121 |
}
|
122 |
],
|
123 |
"metadata": {
|
|
|
2 |
"cells": [
|
3 |
{
|
4 |
"cell_type": "markdown",
|
5 |
+
"id": "fb0b148e",
|
6 |
"metadata": {},
|
7 |
"source": [
|
8 |
+
"# This notebook is the .ipynb file for the model. \n",
|
9 |
+
"The code has been commmented in order to explain various parts, including the unused commented out parts."
|
10 |
]
|
11 |
},
|
12 |
{
|
13 |
"cell_type": "code",
|
14 |
"execution_count": 1,
|
15 |
+
"id": "e39e2ed1",
|
16 |
+
"metadata": {},
|
17 |
+
"outputs": [],
|
18 |
+
"source": [
|
19 |
+
"#|default_exp app"
|
20 |
+
]
|
21 |
+
},
|
22 |
+
{
|
23 |
+
"cell_type": "code",
|
24 |
+
"execution_count": 2,
|
25 |
+
"id": "d671a893",
|
26 |
+
"metadata": {},
|
27 |
+
"outputs": [],
|
28 |
+
"source": [
|
29 |
+
"# The various ~| comments are needed to turn this into a .py file\n",
|
30 |
+
"# The export comments specify to export said cell"
|
31 |
+
]
|
32 |
+
},
|
33 |
+
{
|
34 |
+
"cell_type": "code",
|
35 |
+
"execution_count": 3,
|
36 |
"id": "435a6f23",
|
37 |
"metadata": {},
|
38 |
"outputs": [],
|
39 |
"source": [
|
40 |
+
"# On my computer, I use Anaconda, where these packages are already installed, so there is no need to install them on the notebook\n",
|
41 |
+
"# On HuggingFaceSpaces, these packages have been put into requirements.txt so that the website installs them\n",
|
42 |
+
"# Therefore there is no need to install them \n",
|
43 |
+
"\n",
|
44 |
"#%pip install -q gradio\n",
|
45 |
"#%pip install fastbook\n",
|
46 |
"#%pip install -Uqq fastai"
|
|
|
48 |
},
|
49 |
{
|
50 |
"cell_type": "code",
|
51 |
+
"execution_count": 4,
|
52 |
"id": "a89a7628",
|
53 |
"metadata": {},
|
54 |
"outputs": [],
|
55 |
"source": [
|
56 |
+
"#|export\n",
|
57 |
+
"# Importing neccesary modules\n",
|
58 |
"import fastbook\n",
|
59 |
"fastbook.setup_book()\n",
|
60 |
"from fastbook import *\n",
|
|
|
65 |
},
|
66 |
{
|
67 |
"cell_type": "code",
|
68 |
+
"execution_count": 5,
|
69 |
"id": "8c95d6bd",
|
70 |
"metadata": {},
|
71 |
"outputs": [],
|
72 |
"source": [
|
73 |
+
"# There was an error with the module Pillow, it was not updated and I attempted to update it within the notebook\n",
|
74 |
+
"# This was not neccesary as I updated Pillow on my anaconda app and it fixed it.\n",
|
75 |
+
"\n",
|
76 |
"#!pip uninstall Pillow\n",
|
77 |
+
"#!pip install Pillow"
|
|
|
|
|
|
|
|
|
78 |
]
|
79 |
},
|
80 |
{
|
81 |
"cell_type": "code",
|
82 |
+
"execution_count": 6,
|
83 |
"id": "fe4889a5",
|
84 |
"metadata": {},
|
85 |
"outputs": [],
|
86 |
"source": [
|
87 |
+
"# There was an error the first time I ran this code on the notebook: \"NotImplementedError: cannot instantiate 'PosixPath' on your system\"\n",
|
88 |
+
"# this code fixed it, but as it is suited for windows,\n",
|
89 |
+
"# this causes an error on HuggingSpaceFaces, which likely uses linux. \n",
|
90 |
+
"# Strangely, simply commenting this code out does not cause the initial error on HuggingFaceSpaces and works for it\n",
|
91 |
+
"\n",
|
92 |
"import pathlib\n",
|
93 |
"temp = pathlib.PosixPath\n",
|
94 |
"pathlib.PosixPath = pathlib.WindowsPath"
|
|
|
96 |
},
|
97 |
{
|
98 |
"cell_type": "code",
|
99 |
+
"execution_count": null,
|
100 |
"id": "d1d0d596",
|
101 |
"metadata": {},
|
102 |
"outputs": [
|
|
|
122 |
"\n",
|
123 |
"To create a public link, set `share=True` in `launch()`.\n"
|
124 |
]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
125 |
}
|
126 |
],
|
127 |
"source": [
|
128 |
+
"#|export\n",
|
129 |
+
"learn_inf = load_learner('NovaOrToastModel.pkl') # Loading the model\n",
|
130 |
+
"learn_inf.dls.vocab # Returns a list of the categories\n",
|
131 |
"categories = learn_inf.dls.vocab\n",
|
132 |
"\n",
|
133 |
+
"# Gradio code:\n",
|
134 |
+
"\n",
|
135 |
+
"# Function for Gradio to use to classify images\n",
|
136 |
"def classify_image(img):\n",
|
137 |
" pred, idx, probs = learn_inf.predict(img)\n",
|
138 |
" return dict(zip(categories, map(float,probs)))\n",
|
|
|
144 |
"intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples)\n",
|
145 |
"intf.launch(inline=False)"
|
146 |
]
|
147 |
+
},
|
148 |
+
{
|
149 |
+
"cell_type": "code",
|
150 |
+
"execution_count": null,
|
151 |
+
"id": "300585db",
|
152 |
+
"metadata": {},
|
153 |
+
"outputs": [],
|
154 |
+
"source": [
|
155 |
+
"# Notebook2script simply turns the specified cells into a .py file for usage in HuggingFaceSpaces\n",
|
156 |
+
"from nbdev.export import notebook2script\n",
|
157 |
+
"\n",
|
158 |
+
"# There were many problems getting notebook2script to work\n",
|
159 |
+
"# The fix was to add a text document into the folder called 'settings.ini', for which I used the author's standard settings\n",
|
160 |
+
"# which works\n",
|
161 |
+
"\n",
|
162 |
+
"notebook2script('NovaOrToast.ipynb')"
|
163 |
+
]
|
164 |
}
|
165 |
],
|
166 |
"metadata": {
|
app.ipynb
CHANGED
@@ -11,7 +11,7 @@
|
|
11 |
},
|
12 |
{
|
13 |
"cell_type": "code",
|
14 |
-
"execution_count":
|
15 |
"id": "e39e2ed1",
|
16 |
"metadata": {},
|
17 |
"outputs": [],
|
@@ -21,7 +21,18 @@
|
|
21 |
},
|
22 |
{
|
23 |
"cell_type": "code",
|
24 |
-
"execution_count":
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
25 |
"id": "435a6f23",
|
26 |
"metadata": {},
|
27 |
"outputs": [],
|
@@ -37,7 +48,7 @@
|
|
37 |
},
|
38 |
{
|
39 |
"cell_type": "code",
|
40 |
-
"execution_count":
|
41 |
"id": "a89a7628",
|
42 |
"metadata": {},
|
43 |
"outputs": [],
|
@@ -54,7 +65,7 @@
|
|
54 |
},
|
55 |
{
|
56 |
"cell_type": "code",
|
57 |
-
"execution_count":
|
58 |
"id": "8c95d6bd",
|
59 |
"metadata": {},
|
60 |
"outputs": [],
|
@@ -68,7 +79,7 @@
|
|
68 |
},
|
69 |
{
|
70 |
"cell_type": "code",
|
71 |
-
"execution_count":
|
72 |
"id": "fe4889a5",
|
73 |
"metadata": {},
|
74 |
"outputs": [],
|
@@ -85,7 +96,7 @@
|
|
85 |
},
|
86 |
{
|
87 |
"cell_type": "code",
|
88 |
-
"execution_count":
|
89 |
"id": "d1d0d596",
|
90 |
"metadata": {},
|
91 |
"outputs": [
|
@@ -107,7 +118,7 @@
|
|
107 |
"name": "stdout",
|
108 |
"output_type": "stream",
|
109 |
"text": [
|
110 |
-
"Running on local URL: http://127.0.0.1:
|
111 |
"\n",
|
112 |
"To create a public link, set `share=True` in `launch()`.\n"
|
113 |
]
|
@@ -115,10 +126,10 @@
|
|
115 |
{
|
116 |
"data": {
|
117 |
"text/plain": [
|
118 |
-
"(<gradio.routes.App at
|
119 |
]
|
120 |
},
|
121 |
-
"execution_count":
|
122 |
"metadata": {},
|
123 |
"output_type": "execute_result"
|
124 |
}
|
@@ -144,48 +155,37 @@
|
|
144 |
"intf.launch(inline=False)"
|
145 |
]
|
146 |
},
|
147 |
-
{
|
148 |
-
"cell_type": "code",
|
149 |
-
"execution_count": 16,
|
150 |
-
"id": "300585db",
|
151 |
-
"metadata": {},
|
152 |
-
"outputs": [],
|
153 |
-
"source": [
|
154 |
-
"from nbdev.export import notebook2script"
|
155 |
-
]
|
156 |
-
},
|
157 |
{
|
158 |
"cell_type": "code",
|
159 |
"execution_count": 17,
|
160 |
-
"id": "
|
161 |
-
"metadata": {},
|
162 |
-
"outputs": [],
|
163 |
-
"source": [
|
164 |
-
"#from nbdev import get_config\n",
|
165 |
-
"#get_config (cfg_name='settings.ini', path=None)\n",
|
166 |
-
"#get_config (cfg_name='settings.ini')"
|
167 |
-
]
|
168 |
-
},
|
169 |
-
{
|
170 |
-
"cell_type": "code",
|
171 |
-
"execution_count": 20,
|
172 |
-
"id": "fad6e0cf",
|
173 |
"metadata": {},
|
174 |
"outputs": [
|
175 |
{
|
176 |
-
"ename": "
|
177 |
-
"evalue": "
|
178 |
"output_type": "error",
|
179 |
"traceback": [
|
180 |
"\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
|
181 |
-
"\u001b[1;
|
182 |
-
"Input \u001b[1;32mIn [
|
183 |
-
"\u001b[1;
|
|
|
|
|
|
|
184 |
]
|
185 |
}
|
186 |
],
|
187 |
"source": [
|
188 |
-
"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
189 |
]
|
190 |
}
|
191 |
],
|
|
|
11 |
},
|
12 |
{
|
13 |
"cell_type": "code",
|
14 |
+
"execution_count": 1,
|
15 |
"id": "e39e2ed1",
|
16 |
"metadata": {},
|
17 |
"outputs": [],
|
|
|
21 |
},
|
22 |
{
|
23 |
"cell_type": "code",
|
24 |
+
"execution_count": 2,
|
25 |
+
"id": "35ff6d9b",
|
26 |
+
"metadata": {},
|
27 |
+
"outputs": [],
|
28 |
+
"source": [
|
29 |
+
"# The various ~| comments are needed to turn this into a .py file\n",
|
30 |
+
"# The export comments specify to export said cell"
|
31 |
+
]
|
32 |
+
},
|
33 |
+
{
|
34 |
+
"cell_type": "code",
|
35 |
+
"execution_count": 3,
|
36 |
"id": "435a6f23",
|
37 |
"metadata": {},
|
38 |
"outputs": [],
|
|
|
48 |
},
|
49 |
{
|
50 |
"cell_type": "code",
|
51 |
+
"execution_count": 4,
|
52 |
"id": "a89a7628",
|
53 |
"metadata": {},
|
54 |
"outputs": [],
|
|
|
65 |
},
|
66 |
{
|
67 |
"cell_type": "code",
|
68 |
+
"execution_count": 5,
|
69 |
"id": "8c95d6bd",
|
70 |
"metadata": {},
|
71 |
"outputs": [],
|
|
|
79 |
},
|
80 |
{
|
81 |
"cell_type": "code",
|
82 |
+
"execution_count": 6,
|
83 |
"id": "fe4889a5",
|
84 |
"metadata": {},
|
85 |
"outputs": [],
|
|
|
96 |
},
|
97 |
{
|
98 |
"cell_type": "code",
|
99 |
+
"execution_count": 7,
|
100 |
"id": "d1d0d596",
|
101 |
"metadata": {},
|
102 |
"outputs": [
|
|
|
118 |
"name": "stdout",
|
119 |
"output_type": "stream",
|
120 |
"text": [
|
121 |
+
"Running on local URL: http://127.0.0.1:7860\n",
|
122 |
"\n",
|
123 |
"To create a public link, set `share=True` in `launch()`.\n"
|
124 |
]
|
|
|
126 |
{
|
127 |
"data": {
|
128 |
"text/plain": [
|
129 |
+
"(<gradio.routes.App at 0x20adf46c250>, 'http://127.0.0.1:7860/', None)"
|
130 |
]
|
131 |
},
|
132 |
+
"execution_count": 7,
|
133 |
"metadata": {},
|
134 |
"output_type": "execute_result"
|
135 |
}
|
|
|
155 |
"intf.launch(inline=False)"
|
156 |
]
|
157 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
158 |
{
|
159 |
"cell_type": "code",
|
160 |
"execution_count": 17,
|
161 |
+
"id": "300585db",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
162 |
"metadata": {},
|
163 |
"outputs": [
|
164 |
{
|
165 |
+
"ename": "FileNotFoundError",
|
166 |
+
"evalue": "[Errno 2] No such file or directory: 'C:\\\\Users\\\\Adnan\\\\Downloads\\\\Fast AI\\\\Lesson 2 Git\\\\NovaOrToast\\\\NovaOrToast\\\\nbdev\\\\_nbdev.py'",
|
167 |
"output_type": "error",
|
168 |
"traceback": [
|
169 |
"\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
|
170 |
+
"\u001b[1;31mFileNotFoundError\u001b[0m Traceback (most recent call last)",
|
171 |
+
"Input \u001b[1;32mIn [17]\u001b[0m, in \u001b[0;36m<cell line: 8>\u001b[1;34m()\u001b[0m\n\u001b[0;32m 2\u001b[0m \u001b[38;5;28;01mfrom\u001b[39;00m \u001b[38;5;21;01mnbdev\u001b[39;00m\u001b[38;5;21;01m.\u001b[39;00m\u001b[38;5;21;01mexport\u001b[39;00m \u001b[38;5;28;01mimport\u001b[39;00m notebook2script\n\u001b[0;32m 4\u001b[0m \u001b[38;5;66;03m# There were many problems getting notebook2script to work\u001b[39;00m\n\u001b[0;32m 5\u001b[0m \u001b[38;5;66;03m# The fix was to add a text document into the folder called 'settings.ini', for which I used the author's standard settings\u001b[39;00m\n\u001b[0;32m 6\u001b[0m \u001b[38;5;66;03m# which works\u001b[39;00m\n\u001b[1;32m----> 8\u001b[0m \u001b[43mnotebook2script\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[38;5;124;43mapp.ipynb\u001b[39;49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[43m)\u001b[49m\n",
|
172 |
+
"File \u001b[1;32m~\\anaconda3\\lib\\site-packages\\nbdev\\export.py:445\u001b[0m, in \u001b[0;36mnotebook2script\u001b[1;34m(fname, silent, to_dict, bare)\u001b[0m\n\u001b[0;32m 443\u001b[0m d \u001b[38;5;241m=\u001b[39m collections\u001b[38;5;241m.\u001b[39mdefaultdict(\u001b[38;5;28mlist\u001b[39m) \u001b[38;5;28;01mif\u001b[39;00m to_dict \u001b[38;5;28;01melse\u001b[39;00m \u001b[38;5;28;01mNone\u001b[39;00m\n\u001b[0;32m 444\u001b[0m modules \u001b[38;5;241m=\u001b[39m create_mod_files(files, to_dict, bare\u001b[38;5;241m=\u001b[39mbare)\n\u001b[1;32m--> 445\u001b[0m \u001b[38;5;28;01mfor\u001b[39;00m f \u001b[38;5;129;01min\u001b[39;00m \u001b[38;5;28msorted\u001b[39m(files): d \u001b[38;5;241m=\u001b[39m \u001b[43m_notebook2script\u001b[49m\u001b[43m(\u001b[49m\u001b[43mf\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mmodules\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43msilent\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43msilent\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mto_dict\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43md\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mbare\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mbare\u001b[49m\u001b[43m)\u001b[49m\n\u001b[0;32m 446\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m to_dict: \u001b[38;5;28;01mreturn\u001b[39;00m d\n\u001b[0;32m 447\u001b[0m \u001b[38;5;28;01melif\u001b[39;00m fname \u001b[38;5;129;01mis\u001b[39;00m \u001b[38;5;28;01mNone\u001b[39;00m: add_init(get_config()\u001b[38;5;241m.\u001b[39mpath(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mlib_path\u001b[39m\u001b[38;5;124m\"\u001b[39m))\n",
|
173 |
+
"File \u001b[1;32m~\\anaconda3\\lib\\site-packages\\nbdev\\export.py:380\u001b[0m, in \u001b[0;36m_notebook2script\u001b[1;34m(fname, modules, silent, to_dict, bare)\u001b[0m\n\u001b[0;32m 378\u001b[0m \u001b[38;5;28;01mwith\u001b[39;00m \u001b[38;5;28mopen\u001b[39m(fname_out, \u001b[38;5;124m'\u001b[39m\u001b[38;5;124ma\u001b[39m\u001b[38;5;124m'\u001b[39m, encoding\u001b[38;5;241m=\u001b[39m\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mutf8\u001b[39m\u001b[38;5;124m'\u001b[39m) \u001b[38;5;28;01mas\u001b[39;00m f: f\u001b[38;5;241m.\u001b[39mwrite(code)\n\u001b[0;32m 379\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;124mf\u001b[39m\u001b[38;5;124m'\u001b[39m\u001b[38;5;132;01m{\u001b[39;00me\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m.py\u001b[39m\u001b[38;5;124m'\u001b[39m \u001b[38;5;129;01mnot\u001b[39;00m \u001b[38;5;129;01min\u001b[39;00m mod\u001b[38;5;241m.\u001b[39mmodules: mod\u001b[38;5;241m.\u001b[39mmodules\u001b[38;5;241m.\u001b[39mappend(\u001b[38;5;124mf\u001b[39m\u001b[38;5;124m'\u001b[39m\u001b[38;5;132;01m{\u001b[39;00me\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m.py\u001b[39m\u001b[38;5;124m'\u001b[39m)\n\u001b[1;32m--> 380\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m has_setting: \u001b[43msave_nbdev_module\u001b[49m\u001b[43m(\u001b[49m\u001b[43mmod\u001b[49m\u001b[43m)\u001b[49m\n\u001b[0;32m 382\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m silent: \u001b[38;5;28mprint\u001b[39m(\u001b[38;5;124mf\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mConverted \u001b[39m\u001b[38;5;132;01m{\u001b[39;00mfname\u001b[38;5;241m.\u001b[39mname\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m.\u001b[39m\u001b[38;5;124m\"\u001b[39m)\n\u001b[0;32m 383\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m to_dict\n",
|
174 |
+
"File \u001b[1;32m~\\anaconda3\\lib\\site-packages\\nbdev\\export.py:290\u001b[0m, in \u001b[0;36msave_nbdev_module\u001b[1;34m(mod)\u001b[0m\n\u001b[0;32m 288\u001b[0m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mSave `mod` inside <code>_nbdev</code>\u001b[39m\u001b[38;5;124m\"\u001b[39m\n\u001b[0;32m 289\u001b[0m fname \u001b[38;5;241m=\u001b[39m get_config()\u001b[38;5;241m.\u001b[39mpath(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mlib_path\u001b[39m\u001b[38;5;124m\"\u001b[39m)\u001b[38;5;241m/\u001b[39m\u001b[38;5;124m'\u001b[39m\u001b[38;5;124m_nbdev.py\u001b[39m\u001b[38;5;124m'\u001b[39m\n\u001b[1;32m--> 290\u001b[0m \u001b[38;5;28;01mwith\u001b[39;00m \u001b[38;5;28;43mopen\u001b[39;49m\u001b[43m(\u001b[49m\u001b[43mfname\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[38;5;124;43mr\u001b[39;49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[43m)\u001b[49m \u001b[38;5;28;01mas\u001b[39;00m f: code \u001b[38;5;241m=\u001b[39m f\u001b[38;5;241m.\u001b[39mread()\n\u001b[0;32m 291\u001b[0m t \u001b[38;5;241m=\u001b[39m \u001b[38;5;124mr\u001b[39m\u001b[38;5;124m'\u001b[39m\u001b[38;5;124m,\u001b[39m\u001b[38;5;124m\\\u001b[39m\u001b[38;5;124mn \u001b[39m\u001b[38;5;124m'\u001b[39m\u001b[38;5;241m.\u001b[39mjoin([\u001b[38;5;124mf\u001b[39m\u001b[38;5;124m'\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;132;01m{\u001b[39;00mk\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124m: \u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;132;01m{\u001b[39;00mv\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124m'\u001b[39m \u001b[38;5;28;01mfor\u001b[39;00m k,v \u001b[38;5;129;01min\u001b[39;00m mod\u001b[38;5;241m.\u001b[39mindex\u001b[38;5;241m.\u001b[39mitems()])\n\u001b[0;32m 292\u001b[0m code \u001b[38;5;241m=\u001b[39m _re_index_idx\u001b[38;5;241m.\u001b[39msub(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mindex = \u001b[39m\u001b[38;5;124m{\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;241m+\u001b[39m t \u001b[38;5;241m+\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124m}\u001b[39m\u001b[38;5;124m\"\u001b[39m, code)\n",
|
175 |
+
"\u001b[1;31mFileNotFoundError\u001b[0m: [Errno 2] No such file or directory: 'C:\\\\Users\\\\Adnan\\\\Downloads\\\\Fast AI\\\\Lesson 2 Git\\\\NovaOrToast\\\\NovaOrToast\\\\nbdev\\\\_nbdev.py'"
|
176 |
]
|
177 |
}
|
178 |
],
|
179 |
"source": [
|
180 |
+
"# Notebook2script simply turns the specified cells into a .py file for usage in HuggingFaceSpaces\n",
|
181 |
+
"from nbdev.export import notebook2script\n",
|
182 |
+
"\n",
|
183 |
+
"# There were many problems getting notebook2script to work\n",
|
184 |
+
"# The fix was to add a text document into the folder called 'settings.ini', for which I used the author's standard settings\n",
|
185 |
+
"# This works. It creates a file called app.py and a folder called nbdev to place it in\n",
|
186 |
+
"# But it returns the error \"FileNotFoundError: [Errno 2] No such file or directory: 'C:\\\\Users\\\\Adnan\\\\Downloads\\\\Fast AI\\\\Lesson 2 Git\\\\NovaOrToast\\\\NovaOrToast\\\\nbdev\\\\_nbdev.py'\"\n",
|
187 |
+
"\n",
|
188 |
+
"notebook2script('app.ipynb')"
|
189 |
]
|
190 |
}
|
191 |
],
|