Longsum commited on
Commit
40f0749
1 Parent(s): 68923b2

8 files test

Browse files
Files changed (8) hide show
  1. .gitattributes +1 -0
  2. app.ipynb +163 -0
  3. app.py +27 -0
  4. cat.jpg +3 -0
  5. dog.jpg +0 -0
  6. dunno.jpg +0 -0
  7. model.pkl +3 -0
  8. requirements.txt +2 -0
.gitattributes CHANGED
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ cat.jpg filter=lfs diff=lfs merge=lfs -text
app.ipynb ADDED
@@ -0,0 +1,163 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "cells": [
3
+ {
4
+ "cell_type": "code",
5
+ "execution_count": 1,
6
+ "metadata": {},
7
+ "outputs": [],
8
+ "source": [
9
+ "from fastai.vision.all import *\n",
10
+ "import gradio as gr\n",
11
+ "import pathlib\n",
12
+ "temp = pathlib.PosixPath\n",
13
+ "pathlib.PosixPath = pathlib.WindowsPath\n",
14
+ "\n",
15
+ "def is_cat(x): return x[0].isupper()"
16
+ ]
17
+ },
18
+ {
19
+ "cell_type": "code",
20
+ "execution_count": 2,
21
+ "metadata": {},
22
+ "outputs": [],
23
+ "source": [
24
+ "learn = load_learner('model.pkl')"
25
+ ]
26
+ },
27
+ {
28
+ "cell_type": "code",
29
+ "execution_count": 3,
30
+ "metadata": {},
31
+ "outputs": [],
32
+ "source": [
33
+ "categories = ('Dog', 'Cat')\n",
34
+ "\n",
35
+ "def classify_image(img):\n",
36
+ " pred,idx,probs = learn.predict(img)\n",
37
+ " return dict(zip(categories, map(float,probs)))"
38
+ ]
39
+ },
40
+ {
41
+ "cell_type": "code",
42
+ "execution_count": 4,
43
+ "metadata": {},
44
+ "outputs": [
45
+ {
46
+ "name": "stderr",
47
+ "output_type": "stream",
48
+ "text": [
49
+ "C:\\Users\\Lenovo\\AppData\\Local\\Temp\\ipykernel_16112\\1698676069.py:1: GradioDeprecationWarning: Usage of gradio.inputs is deprecated, and will not be supported in the future, please import your component from gradio.components\n",
50
+ " image = gr.inputs.Image(shape=(192, 192))\n",
51
+ "C:\\Users\\Lenovo\\AppData\\Local\\Temp\\ipykernel_16112\\1698676069.py:1: GradioDeprecationWarning: `optional` parameter is deprecated, and it has no effect\n",
52
+ " image = gr.inputs.Image(shape=(192, 192))\n",
53
+ "C:\\Users\\Lenovo\\AppData\\Local\\Temp\\ipykernel_16112\\1698676069.py:2: GradioDeprecationWarning: Usage of gradio.outputs is deprecated, and will not be supported in the future, please import your components from gradio.components\n",
54
+ " label = gr.outputs.Label()\n",
55
+ "C:\\Users\\Lenovo\\AppData\\Local\\Temp\\ipykernel_16112\\1698676069.py:2: GradioUnusedKwargWarning: You have unused kwarg parameters in Label, please remove them: {'type': 'auto'}\n",
56
+ " label = gr.outputs.Label()\n"
57
+ ]
58
+ },
59
+ {
60
+ "name": "stdout",
61
+ "output_type": "stream",
62
+ "text": [
63
+ "Running on local URL: http://127.0.0.1:7860\n",
64
+ "\n",
65
+ "To create a public link, set `share=True` in `launch()`.\n"
66
+ ]
67
+ },
68
+ {
69
+ "data": {
70
+ "text/plain": []
71
+ },
72
+ "execution_count": 4,
73
+ "metadata": {},
74
+ "output_type": "execute_result"
75
+ }
76
+ ],
77
+ "source": [
78
+ "image = gr.inputs.Image(shape=(192, 192))\n",
79
+ "label = gr.outputs.Label()\n",
80
+ "examples = ['dog.jpg', 'cat.jpg', 'dunno.jpg']\n",
81
+ "\n",
82
+ "intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples)\n",
83
+ "intf.launch(inline=False)"
84
+ ]
85
+ },
86
+ {
87
+ "cell_type": "code",
88
+ "execution_count": 5,
89
+ "metadata": {},
90
+ "outputs": [],
91
+ "source": [
92
+ "import nbdev\n"
93
+ ]
94
+ },
95
+ {
96
+ "cell_type": "code",
97
+ "execution_count": 6,
98
+ "metadata": {},
99
+ "outputs": [
100
+ {
101
+ "name": "stdout",
102
+ "output_type": "stream",
103
+ "text": [
104
+ "C:\\Users\\Lenovo\\Desktop\\fastaiTesting\\testai\n"
105
+ ]
106
+ }
107
+ ],
108
+ "source": [
109
+ "import os\n",
110
+ "print(os.getcwd())"
111
+ ]
112
+ },
113
+ {
114
+ "cell_type": "code",
115
+ "execution_count": 7,
116
+ "metadata": {},
117
+ "outputs": [],
118
+ "source": [
119
+ "nbdev.export.nb_export('app.ipynb', r'C:\\Users\\Lenovo\\Desktop\\fastaiTesting\\testai')"
120
+ ]
121
+ },
122
+ {
123
+ "cell_type": "code",
124
+ "execution_count": 8,
125
+ "metadata": {},
126
+ "outputs": [
127
+ {
128
+ "name": "stdout",
129
+ "output_type": "stream",
130
+ "text": [
131
+ "C:\\Users\\Lenovo\\miniconda3\\envs\\pytorch\\python.exe\n"
132
+ ]
133
+ }
134
+ ],
135
+ "source": [
136
+ "import sys\n",
137
+ "\n",
138
+ "print(sys.executable)"
139
+ ]
140
+ }
141
+ ],
142
+ "metadata": {
143
+ "kernelspec": {
144
+ "display_name": "Python 3 (ipykernel)",
145
+ "language": "python",
146
+ "name": "python3"
147
+ },
148
+ "language_info": {
149
+ "codemirror_mode": {
150
+ "name": "ipython",
151
+ "version": 3
152
+ },
153
+ "file_extension": ".py",
154
+ "mimetype": "text/x-python",
155
+ "name": "python",
156
+ "nbconvert_exporter": "python",
157
+ "pygments_lexer": "ipython3",
158
+ "version": "3.8.17"
159
+ }
160
+ },
161
+ "nbformat": 4,
162
+ "nbformat_minor": 4
163
+ }
app.py ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # AUTOGENERATED! DO NOT EDIT! File to edit: . (unless otherwise specified).
2
+
3
+ __all__ = ['is_cat', 'learn', 'classify_image', 'categories', 'image', 'label', 'examples', 'intf']
4
+
5
+ # Cell
6
+ from fastai.vision.all import *
7
+ import gradio as gr
8
+
9
+ def is_cat(x): return x[0].isupper()
10
+
11
+ # Cell
12
+ learn = load_learner('model.pkl')
13
+
14
+ # Cell
15
+ categories = ('Dog', 'Cat')
16
+
17
+ def classify_image(img):
18
+ pred,idx,probs = learn.predict(img)
19
+ return dict(zip(categories, map(float,probs)))
20
+
21
+ # Cell
22
+ image = gr.inputs.Image(shape=(192, 192))
23
+ label = gr.outputs.Label()
24
+ examples = ['dog.jpg', 'cat.jpg', 'dunno.jpg']
25
+
26
+ intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples)
27
+ intf.launch(inline=False)
cat.jpg ADDED

Git LFS Details

  • SHA256: 834d194a5414c079992879b92b780d02ca74737f07e59af475a0f70b1996249e
  • Pointer size: 132 Bytes
  • Size of remote file: 1.14 MB
dog.jpg ADDED
dunno.jpg ADDED
model.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:46eee60a5eac1402f8402ce1915230e6ca75d8d05c35c4e9500eadf2e39c525a
3
+ size 47062827
requirements.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ fastai
2
+