lordsquirrel commited on
Commit
3dd905b
1 Parent(s): 7c6b981
Files changed (3) hide show
  1. demo.py +17 -4
  2. model-gym.ipynb +0 -0
  3. model-test.ipynb +20 -7
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', 'image', 'label', 'examples', 'iface', 'is_albani', 'classify_image']
5
 
6
  # %% model-test.ipynb 2
7
  from fastai.vision.all import *
@@ -21,10 +21,23 @@ def classify_image(img):
21
  pred,idx,probs = learn.predict(img)
22
  return dict(zip(categories, map(float, probs)))
23
 
24
- image = gr.inputs.Image(shape=(192, 192))
25
- label = gr.outputs.Label()
 
 
 
 
26
  examples = ['albani.jpg', 'albani2.jpg', 'heineken.jpg', 'carlsberg.jpg']
27
 
28
- iface = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples)
 
 
 
 
 
 
 
 
 
29
  iface.launch(inline=False)
30
 
 
1
  # AUTOGENERATED! DO NOT EDIT! File to edit: model-test.ipynb.
2
 
3
  # %% auto 0
4
+ __all__ = ['plt', 'learn', 'categories', 'title', 'image', 'label', 'examples', 'iface', 'is_albani', 'classify_image']
5
 
6
  # %% model-test.ipynb 2
7
  from fastai.vision.all import *
 
21
  pred,idx,probs = learn.predict(img)
22
  return dict(zip(categories, map(float, probs)))
23
 
24
+ title = """
25
+ ## Er du i tvivl om at den øl du sidder med i hånden lige nu er god?
26
+ Tvivl ej 68 års invotation inden for machine learning skal nok fortælle dig om øllen er god eller ej
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,
34
+ inputs=image,
35
+ outputs=label,
36
+ examples=examples,
37
+ description=title,
38
+ allow_flagging="manual",
39
+ flagging_options=["wrong", "ambiguous"]
40
+ )
41
+
42
  iface.launch(inline=False)
43
 
model-gym.ipynb CHANGED
The diff for this file is too large to render. See raw diff
 
model-test.ipynb CHANGED
@@ -75,14 +75,14 @@
75
  },
76
  {
77
  "cell_type": "code",
78
- "execution_count": 26,
79
  "metadata": {},
80
  "outputs": [
81
  {
82
  "name": "stdout",
83
  "output_type": "stream",
84
  "text": [
85
- "Running on local URL: http://127.0.0.1:7862\n",
86
  "\n",
87
  "To create a public link, set `share=True` in `launch()`.\n"
88
  ]
@@ -91,7 +91,7 @@
91
  "data": {
92
  "text/plain": []
93
  },
94
- "execution_count": 26,
95
  "metadata": {},
96
  "output_type": "execute_result"
97
  },
@@ -113,11 +113,24 @@
113
  " pred,idx,probs = learn.predict(img)\n",
114
  " return dict(zip(categories, map(float, probs)))\n",
115
  "\n",
116
- "image = gr.inputs.Image(shape=(192, 192))\n",
117
- "label = gr.outputs.Label()\n",
 
 
 
 
118
  "examples = ['albani.jpg', 'albani2.jpg', 'heineken.jpg', 'carlsberg.jpg']\n",
119
  "\n",
120
- "iface = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples)\n",
 
 
 
 
 
 
 
 
 
121
  "iface.launch(inline=False)\n"
122
  ]
123
  },
@@ -131,7 +144,7 @@
131
  },
132
  {
133
  "cell_type": "code",
134
- "execution_count": 27,
135
  "metadata": {},
136
  "outputs": [
137
  {
 
75
  },
76
  {
77
  "cell_type": "code",
78
+ "execution_count": 40,
79
  "metadata": {},
80
  "outputs": [
81
  {
82
  "name": "stdout",
83
  "output_type": "stream",
84
  "text": [
85
+ "Running on local URL: http://127.0.0.1:7870\n",
86
  "\n",
87
  "To create a public link, set `share=True` in `launch()`.\n"
88
  ]
 
91
  "data": {
92
  "text/plain": []
93
  },
94
+ "execution_count": 40,
95
  "metadata": {},
96
  "output_type": "execute_result"
97
  },
 
113
  " pred,idx,probs = learn.predict(img)\n",
114
  " return dict(zip(categories, map(float, probs)))\n",
115
  "\n",
116
+ "title = \"\"\"\n",
117
+ " ## Er du i tvivl om at den øl du sidder med i hånden lige nu er god? \n",
118
+ " Tvivl ej 68 års invotation inden for machine learning skal nok fortælle dig om øllen er god eller ej\n",
119
+ "\"\"\"\n",
120
+ "image = gr.Image(shape=(192, 192))\n",
121
+ "label = gr.Label()\n",
122
  "examples = ['albani.jpg', 'albani2.jpg', 'heineken.jpg', 'carlsberg.jpg']\n",
123
  "\n",
124
+ "iface = gr.Interface(\n",
125
+ " fn=classify_image, \n",
126
+ " inputs=image, \n",
127
+ " outputs=label, \n",
128
+ " examples=examples, \n",
129
+ " description=title, \n",
130
+ " allow_flagging=\"manual\", \n",
131
+ " flagging_options=[\"wrong\", \"ambiguous\"]\n",
132
+ ")\n",
133
+ "\n",
134
  "iface.launch(inline=False)\n"
135
  ]
136
  },
 
144
  },
145
  {
146
  "cell_type": "code",
147
+ "execution_count": 41,
148
  "metadata": {},
149
  "outputs": [
150
  {