ArturG9 commited on
Commit
ad26b7f
·
verified ·
1 Parent(s): ae7133a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -17
app.py CHANGED
@@ -1,30 +1,22 @@
 
1
  import gradio as gr
2
- from gradio.components import Image, Label
3
  from fastai.vision.all import *
 
4
 
5
  learn = load_learner('ConvNext_RmsProps.pkl')
6
 
7
  labels = learn.dls.vocab
8
-
9
  def predict(img):
10
  img = PILImage.create(img)
11
- pred, pred_idx, probs = learn.predict(img)
12
  return {labels[i]: float(probs[i]) for i in range(len(labels))}
13
-
14
- title = "European Mushroom Common Genus Image Classifier"
15
- description = "European Mushroom Common Genus Image Classifier trained on the Kaggle dataset https://www.kaggle.com/maysee/mushrooms-classification-common-genuss-imagest with fastai. Created as a demo for Gradio and HuggingFace Spaces."
16
  article="<p style='text-align: center'><a href='https://tmabraham.github.io/blog/gradio_hf_spaces_tutorial' target='_blank'>Blog post</a></p>"
17
  examples = ['Amanita.jpg']
18
  interpretation='default'
19
- allow_queue=True
 
 
20
 
21
- gr.Interface(fn=predict,
22
- inputs=Image(shape=(224, 224)),
23
- outputs=Label(num_top_classes=3),
24
- title=title,
25
- description=description,
26
- article=article,
27
- examples=examples,
28
- interpretation=interpretation,
29
- allow_queue=allow_queue
30
- ).launch()
 
1
+
2
  import gradio as gr
 
3
  from fastai.vision.all import *
4
+ import skimage
5
 
6
  learn = load_learner('ConvNext_RmsProps.pkl')
7
 
8
  labels = learn.dls.vocab
 
9
  def predict(img):
10
  img = PILImage.create(img)
11
+ pred,pred_idx,probs = learn.predict(img)
12
  return {labels[i]: float(probs[i]) for i in range(len(labels))}
13
+
14
+ title = "Pet Breed Classifier"
15
+ description = "A pet breed classifier trained on the Oxford Pets dataset with fastai. Created as a demo for Gradio and HuggingFace Spaces."
16
  article="<p style='text-align: center'><a href='https://tmabraham.github.io/blog/gradio_hf_spaces_tutorial' target='_blank'>Blog post</a></p>"
17
  examples = ['Amanita.jpg']
18
  interpretation='default'
19
+ enable_queue=True
20
+
21
+ gr.Interface(fn=predict,inputs=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()
22