Darklight0012 commited on
Commit
daff38f
·
1 Parent(s): 74f7087

predictor update

Browse files
Files changed (2) hide show
  1. app.py +21 -1
  2. requirements.txt +2 -0
app.py CHANGED
@@ -1,7 +1,27 @@
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
+ import scikit-image
4
 
5
  def greet(name):
6
  return "Hello " + name + "!!"
7
 
8
  iface = gr.Interface(fn=greet, inputs="text", outputs="text")
9
+ iface.launch()
10
+
11
+ pet_learner = load_learner('pets.pkl')
12
+ im = PILImage.create('corgi.jpg')
13
+ im.thumbnail((192,192))
14
+
15
+ labels = pet_learner.dls.vocab
16
+ def predict(img):
17
+ img = PILImage.create(img)
18
+ pred,pred_idx,probs = pet_learner.predict(img)
19
+ return{labels[i]:float(probs[i]) for i in range(len(labels))}
20
+ title = "Pet Breed Classifier"
21
+ description = "A pet breed classifier trained on the Oxford Pets dataset with fastai."
22
+ article = "<p style = 'text-align: center'><a href='https://tmabraham.github.io/blog/gradio_hf_spaces_tutorial' target='_blank'>Blog post</a></p>"
23
+ examples = ['corgi.jpeg']
24
+ interpretation = 'default'
25
+ enable_queue=True
26
+
27
+ gr.Interface(fn=predict,inpute = gr.inputs.Image(shape=(512,512)),outputs = gr.outputs.Label(num_top_classes=3),title=title,description=description,article=article,examples=examples,interpretation=interpretation,enable_queue=enable_queue).launch()
requirements.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ fastai
2
+ scikit-image