yvoievid commited on
Commit
625a42e
1 Parent(s): a6de294

update .gitattributes so git lfs will track .pkl files

Browse files
Files changed (4) hide show
  1. .DS_Store +0 -0
  2. app.py +12 -1
  3. model.pkl +3 -0
  4. requirements.txt +2 -0
.DS_Store ADDED
Binary file (6.15 kB). View file
 
app.py CHANGED
@@ -1,7 +1,18 @@
 
1
  import gradio as gr
 
 
 
 
 
 
 
 
 
2
 
3
  def greet(name):
4
  return "May the force will be with you, " + name + "!!"
5
 
6
- iface = gr.Interface(fn=greet, inputs="text", outputs="text")
 
7
  iface.launch()
 
1
+ import fastai
2
  import gradio as gr
3
+ from fastai.vision.all import *
4
+
5
+ learn = load_learner('export.pkl')
6
+
7
+ labels = learn.dls.vocab
8
+ def predict(img):
9
+ img = PILImage.create(img)
10
+ pred,pred_idx,probs = learn.predict(img)
11
+ return {labels[i]: float(probs[i]) for i in range(len(labels))}
12
 
13
  def greet(name):
14
  return "May the force will be with you, " + name + "!!"
15
 
16
+ # iface = gr.Interface(fn=greet, inputs="text", outputs="text")
17
+ gr.Interface(fn=predict, inputs=gr.inputs.Image(shape=(512, 512)), outputs=gr.outputs.Label(num_top_classes=3)).launch(share=True)
18
  iface.launch()
model.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:af4a80baebcbafb7ecc26b7e1fa14bdcd51b269184d2d88617f98f27743f8d62
3
+ size 46954905
requirements.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ fastai
2
+ scikit-image