continuouslearnerforever commited on
Commit
a7397f8
·
1 Parent(s): fdab041

Update examples path relative

Browse files
Files changed (2) hide show
  1. nbs/app.ipynb +10 -42
  2. nbs/app.py +9 -6
nbs/app.ipynb CHANGED
@@ -91,7 +91,7 @@
91
  },
92
  {
93
  "cell_type": "code",
94
- "execution_count": 15,
95
  "id": "e77f8a97-e73f-4c3b-a73d-a958689ff1a6",
96
  "metadata": {},
97
  "outputs": [
@@ -99,7 +99,7 @@
99
  "name": "stdout",
100
  "output_type": "stream",
101
  "text": [
102
- "* Running on local URL: http://127.0.0.1:7861\n",
103
  "\n",
104
  "To create a public link, set `share=True` in `launch()`.\n"
105
  ]
@@ -108,7 +108,7 @@
108
  "data": {
109
  "text/plain": []
110
  },
111
- "execution_count": 15,
112
  "metadata": {},
113
  "output_type": "execute_result"
114
  },
@@ -139,43 +139,6 @@
139
  "metadata": {},
140
  "output_type": "display_data"
141
  },
142
- {
143
- "data": {
144
- "text/html": [],
145
- "text/plain": [
146
- "<IPython.core.display.HTML object>"
147
- ]
148
- },
149
- "metadata": {},
150
- "output_type": "display_data"
151
- },
152
- {
153
- "data": {
154
- "text/html": [
155
- "\n",
156
- "<style>\n",
157
- " /* Turns off some styling */\n",
158
- " progress {\n",
159
- " /* gets rid of default border in Firefox and Opera. */\n",
160
- " border: none;\n",
161
- " /* Needs to be in here for Safari polyfill so background images work as expected. */\n",
162
- " background-size: auto;\n",
163
- " }\n",
164
- " progress:not([value]), progress:not([value])::-webkit-progress-bar {\n",
165
- " background: repeating-linear-gradient(45deg, #7e7e7e, #7e7e7e 10px, #5c5c5c 10px, #5c5c5c 20px);\n",
166
- " }\n",
167
- " .progress-bar-interrupted, .progress-bar-interrupted::-webkit-progress-bar {\n",
168
- " background: #F44336;\n",
169
- " }\n",
170
- "</style>\n"
171
- ],
172
- "text/plain": [
173
- "<IPython.core.display.HTML object>"
174
- ]
175
- },
176
- "metadata": {},
177
- "output_type": "display_data"
178
- },
179
  {
180
  "data": {
181
  "text/html": [],
@@ -191,7 +154,12 @@
191
  "#|export\n",
192
  "image = gr.Image(type=\"pil\")\n",
193
  "label = gr.Label()\n",
194
- "examples = ['black_bear.jpg', 'grizzly_bear.jpg', 'teddy_bear.jpg']\n",
 
 
 
 
 
195
  "\n",
196
  "intf = gr.Interface(\n",
197
  " fn=classify_image, \n",
@@ -213,7 +181,7 @@
213
  },
214
  {
215
  "cell_type": "code",
216
- "execution_count": 16,
217
  "id": "af0ec285-9e53-49f0-be57-12d4e1fc1a3c",
218
  "metadata": {},
219
  "outputs": [],
 
91
  },
92
  {
93
  "cell_type": "code",
94
+ "execution_count": 19,
95
  "id": "e77f8a97-e73f-4c3b-a73d-a958689ff1a6",
96
  "metadata": {},
97
  "outputs": [
 
99
  "name": "stdout",
100
  "output_type": "stream",
101
  "text": [
102
+ "* Running on local URL: http://127.0.0.1:7863\n",
103
  "\n",
104
  "To create a public link, set `share=True` in `launch()`.\n"
105
  ]
 
108
  "data": {
109
  "text/plain": []
110
  },
111
+ "execution_count": 19,
112
  "metadata": {},
113
  "output_type": "execute_result"
114
  },
 
139
  "metadata": {},
140
  "output_type": "display_data"
141
  },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
142
  {
143
  "data": {
144
  "text/html": [],
 
154
  "#|export\n",
155
  "image = gr.Image(type=\"pil\")\n",
156
  "label = gr.Label()\n",
157
+ "\n",
158
+ "examples = [\n",
159
+ " path / 'black_bear.jpg',\n",
160
+ " path / 'grizzly_bear.jpg',\n",
161
+ " path / 'teddy_bear.jpg'\n",
162
+ " ]\n",
163
  "\n",
164
  "intf = gr.Interface(\n",
165
  " fn=classify_image, \n",
 
181
  },
182
  {
183
  "cell_type": "code",
184
+ "execution_count": 21,
185
  "id": "af0ec285-9e53-49f0-be57-12d4e1fc1a3c",
186
  "metadata": {},
187
  "outputs": [],
nbs/app.py CHANGED
@@ -17,16 +17,14 @@ try:
17
  path = pathlib.Path(__file__).parent.resolve()
18
  except NameError:
19
  if 'SPACE_ID' in os.environ:
20
- path = pathlib.Path('nbs')
21
-
22
 
23
- # Construct the final path to the model
24
  model_path = path / 'model.pkl'
25
 
26
- learn = load_learner('./nbs/model.pkl')
27
 
28
  # %% app.ipynb 5
29
- categories = ('Black','Grizzly','Teddy')
30
 
31
  def classify_image(img):
32
  pred,idx,probs = learn.predict(img)
@@ -35,7 +33,12 @@ def classify_image(img):
35
  # %% app.ipynb 6
36
  image = gr.Image(type="pil")
37
  label = gr.Label()
38
- examples = ['black_bear.jpg', 'grizzly_bear.jpg', 'teddy_bear.jpg']
 
 
 
 
 
39
 
40
  intf = gr.Interface(
41
  fn=classify_image,
 
17
  path = pathlib.Path(__file__).parent.resolve()
18
  except NameError:
19
  if 'SPACE_ID' in os.environ:
20
+ path = pathlib.Path('nbs')
 
21
 
 
22
  model_path = path / 'model.pkl'
23
 
24
+ learn = load_learner(model_path)
25
 
26
  # %% app.ipynb 5
27
+ categories = learn.dls.vocab
28
 
29
  def classify_image(img):
30
  pred,idx,probs = learn.predict(img)
 
33
  # %% app.ipynb 6
34
  image = gr.Image(type="pil")
35
  label = gr.Label()
36
+
37
+ examples = [
38
+ path / 'black_bear.jpg',
39
+ path / 'grizzly_bear.jpg',
40
+ path / 'teddy_bear.jpg'
41
+ ]
42
 
43
  intf = gr.Interface(
44
  fn=classify_image,