Toqi Tahamid commited on
Commit
27715d1
1 Parent(s): fcf0e0b

First model version

Browse files
Files changed (5) hide show
  1. .gitignore +4 -0
  2. app.ipynb +125 -0
  3. app.py +21 -0
  4. model.pkl +3 -0
  5. train.ipynb +0 -0
.gitignore ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ data/
2
+ .ipynb_checkpoints/
3
+ flagged/
4
+ .DS_Store/
app.ipynb ADDED
@@ -0,0 +1,125 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "cells": [
3
+ {
4
+ "cell_type": "code",
5
+ "execution_count": 7,
6
+ "id": "68be7c38-5de9-41bb-b2e6-db358bab0516",
7
+ "metadata": {},
8
+ "outputs": [],
9
+ "source": [
10
+ "from fastai.vision.all import *\n",
11
+ "import gradio as gr"
12
+ ]
13
+ },
14
+ {
15
+ "cell_type": "code",
16
+ "execution_count": 8,
17
+ "id": "e0961d9e-d655-4367-ac5b-cc90ce41118f",
18
+ "metadata": {},
19
+ "outputs": [],
20
+ "source": [
21
+ "learn = load_learner('model.pkl')"
22
+ ]
23
+ },
24
+ {
25
+ "cell_type": "code",
26
+ "execution_count": 9,
27
+ "id": "d7fd2b34-1111-4694-88be-9bd3d4e9efa2",
28
+ "metadata": {},
29
+ "outputs": [],
30
+ "source": [
31
+ "categories = learn.dls.vocab"
32
+ ]
33
+ },
34
+ {
35
+ "cell_type": "code",
36
+ "execution_count": 10,
37
+ "id": "3afc0a26-0769-4b94-8e16-266eb43ffeed",
38
+ "metadata": {},
39
+ "outputs": [],
40
+ "source": [
41
+ "def classify_image(img):\n",
42
+ " pred, idx, probs = learn.predict(img)\n",
43
+ " return dict(zip(categories, map(float, probs)))"
44
+ ]
45
+ },
46
+ {
47
+ "cell_type": "code",
48
+ "execution_count": 11,
49
+ "id": "95875ae8-f066-4c24-9488-5ccd1602fdaa",
50
+ "metadata": {},
51
+ "outputs": [
52
+ {
53
+ "name": "stderr",
54
+ "output_type": "stream",
55
+ "text": [
56
+ "/Users/toqi/opt/miniconda3/envs/fastai/lib/python3.9/site-packages/gradio/inputs.py:257: UserWarning: Usage of gradio.inputs is deprecated, and will not be supported in the future, please import your component from gradio.components\n",
57
+ " warnings.warn(\n",
58
+ "/Users/toqi/opt/miniconda3/envs/fastai/lib/python3.9/site-packages/gradio/deprecation.py:40: UserWarning: `optional` parameter is deprecated, and it has no effect\n",
59
+ " warnings.warn(value)\n",
60
+ "/Users/toqi/opt/miniconda3/envs/fastai/lib/python3.9/site-packages/gradio/outputs.py:197: UserWarning: Usage of gradio.outputs is deprecated, and will not be supported in the future, please import your components from gradio.components\n",
61
+ " warnings.warn(\n",
62
+ "/Users/toqi/opt/miniconda3/envs/fastai/lib/python3.9/site-packages/gradio/deprecation.py:40: UserWarning: The 'type' parameter has been deprecated. Use the Number component instead.\n",
63
+ " warnings.warn(value)\n"
64
+ ]
65
+ },
66
+ {
67
+ "name": "stdout",
68
+ "output_type": "stream",
69
+ "text": [
70
+ "Running on local URL: http://127.0.0.1:7861\n",
71
+ "\n",
72
+ "To create a public link, set `share=True` in `launch()`.\n"
73
+ ]
74
+ },
75
+ {
76
+ "data": {
77
+ "text/plain": []
78
+ },
79
+ "execution_count": 11,
80
+ "metadata": {},
81
+ "output_type": "execute_result"
82
+ }
83
+ ],
84
+ "source": [
85
+ "image = gr.inputs.Image(shape=(224, 224))\n",
86
+ "label = gr.outputs.Label()\n",
87
+ "# examples = ['black-bear.jpg', 'grizzly-bear.jpg', 'teddy-bear.jpg']\n",
88
+ "\n",
89
+ "title= \"Car Classifer\"\n",
90
+ "\n",
91
+ "intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, title=title)\n",
92
+ "intf.launch(inline=False)"
93
+ ]
94
+ },
95
+ {
96
+ "cell_type": "code",
97
+ "execution_count": null,
98
+ "id": "43c24456-6927-4098-8537-6399258923e8",
99
+ "metadata": {},
100
+ "outputs": [],
101
+ "source": []
102
+ }
103
+ ],
104
+ "metadata": {
105
+ "kernelspec": {
106
+ "display_name": "Python 3.9 (fastai)",
107
+ "language": "python",
108
+ "name": "fastai"
109
+ },
110
+ "language_info": {
111
+ "codemirror_mode": {
112
+ "name": "ipython",
113
+ "version": 3
114
+ },
115
+ "file_extension": ".py",
116
+ "mimetype": "text/x-python",
117
+ "name": "python",
118
+ "nbconvert_exporter": "python",
119
+ "pygments_lexer": "ipython3",
120
+ "version": "3.9.15"
121
+ }
122
+ },
123
+ "nbformat": 4,
124
+ "nbformat_minor": 5
125
+ }
app.py ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from fastai.vision.all import *
2
+ import gradio as gr
3
+
4
+ learn = load_learner('model.pkl')
5
+
6
+ categories = learn.dls.vocab
7
+
8
+ def classify_image(img):
9
+ pred, idx, probs = learn.predict(img)
10
+ return dict(zip(categories, map(float, probs)))
11
+
12
+
13
+ image = gr.inputs.Image(shape=(224, 224))
14
+ label = gr.outputs.Label()
15
+ # examples = ['black-bear.jpg', 'grizzly-bear.jpg', 'teddy-bear.jpg']
16
+
17
+ title= "Car Classifer"
18
+
19
+ intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, title=title)
20
+ intf.launch(inline=False)
21
+
model.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:7e765cb1e2f5f269d8f1285531152578a2a83c13fa2a69c8ef0cab73a904c63c
3
+ size 88023949
train.ipynb ADDED
The diff for this file is too large to render. See raw diff