tiesan commited on
Commit
25aaf07
1 Parent(s): e836fee

add script to predict bears

Browse files
Files changed (6) hide show
  1. app.py +14 -3
  2. black-bear.jpg +0 -0
  3. export.pkl +3 -0
  4. grizzly-bear.jpg +0 -0
  5. requirements.txt +86 -0
  6. teddy-bear.jpg +0 -0
app.py CHANGED
@@ -1,7 +1,18 @@
1
  import gradio as gr
 
2
 
3
- def greet(name):
4
- return "Hello " + name + "!!"
5
 
6
- iface = gr.Interface(fn=greet, inputs="text", outputs="text")
 
 
 
 
 
 
 
 
 
 
 
7
  iface.launch()
 
1
  import gradio as gr
2
+ from fastai.vision.all import load_learner
3
 
4
+ learn_inf = load_learner('export.pkl')
 
5
 
6
+ categories = ['black', 'grizzly', 'teddy']
7
+
8
+ image = gr.inputs.Image(shape=(192, 192))
9
+ label = gr.outputs.Label()
10
+ examples = ['grizzly-bear.jpg', 'teddy-bear.jpg', 'black-bear.jpg']
11
+
12
+ def classify_img(img):
13
+ pred, idx, probs = learn_inf.predict(img)
14
+ return dict(zip(categories, map(float, probs)))
15
+
16
+
17
+ iface = gr.Interface(fn=classify_img, inputs=image, outputs=label, examples=examples)
18
  iface.launch()
black-bear.jpg ADDED
export.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:1496fa386729722a41a56364cf759322620eb3fccf98f75d322e28148feb85d9
3
+ size 46965263
grizzly-bear.jpg ADDED
requirements.txt CHANGED
@@ -0,0 +1,86 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ aiohttp==3.8.3
2
+ aiosignal==1.3.1
3
+ anyio==3.6.2
4
+ async-timeout==4.0.2
5
+ attrs==22.1.0
6
+ bcrypt==4.0.1
7
+ blis==0.7.9
8
+ catalogue==2.0.8
9
+ certifi==2022.12.7
10
+ cffi==1.15.1
11
+ charset-normalizer==2.1.1
12
+ click==8.1.3
13
+ confection==0.0.3
14
+ contourpy==1.0.6
15
+ cryptography==38.0.4
16
+ cycler==0.11.0
17
+ cymem==2.0.7
18
+ fastai==2.7.10
19
+ fastapi==0.88.0
20
+ fastcore==1.5.27
21
+ fastdownload==0.0.7
22
+ fastprogress==1.0.3
23
+ ffmpy==0.3.0
24
+ fonttools==4.38.0
25
+ frozenlist==1.3.3
26
+ fsspec==2022.11.0
27
+ gradio==3.13.0
28
+ h11==0.12.0
29
+ httpcore==0.15.0
30
+ httpx==0.23.1
31
+ idna==3.4
32
+ Jinja2==3.1.2
33
+ joblib==1.2.0
34
+ kiwisolver==1.4.4
35
+ langcodes==3.3.0
36
+ linkify-it-py==1.0.3
37
+ markdown-it-py==2.1.0
38
+ MarkupSafe==2.1.1
39
+ matplotlib==3.6.2
40
+ mdit-py-plugins==0.3.3
41
+ mdurl==0.1.2
42
+ multidict==6.0.3
43
+ murmurhash==1.0.9
44
+ numpy==1.23.5
45
+ orjson==3.8.3
46
+ packaging==22.0
47
+ pandas==1.5.2
48
+ paramiko==2.12.0
49
+ pathy==0.10.1
50
+ Pillow==9.3.0
51
+ preshed==3.0.8
52
+ pycparser==2.21
53
+ pycryptodome==3.16.0
54
+ pydantic==1.10.2
55
+ pydub==0.25.1
56
+ PyNaCl==1.5.0
57
+ pyparsing==3.0.9
58
+ python-dateutil==2.8.2
59
+ python-multipart==0.0.5
60
+ pytz==2022.6
61
+ PyYAML==6.0
62
+ requests==2.28.1
63
+ rfc3986==1.5.0
64
+ scikit-learn==1.2.0
65
+ scipy==1.9.3
66
+ six==1.16.0
67
+ smart-open==6.3.0
68
+ sniffio==1.3.0
69
+ spacy==3.4.4
70
+ spacy-legacy==3.0.10
71
+ spacy-loggers==1.0.4
72
+ srsly==2.4.5
73
+ starlette==0.22.0
74
+ thinc==8.1.5
75
+ threadpoolctl==3.1.0
76
+ torch==1.13.0
77
+ torchvision==0.14.0
78
+ tqdm==4.64.1
79
+ typer==0.7.0
80
+ typing_extensions==4.4.0
81
+ uc-micro-py==1.0.1
82
+ urllib3==1.26.13
83
+ uvicorn==0.20.0
84
+ wasabi==0.10.1
85
+ websockets==10.4
86
+ yarl==1.8.2
teddy-bear.jpg ADDED