wendys-llc commited on
Commit
6f419af
·
1 Parent(s): c7102bb

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -9
app.py CHANGED
@@ -1,16 +1,17 @@
1
  import gradio as gr
2
  from transformers import pipeline
3
 
4
- def do_action(text):
5
- classifier = pipeline("zero-shot-classification",
6
- model="facebook/bart-large-mnli")
 
7
 
8
- candidate_labels = ['gun control', 'abortion', 'gender transition', 'freedom of speech', 'immigration', 'taxes']
9
- result = classifier(text, candidate_labels)
10
-
11
- result = dict(zip(result['labels'], result['scores']))
12
 
13
  return result
14
 
15
- iface = gr.Interface(fn=do_action, inputs="text", outputs="label")
16
- iface.launch()
 
 
 
 
1
  import gradio as gr
2
  from transformers import pipeline
3
 
4
+ # Rename 'text' to 'image'
5
+ def do_action(image):
6
+ # Use the blip model
7
+ pipe = pipeline("image-to-text", model="Salesforce/blip-image-captioning-large")
8
 
9
+ result = pipe(image)
 
 
 
10
 
11
  return result
12
 
13
+ # input image, output text
14
+ # can't use inputs="image"
15
+ # instead use inputs=gr.Image(type='pil')
16
+ iface = gr.Interface(fn=do_action, inputs=gr.Image(type='pil'), outputs="text")
17
+ iface.launch()