Joel Sleppy commited on
Commit
8446f22
β€’
1 Parent(s): 4285e3e

use LFS with only model.pkl?

Browse files
README.md CHANGED
@@ -1,3 +1,13 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:02e3e6211e8c301209dfc516bbbf5ddf15bd3c7d79b34aa15e9adc456777a503
3
- size 258
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ title: Cactus Classifier
3
+ emoji: πŸ‘
4
+ colorFrom: yellow
5
+ colorTo: green
6
+ sdk: gradio
7
+ sdk_version: 3.1.7
8
+ app_file: app.py
9
+ pinned: false
10
+ license: apache-2.0
11
+ ---
12
+
13
+ Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
app.py CHANGED
@@ -1,3 +1,39 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:e8d19e9e26f83f591771a1c0f4485919a06be18a67ee299c8bac5438c334f178
3
- size 1033
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from pathlib import Path
2
+
3
+ import gradio as gr
4
+ import numpy as np
5
+
6
+ from fastai.learner import load_learner
7
+
8
+
9
+ learner = load_learner(Path("model.pkl"))
10
+ labels = learner.dls.vocab
11
+
12
+
13
+ def classify(image: np.array):
14
+ results = learner.predict(image)
15
+ probabilities = results[2]
16
+ probabilities = map(float, probabilities)
17
+ return dict(zip(labels, probabilities))
18
+
19
+
20
+ description = """<p>Give me a cactus picture and I'll try to guess the variety.</p>
21
+ <p>I can recognize the following types of cactus:</p>
22
+ <ul>
23
+ {list_items}
24
+ </ul>
25
+ <p>This model was trained <a href="https://www.kaggle.com/jdsleppy/cactus-classifier/">here</a> by <a href="https://www.joelsleppy.com">Joel</a>.</p>
26
+ """.format(
27
+ list_items='\n'.join([f' <li>{label}</li>' for label in labels])
28
+ )
29
+
30
+
31
+ gr.Interface(
32
+ fn=classify,
33
+ inputs="image",
34
+ outputs="label",
35
+ examples=["examples/disco.jpg", "examples/scarlet_crown.jpg", "examples/silver_torch.webp"],
36
+ title="Cactus Classifier",
37
+ description=description,
38
+ allow_flagging="never",
39
+ ).launch()
examples/disco.jpg CHANGED

Git LFS Details

  • SHA256: e8f1c5668965beef25e56786f694b88d2a558fc1538444541d6f28918a2ea0d5
  • Pointer size: 130 Bytes
  • Size of remote file: 22.1 kB
examples/scarlet_crown.jpg CHANGED

Git LFS Details

  • SHA256: 861f4cdc1951160aa0a10e1e45c01bcc07c03847e457d0c408509182dbee4827
  • Pointer size: 131 Bytes
  • Size of remote file: 233 kB
examples/silver_torch.webp CHANGED

Git LFS Details

  • SHA256: 834dbf3a43970db7d22cdaf9ec51b2ca4f63d82e2f8bcfe471aeb24010fd2e22
  • Pointer size: 130 Bytes
  • Size of remote file: 57.8 kB
requirements.txt CHANGED
@@ -1,3 +1,3 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:7a63b27ead448df70193c8ffc3a42183ef1825e492bf4b92cfe8cec44d03f01e
3
- size 42
 
1
+ fastai==2.7.9
2
+ gradio==3.1.7
3
+ numpy==1.23.2