Paris Morgan commited on
Commit
7a91fec
1 Parent(s): 42cbd3f
Files changed (6) hide show
  1. README.md +4 -0
  2. app.py +16 -4
  3. bird.jpg +0 -0
  4. cat.jpg +0 -0
  5. dog.jpg +0 -0
  6. model.pkl +3 -0
README.md CHANGED
@@ -11,3 +11,7 @@ license: apache-2.0
11
  ---
12
 
13
  Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
 
 
 
 
11
  ---
12
 
13
  Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
14
+
15
+ ### What
16
+ - Based on https://www.youtube.com/watch?v=F4tvM4Vb3A0
17
+ - Model trained here: https://www.kaggle.com/code/parismorgan/saving-a-basic-fastai-model/edit
app.py CHANGED
@@ -1,7 +1,19 @@
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 *
3
 
4
+ def is_cat(x): return x[0].isupper()
 
5
 
6
+ categories = ('Dog', 'Cat')
7
+
8
+ learn = load_learner('model.pkl')
9
+
10
+ def classify_image(img):
11
+ pred, idx, probs = learn.predict(img)
12
+ return dict(zip(categories, map(float, probs)))
13
+
14
+ image = gr.inputs.Image(shape=(192, 192))
15
+ label = gr.outputs.Label()
16
+ examples = ['dog.jpg', 'cat.jpg', 'bird.jpg']
17
+
18
+ intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples)
19
+ intf.launch(inline=False)
bird.jpg ADDED
cat.jpg ADDED
dog.jpg ADDED
model.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:eac5b2a7418ea1dd7ed0b66f17885fbf6b8e89a9dc0e9487bc75db381f33a104
3
+ size 47061419