bhavyagiri commited on
Commit
07b3fd0
1 Parent(s): 7204b22
Files changed (2) hide show
  1. app.py +10 -4
  2. requirements.txt +2 -1
app.py CHANGED
@@ -1,16 +1,22 @@
1
  import gradio as gr
2
  from fastai.vision.all import *
3
-
4
  learn = load_learner("model.pkl")
5
 
 
 
6
  def classify_garbage(img):
 
7
  pred,idx,probs = learn.predict(img)
8
- return(dict(zip(pred,map(float,probs))))
9
 
10
  image = gr.inputs.Image(shape = (128,128))
11
- label = gr.outputs.Label()
12
  title = "Garbage Classifier"
13
  description = "A Garbage classifier trained with fastai. Created as a demo for Gradio and HuggingFace Spaces."
14
  examples = ['paper24.jpg']
15
- iface = gr.Interface(fn=classify_garbage, inputs=image, outputs=label,examples=examples,title=title,description=description)
 
 
 
16
  iface.launch(inline=False)
 
1
  import gradio as gr
2
  from fastai.vision.all import *
3
+ import skimage
4
  learn = load_learner("model.pkl")
5
 
6
+ labels = learn.dls.vocab
7
+
8
  def classify_garbage(img):
9
+ img = PILImage.create(img)
10
  pred,idx,probs = learn.predict(img)
11
+ return {labels[i]: float(probs[i]) for i in range(len(labels))}
12
 
13
  image = gr.inputs.Image(shape = (128,128))
14
+ label = gr.outputs.Label(num_top_classes=7)
15
  title = "Garbage Classifier"
16
  description = "A Garbage classifier trained with fastai. Created as a demo for Gradio and HuggingFace Spaces."
17
  examples = ['paper24.jpg']
18
+ interpretation='default'
19
+ enable_queue=True
20
+
21
+ iface = gr.Interface(fn=classify_garbage, inputs=image, outputs=label,examples=examples,title=title,description=description,interpretation=interpretation,enable_queue=enable_queue)
22
  iface.launch(inline=False)
requirements.txt CHANGED
@@ -1 +1,2 @@
1
- fastai
 
 
1
+ fastai
2
+ scikit-image