sahalhes commited on
Commit
9cf29f4
·
1 Parent(s): 9b6e5c0
Files changed (1) hide show
  1. app.py +3 -3
app.py CHANGED
@@ -1,10 +1,10 @@
1
  import gradio as gr
2
  from transformers import pipeline
3
 
4
- captioner = pipeline("image-to-text", model="nlpconnect/vit-gpt2-image-captioning")
5
 
6
  def generate_caption(image):
7
- result = captioner(image)
8
  return result[0]["generated_text"].strip()
9
 
10
  title = "🖼️ Image Caption Generator"
@@ -16,7 +16,7 @@ demo = gr.Interface(
16
  outputs=gr.Textbox(label="Generated Caption"),
17
  title=title,
18
  description=description,
19
- allow_flagging="never"
20
  )
21
 
22
  if __name__ == "__main__":
 
1
  import gradio as gr
2
  from transformers import pipeline
3
 
4
+ pipe = pipeline("image-to-text", model="nlpconnect/vit-gpt2-image-captioning")
5
 
6
  def generate_caption(image):
7
+ result = pipe(image)
8
  return result[0]["generated_text"].strip()
9
 
10
  title = "🖼️ Image Caption Generator"
 
16
  outputs=gr.Textbox(label="Generated Caption"),
17
  title=title,
18
  description=description,
19
+ flagging_mode="never"
20
  )
21
 
22
  if __name__ == "__main__":