Oleh Hnashuk commited on
Commit
332a36e
β€’
1 Parent(s): bdd9afb

mammal or bird or fish classifier

Browse files
.DS_Store ADDED
Binary file (6.15 kB). View file
 
app.ipynb CHANGED
@@ -2,7 +2,7 @@
2
  "cells": [
3
  {
4
  "cell_type": "code",
5
- "execution_count": 12,
6
  "id": "b0b5e6d7",
7
  "metadata": {},
8
  "outputs": [],
@@ -12,21 +12,19 @@
12
  },
13
  {
14
  "cell_type": "code",
15
- "execution_count": 9,
16
  "id": "894a6707",
17
  "metadata": {},
18
  "outputs": [],
19
  "source": [
20
  "#|export\n",
21
- "!pip install fastai\n",
22
- "!pip install gradio\n",
23
  "from fastai.vision.all import *\n",
24
  "import gradio as gr"
25
  ]
26
  },
27
  {
28
  "cell_type": "code",
29
- "execution_count": 4,
30
  "id": "3308043c",
31
  "metadata": {},
32
  "outputs": [],
@@ -37,14 +35,14 @@
37
  },
38
  {
39
  "cell_type": "code",
40
- "execution_count": 5,
41
  "id": "d9019a15",
42
  "metadata": {},
43
  "outputs": [],
44
  "source": [
45
  "#|export \n",
46
  "\n",
47
- "categories = ('ocean', 'space', 'money')\n",
48
  "\n",
49
  "def classify_image(img):\n",
50
  " pred, idx, probs = learn.predict(img)\n",
@@ -53,7 +51,7 @@
53
  },
54
  {
55
  "cell_type": "code",
56
- "execution_count": 6,
57
  "id": "d04d8882",
58
  "metadata": {},
59
  "outputs": [
@@ -97,24 +95,24 @@
97
  {
98
  "data": {
99
  "text/plain": [
100
- "{'ocean': 5.39313214176218e-06,\n",
101
- " 'space': 0.9999582767486572,\n",
102
- " 'money': 3.6335437471279874e-05}"
103
  ]
104
  },
105
- "execution_count": 6,
106
  "metadata": {},
107
  "output_type": "execute_result"
108
  }
109
  ],
110
  "source": [
111
- "im = PILImage.create('ocean.jpg')\n",
112
  "classify_image(im)"
113
  ]
114
  },
115
  {
116
  "cell_type": "code",
117
- "execution_count": 10,
118
  "id": "bbef2af6",
119
  "metadata": {},
120
  "outputs": [
@@ -136,7 +134,7 @@
136
  "name": "stdout",
137
  "output_type": "stream",
138
  "text": [
139
- "Running on local URL: http://127.0.0.1:7860\n",
140
  "\n",
141
  "To create a public link, set `share=True` in `launch()`.\n"
142
  ]
@@ -145,7 +143,7 @@
145
  "data": {
146
  "text/plain": []
147
  },
148
- "execution_count": 10,
149
  "metadata": {},
150
  "output_type": "execute_result"
151
  },
@@ -265,7 +263,7 @@
265
  "#|export\n",
266
  "image = gr.inputs.Image(shape=(192,192))\n",
267
  "label = gr.outputs.Label()\n",
268
- "examples = ['ocean.jpg', 'space.jpg', 'money.jpg']\n",
269
  "\n",
270
  "intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples)\n",
271
  "intf.launch(inline=False)"
@@ -273,7 +271,7 @@
273
  },
274
  {
275
  "cell_type": "code",
276
- "execution_count": 15,
277
  "id": "c0c533db",
278
  "metadata": {},
279
  "outputs": [],
 
2
  "cells": [
3
  {
4
  "cell_type": "code",
5
+ "execution_count": 40,
6
  "id": "b0b5e6d7",
7
  "metadata": {},
8
  "outputs": [],
 
12
  },
13
  {
14
  "cell_type": "code",
15
+ "execution_count": 41,
16
  "id": "894a6707",
17
  "metadata": {},
18
  "outputs": [],
19
  "source": [
20
  "#|export\n",
 
 
21
  "from fastai.vision.all import *\n",
22
  "import gradio as gr"
23
  ]
24
  },
25
  {
26
  "cell_type": "code",
27
+ "execution_count": 42,
28
  "id": "3308043c",
29
  "metadata": {},
30
  "outputs": [],
 
35
  },
36
  {
37
  "cell_type": "code",
38
+ "execution_count": 47,
39
  "id": "d9019a15",
40
  "metadata": {},
41
  "outputs": [],
42
  "source": [
43
  "#|export \n",
44
  "\n",
45
+ "categories = ('bird.jpg', 'fish.jpg', 'mammal.jpg')\n",
46
  "\n",
47
  "def classify_image(img):\n",
48
  " pred, idx, probs = learn.predict(img)\n",
 
51
  },
52
  {
53
  "cell_type": "code",
54
+ "execution_count": 50,
55
  "id": "d04d8882",
56
  "metadata": {},
57
  "outputs": [
 
95
  {
96
  "data": {
97
  "text/plain": [
98
+ "{'bird.jpg': 1.5930112567730248e-05,\n",
99
+ " 'fish.jpg': 0.9999780654907227,\n",
100
+ " 'mammal.jpg': 5.961885563010583e-06}"
101
  ]
102
  },
103
+ "execution_count": 50,
104
  "metadata": {},
105
  "output_type": "execute_result"
106
  }
107
  ],
108
  "source": [
109
+ "im = PILImage.create('fish.jpg')\n",
110
  "classify_image(im)"
111
  ]
112
  },
113
  {
114
  "cell_type": "code",
115
+ "execution_count": 51,
116
  "id": "bbef2af6",
117
  "metadata": {},
118
  "outputs": [
 
134
  "name": "stdout",
135
  "output_type": "stream",
136
  "text": [
137
+ "Running on local URL: http://127.0.0.1:7863\n",
138
  "\n",
139
  "To create a public link, set `share=True` in `launch()`.\n"
140
  ]
 
143
  "data": {
144
  "text/plain": []
145
  },
146
+ "execution_count": 51,
147
  "metadata": {},
148
  "output_type": "execute_result"
149
  },
 
263
  "#|export\n",
264
  "image = gr.inputs.Image(shape=(192,192))\n",
265
  "label = gr.outputs.Label()\n",
266
+ "examples = ['bird.jpg', 'fish.jpg', 'mammal.jpg']\n",
267
  "\n",
268
  "intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples)\n",
269
  "intf.launch(inline=False)"
 
271
  },
272
  {
273
  "cell_type": "code",
274
+ "execution_count": 52,
275
  "id": "c0c533db",
276
  "metadata": {},
277
  "outputs": [],
app.py CHANGED
@@ -11,7 +11,7 @@ import gradio as gr
11
  learn = load_learner('model.pk1')
12
 
13
  # %% ../app.ipynb 3
14
- categories = ('ocean', 'space', 'money')
15
 
16
  def classify_image(img):
17
  pred, idx, probs = learn.predict(img)
@@ -20,7 +20,7 @@ def classify_image(img):
20
  # %% ../app.ipynb 5
21
  image = gr.inputs.Image(shape=(192,192))
22
  label = gr.outputs.Label()
23
- examples = ['ocean.jpg', 'space.jpg', 'money.jpg']
24
 
25
  intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples)
26
  intf.launch(inline=False)
 
11
  learn = load_learner('model.pk1')
12
 
13
  # %% ../app.ipynb 3
14
+ categories = ('bird.jpg', 'fish.jpg', 'mammal.jpg')
15
 
16
  def classify_image(img):
17
  pred, idx, probs = learn.predict(img)
 
20
  # %% ../app.ipynb 5
21
  image = gr.inputs.Image(shape=(192,192))
22
  label = gr.outputs.Label()
23
+ examples = ['bird.jpg', 'fish.jpg', 'mammal.jpg']
24
 
25
  intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples)
26
  intf.launch(inline=False)
app/app.py DELETED
@@ -1,26 +0,0 @@
1
- # AUTOGENERATED! DO NOT EDIT! File to edit: ../app.ipynb.
2
-
3
- # %% auto 0
4
- __all__ = ['learn', 'categories', 'image', 'label', 'examples', 'intf', 'classify_image']
5
-
6
- # %% ../app.ipynb 1
7
- from fastai.vision.all import *
8
- import gradio as gr
9
-
10
- # %% ../app.ipynb 2
11
- learn = load_learner('model.pk1')
12
-
13
- # %% ../app.ipynb 3
14
- categories = ('ocean', 'space', 'money')
15
-
16
- def classify_image(img):
17
- pred, idx, probs = learn.predict(img)
18
- return dict(zip(categories, map(float, probs)))
19
-
20
- # %% ../app.ipynb 5
21
- image = gr.inputs.Image(shape=(192,192))
22
- label = gr.outputs.Label()
23
- examples = ['ocean.jpg', 'space.jpg', 'money.jpg']
24
-
25
- intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples)
26
- intf.launch(inline=False)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
ocean.jpg β†’ bird.jpg RENAMED
File without changes
money.jpg β†’ fish.jpg RENAMED
File without changes
space.jpg β†’ mammal.jpg RENAMED
File without changes
model.pk1 CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:c397fb6984c96890e13718ebd9f62f19553c56b7f2cdd6b5d861b7df89461a0c
3
- size 46958063
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:29d1fbdb578b1861ffadbfbafcb4a5c5028f1cf62a6d5445a02c7fe2f626e629
3
+ size 46958891