nielsr HF staff commited on
Commit
f3e91bc
1 Parent(s): 76766dc

Add example image

Browse files
Files changed (1) hide show
  1. app.py +5 -1
app.py CHANGED
@@ -1,5 +1,8 @@
1
  import gradio as gr
2
  from transformers import ImageClassificationPipeline, PerceiverForImageClassificationConvProcessing, PerceiverFeatureExtractor
 
 
 
3
 
4
  feature_extractor = PerceiverFeatureExtractor()
5
  model = PerceiverForImageClassificationConvProcessing.from_pretrained("deepmind/vision-perceiver-conv")
@@ -25,5 +28,6 @@ def classify_image(image):
25
 
26
  image = gr.inputs.Image(type="pil")
27
  label = gr.outputs.Label(num_top_classes=5)
 
28
 
29
- gr.Interface(fn=classify_image, inputs=image, outputs=label, enable_queue=True).launch(debug=True)
 
1
  import gradio as gr
2
  from transformers import ImageClassificationPipeline, PerceiverForImageClassificationConvProcessing, PerceiverFeatureExtractor
3
+ import torch
4
+
5
+ torch.hub.download_url_to_file('http://images.cocodataset.org/val2017/000000039769.jpg', 'cats.jpg')
6
 
7
  feature_extractor = PerceiverFeatureExtractor()
8
  model = PerceiverForImageClassificationConvProcessing.from_pretrained("deepmind/vision-perceiver-conv")
 
28
 
29
  image = gr.inputs.Image(type="pil")
30
  label = gr.outputs.Label(num_top_classes=5)
31
+ examples = [["cats.jpg"]]
32
 
33
+ gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples, enable_queue=True).launch(debug=True)