Salman Naqvi commited on
Commit
ce9f94e
·
1 Parent(s): 277bad2

Created classification function.

Browse files
Files changed (1) hide show
  1. app.ipynb +71 -0
app.ipynb CHANGED
@@ -1,5 +1,14 @@
1
  {
2
  "cells": [
 
 
 
 
 
 
 
 
 
3
  {
4
  "cell_type": "code",
5
  "execution_count": 1,
@@ -122,6 +131,68 @@
122
  "collapsed": false
123
  }
124
  },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
125
  {
126
  "cell_type": "markdown",
127
  "source": [],
 
1
  {
2
  "cells": [
3
+ {
4
+ "cell_type": "markdown",
5
+ "source": [
6
+ "> This notebook follows the [fastai style guidelines](https://docs.fast.ai/dev/style.html#style-guide)."
7
+ ],
8
+ "metadata": {
9
+ "collapsed": false
10
+ }
11
+ },
12
  {
13
  "cell_type": "code",
14
  "execution_count": 1,
 
131
  "collapsed": false
132
  }
133
  },
134
+ {
135
+ "cell_type": "markdown",
136
+ "source": [
137
+ "## Classification Function"
138
+ ],
139
+ "metadata": {
140
+ "collapsed": false
141
+ }
142
+ },
143
+ {
144
+ "cell_type": "code",
145
+ "execution_count": 5,
146
+ "outputs": [],
147
+ "source": [
148
+ "#| export\n",
149
+ "\n",
150
+ "cats = ('Grizzly Bear', 'Black Bear', 'Teddy Bear',)\n",
151
+ "\n",
152
+ "def classify_img(img):\n",
153
+ " preds, idx, probs = learner.predict(img)\n",
154
+ " return dict(zip(cats, map(float, probs)))"
155
+ ],
156
+ "metadata": {
157
+ "collapsed": false
158
+ }
159
+ },
160
+ {
161
+ "cell_type": "code",
162
+ "execution_count": 6,
163
+ "outputs": [
164
+ {
165
+ "data": {
166
+ "text/plain": "<IPython.core.display.HTML object>",
167
+ "text/html": "\n<style>\n /* Turns off some styling */\n progress {\n /* gets rid of default border in Firefox and Opera. */\n border: none;\n /* Needs to be in here for Safari polyfill so background images work as expected. */\n background-size: auto;\n }\n progress:not([value]), progress:not([value])::-webkit-progress-bar {\n background: repeating-linear-gradient(45deg, #7e7e7e, #7e7e7e 10px, #5c5c5c 10px, #5c5c5c 20px);\n }\n .progress-bar-interrupted, .progress-bar-interrupted::-webkit-progress-bar {\n background: #F44336;\n }\n</style>\n"
168
+ },
169
+ "metadata": {},
170
+ "output_type": "display_data"
171
+ },
172
+ {
173
+ "data": {
174
+ "text/plain": "<IPython.core.display.HTML object>",
175
+ "text/html": "\n <div>\n <progress value='0' class='' max='1' style='width:300px; height:20px; vertical-align: middle;'></progress>\n \n </div>\n "
176
+ },
177
+ "metadata": {},
178
+ "output_type": "display_data"
179
+ },
180
+ {
181
+ "data": {
182
+ "text/plain": "{'Grizzly Bear': 4.78894253319595e-06,\n 'Black Bear': 0.999984622001648,\n 'Teddy Bear': 1.0576571185083594e-05}"
183
+ },
184
+ "execution_count": 6,
185
+ "metadata": {},
186
+ "output_type": "execute_result"
187
+ }
188
+ ],
189
+ "source": [
190
+ "classify_img(img)"
191
+ ],
192
+ "metadata": {
193
+ "collapsed": false
194
+ }
195
+ },
196
  {
197
  "cell_type": "markdown",
198
  "source": [],