lordsquirrel commited on
Commit
5056593
1 Parent(s): 6425640

Improved model quite a lot

Browse files
Files changed (6) hide show
  1. albani3.jpg +0 -0
  2. demo.py +4 -5
  3. model-gym.ipynb +0 -0
  4. model-test.ipynb +193 -12
  5. resnet18-albani.pkl +2 -2
  6. trainingdata.zip +2 -2
albani3.jpg ADDED
demo.py CHANGED
@@ -1,7 +1,7 @@
1
  # AUTOGENERATED! DO NOT EDIT! File to edit: model-test.ipynb.
2
 
3
  # %% auto 0
4
- __all__ = ['plt', 'learn', 'categories', 'description', 'image', 'label', 'examples', 'iface', 'is_albani', 'classify_image']
5
 
6
  # %% model-test.ipynb 2
7
  from fastai.vision.all import *
@@ -10,12 +10,11 @@ import gradio as gr
10
  plt = platform.system()
11
  if plt == 'Linux': pathlib.WindowsPath = pathlib.PosixPath
12
 
13
- def is_albani(path):
14
- return parent_label(path) == "albani"
15
 
16
  # %% model-test.ipynb 7
17
  learn = load_learner(Path('./resnet18-albani.pkl'))
18
- categories = ('Dårlig Øl', 'God Øl')
19
 
20
  def classify_image(img):
21
  pred,idx,probs = learn.predict(img)
@@ -27,7 +26,7 @@ description = """
27
  """
28
  image = gr.Image(shape=(192, 192))
29
  label = gr.Label()
30
- examples = ['albani.jpg', 'albani2.jpg', 'heineken.jpg', 'carlsberg.jpg']
31
 
32
  iface = gr.Interface(
33
  fn=classify_image,
 
1
  # AUTOGENERATED! DO NOT EDIT! File to edit: model-test.ipynb.
2
 
3
  # %% auto 0
4
+ __all__ = ['plt', 'learn', 'categories', 'description', 'image', 'label', 'examples', 'iface', 'classify_image']
5
 
6
  # %% model-test.ipynb 2
7
  from fastai.vision.all import *
 
10
  plt = platform.system()
11
  if plt == 'Linux': pathlib.WindowsPath = pathlib.PosixPath
12
 
13
+
 
14
 
15
  # %% model-test.ipynb 7
16
  learn = load_learner(Path('./resnet18-albani.pkl'))
17
+ categories = ('God Øl', 'Dårlig Øl')
18
 
19
  def classify_image(img):
20
  pred,idx,probs = learn.predict(img)
 
26
  """
27
  image = gr.Image(shape=(192, 192))
28
  label = gr.Label()
29
+ examples = ['albani.jpg', 'albani2.jpg', 'albani3.jpg', 'heineken.jpg', 'carlsberg.jpg']
30
 
31
  iface = gr.Interface(
32
  fn=classify_image,
model-gym.ipynb CHANGED
The diff for this file is too large to render. See raw diff
 
model-test.ipynb CHANGED
@@ -2,7 +2,7 @@
2
  "cells": [
3
  {
4
  "cell_type": "code",
5
- "execution_count": null,
6
  "metadata": {},
7
  "outputs": [],
8
  "source": [
@@ -19,7 +19,7 @@
19
  },
20
  {
21
  "cell_type": "code",
22
- "execution_count": 23,
23
  "metadata": {},
24
  "outputs": [],
25
  "source": [
@@ -29,9 +29,7 @@
29
  "import gradio as gr\n",
30
  "plt = platform.system()\n",
31
  "if plt == 'Linux': pathlib.WindowsPath = pathlib.PosixPath\n",
32
- "\n",
33
- "def is_albani(path):\n",
34
- " return parent_label(path) == \"albani\""
35
  ]
36
  },
37
  {
@@ -75,16 +73,14 @@
75
  },
76
  {
77
  "cell_type": "code",
78
- "execution_count": 50,
79
  "metadata": {},
80
  "outputs": [
81
  {
82
  "name": "stdout",
83
  "output_type": "stream",
84
  "text": [
85
- "\n",
86
- "Thanks for being a Gradio user! If you have questions or feedback, please join our Discord server and chat with us: https://discord.gg/feTf9x3ZSB\n",
87
- "Running on local URL: http://127.0.0.1:7877\n",
88
  "\n",
89
  "To create a public link, set `share=True` in `launch()`.\n"
90
  ]
@@ -93,16 +89,201 @@
93
  "data": {
94
  "text/plain": []
95
  },
96
- "execution_count": 50,
97
  "metadata": {},
98
  "output_type": "execute_result"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
99
  }
100
  ],
101
  "source": [
102
  "#|export\n",
103
  "\n",
104
  "learn = load_learner(Path('./resnet18-albani.pkl'))\n",
105
- "categories = ('Dårlig Øl', 'God Øl')\n",
106
  "\n",
107
  "def classify_image(img):\n",
108
  " pred,idx,probs = learn.predict(img)\n",
@@ -114,7 +295,7 @@
114
  "\"\"\"\n",
115
  "image = gr.Image(shape=(192, 192))\n",
116
  "label = gr.Label()\n",
117
- "examples = ['albani.jpg', 'albani2.jpg', 'heineken.jpg', 'carlsberg.jpg']\n",
118
  "\n",
119
  "iface = gr.Interface(\n",
120
  " fn=classify_image, \n",
 
2
  "cells": [
3
  {
4
  "cell_type": "code",
5
+ "execution_count": 2,
6
  "metadata": {},
7
  "outputs": [],
8
  "source": [
 
19
  },
20
  {
21
  "cell_type": "code",
22
+ "execution_count": 5,
23
  "metadata": {},
24
  "outputs": [],
25
  "source": [
 
29
  "import gradio as gr\n",
30
  "plt = platform.system()\n",
31
  "if plt == 'Linux': pathlib.WindowsPath = pathlib.PosixPath\n",
32
+ "\n"
 
 
33
  ]
34
  },
35
  {
 
73
  },
74
  {
75
  "cell_type": "code",
76
+ "execution_count": 7,
77
  "metadata": {},
78
  "outputs": [
79
  {
80
  "name": "stdout",
81
  "output_type": "stream",
82
  "text": [
83
+ "Running on local URL: http://127.0.0.1:7863\n",
 
 
84
  "\n",
85
  "To create a public link, set `share=True` in `launch()`.\n"
86
  ]
 
89
  "data": {
90
  "text/plain": []
91
  },
92
+ "execution_count": 7,
93
  "metadata": {},
94
  "output_type": "execute_result"
95
+ },
96
+ {
97
+ "data": {
98
+ "text/html": [
99
+ "\n",
100
+ "<style>\n",
101
+ " /* Turns off some styling */\n",
102
+ " progress {\n",
103
+ " /* gets rid of default border in Firefox and Opera. */\n",
104
+ " border: none;\n",
105
+ " /* Needs to be in here for Safari polyfill so background images work as expected. */\n",
106
+ " background-size: auto;\n",
107
+ " }\n",
108
+ " progress:not([value]), progress:not([value])::-webkit-progress-bar {\n",
109
+ " background: repeating-linear-gradient(45deg, #7e7e7e, #7e7e7e 10px, #5c5c5c 10px, #5c5c5c 20px);\n",
110
+ " }\n",
111
+ " .progress-bar-interrupted, .progress-bar-interrupted::-webkit-progress-bar {\n",
112
+ " background: #F44336;\n",
113
+ " }\n",
114
+ "</style>\n"
115
+ ],
116
+ "text/plain": [
117
+ "<IPython.core.display.HTML object>"
118
+ ]
119
+ },
120
+ "metadata": {},
121
+ "output_type": "display_data"
122
+ },
123
+ {
124
+ "data": {
125
+ "text/html": [],
126
+ "text/plain": [
127
+ "<IPython.core.display.HTML object>"
128
+ ]
129
+ },
130
+ "metadata": {},
131
+ "output_type": "display_data"
132
+ },
133
+ {
134
+ "data": {
135
+ "text/html": [
136
+ "\n",
137
+ "<style>\n",
138
+ " /* Turns off some styling */\n",
139
+ " progress {\n",
140
+ " /* gets rid of default border in Firefox and Opera. */\n",
141
+ " border: none;\n",
142
+ " /* Needs to be in here for Safari polyfill so background images work as expected. */\n",
143
+ " background-size: auto;\n",
144
+ " }\n",
145
+ " progress:not([value]), progress:not([value])::-webkit-progress-bar {\n",
146
+ " background: repeating-linear-gradient(45deg, #7e7e7e, #7e7e7e 10px, #5c5c5c 10px, #5c5c5c 20px);\n",
147
+ " }\n",
148
+ " .progress-bar-interrupted, .progress-bar-interrupted::-webkit-progress-bar {\n",
149
+ " background: #F44336;\n",
150
+ " }\n",
151
+ "</style>\n"
152
+ ],
153
+ "text/plain": [
154
+ "<IPython.core.display.HTML object>"
155
+ ]
156
+ },
157
+ "metadata": {},
158
+ "output_type": "display_data"
159
+ },
160
+ {
161
+ "data": {
162
+ "text/html": [],
163
+ "text/plain": [
164
+ "<IPython.core.display.HTML object>"
165
+ ]
166
+ },
167
+ "metadata": {},
168
+ "output_type": "display_data"
169
+ },
170
+ {
171
+ "data": {
172
+ "text/html": [
173
+ "\n",
174
+ "<style>\n",
175
+ " /* Turns off some styling */\n",
176
+ " progress {\n",
177
+ " /* gets rid of default border in Firefox and Opera. */\n",
178
+ " border: none;\n",
179
+ " /* Needs to be in here for Safari polyfill so background images work as expected. */\n",
180
+ " background-size: auto;\n",
181
+ " }\n",
182
+ " progress:not([value]), progress:not([value])::-webkit-progress-bar {\n",
183
+ " background: repeating-linear-gradient(45deg, #7e7e7e, #7e7e7e 10px, #5c5c5c 10px, #5c5c5c 20px);\n",
184
+ " }\n",
185
+ " .progress-bar-interrupted, .progress-bar-interrupted::-webkit-progress-bar {\n",
186
+ " background: #F44336;\n",
187
+ " }\n",
188
+ "</style>\n"
189
+ ],
190
+ "text/plain": [
191
+ "<IPython.core.display.HTML object>"
192
+ ]
193
+ },
194
+ "metadata": {},
195
+ "output_type": "display_data"
196
+ },
197
+ {
198
+ "data": {
199
+ "text/html": [],
200
+ "text/plain": [
201
+ "<IPython.core.display.HTML object>"
202
+ ]
203
+ },
204
+ "metadata": {},
205
+ "output_type": "display_data"
206
+ },
207
+ {
208
+ "data": {
209
+ "text/html": [
210
+ "\n",
211
+ "<style>\n",
212
+ " /* Turns off some styling */\n",
213
+ " progress {\n",
214
+ " /* gets rid of default border in Firefox and Opera. */\n",
215
+ " border: none;\n",
216
+ " /* Needs to be in here for Safari polyfill so background images work as expected. */\n",
217
+ " background-size: auto;\n",
218
+ " }\n",
219
+ " progress:not([value]), progress:not([value])::-webkit-progress-bar {\n",
220
+ " background: repeating-linear-gradient(45deg, #7e7e7e, #7e7e7e 10px, #5c5c5c 10px, #5c5c5c 20px);\n",
221
+ " }\n",
222
+ " .progress-bar-interrupted, .progress-bar-interrupted::-webkit-progress-bar {\n",
223
+ " background: #F44336;\n",
224
+ " }\n",
225
+ "</style>\n"
226
+ ],
227
+ "text/plain": [
228
+ "<IPython.core.display.HTML object>"
229
+ ]
230
+ },
231
+ "metadata": {},
232
+ "output_type": "display_data"
233
+ },
234
+ {
235
+ "data": {
236
+ "text/html": [],
237
+ "text/plain": [
238
+ "<IPython.core.display.HTML object>"
239
+ ]
240
+ },
241
+ "metadata": {},
242
+ "output_type": "display_data"
243
+ },
244
+ {
245
+ "data": {
246
+ "text/html": [
247
+ "\n",
248
+ "<style>\n",
249
+ " /* Turns off some styling */\n",
250
+ " progress {\n",
251
+ " /* gets rid of default border in Firefox and Opera. */\n",
252
+ " border: none;\n",
253
+ " /* Needs to be in here for Safari polyfill so background images work as expected. */\n",
254
+ " background-size: auto;\n",
255
+ " }\n",
256
+ " progress:not([value]), progress:not([value])::-webkit-progress-bar {\n",
257
+ " background: repeating-linear-gradient(45deg, #7e7e7e, #7e7e7e 10px, #5c5c5c 10px, #5c5c5c 20px);\n",
258
+ " }\n",
259
+ " .progress-bar-interrupted, .progress-bar-interrupted::-webkit-progress-bar {\n",
260
+ " background: #F44336;\n",
261
+ " }\n",
262
+ "</style>\n"
263
+ ],
264
+ "text/plain": [
265
+ "<IPython.core.display.HTML object>"
266
+ ]
267
+ },
268
+ "metadata": {},
269
+ "output_type": "display_data"
270
+ },
271
+ {
272
+ "data": {
273
+ "text/html": [],
274
+ "text/plain": [
275
+ "<IPython.core.display.HTML object>"
276
+ ]
277
+ },
278
+ "metadata": {},
279
+ "output_type": "display_data"
280
  }
281
  ],
282
  "source": [
283
  "#|export\n",
284
  "\n",
285
  "learn = load_learner(Path('./resnet18-albani.pkl'))\n",
286
+ "categories = ('God Øl', 'Dårlig Øl')\n",
287
  "\n",
288
  "def classify_image(img):\n",
289
  " pred,idx,probs = learn.predict(img)\n",
 
295
  "\"\"\"\n",
296
  "image = gr.Image(shape=(192, 192))\n",
297
  "label = gr.Label()\n",
298
+ "examples = ['albani.jpg', 'albani2.jpg', 'albani3.jpg', 'heineken.jpg', 'carlsberg.jpg']\n",
299
  "\n",
300
  "iface = gr.Interface(\n",
301
  " fn=classify_image, \n",
resnet18-albani.pkl CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:2eb8fa12c9ef55eec5acf5aa74bbbc590cd1fb09fb3d636d9ef7b506add06cfb
3
- size 46971313
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:627089adbb0053d085a8157ef9db5bd9bdfec3fc60ccb301c2c25dde4c54eb75
3
+ size 46967321
trainingdata.zip CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:f711980dee2ec8808f233497a9c1afbc7803e100f6dc16fde26b56c14c8c168b
3
- size 10748407
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:4643bbadaa2ba2b8557c722f6f02823fe07fdf9339a1a7b03aa350a0c28b78b4
3
+ size 23563235