Siri23 commited on
Commit
924adb9
·
verified ·
1 Parent(s): 5df154e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +0 -7
app.py CHANGED
@@ -1,16 +1,11 @@
1
  from transformers import pipeline
2
  import gradio as gr
3
  from PIL import Image
4
-
5
- # Load the image captioning pipeline
6
  pipe = pipeline("image-to-text", model="Salesforce/blip-image-captioning-large")
7
-
8
  def generate_caption(image):
9
  # Generate a caption for the image
10
  captions = pipe(image)
11
  return captions[0]['generated_text']
12
-
13
- # Create a Gradio interface for image captioning
14
  demo = gr.Interface(
15
  fn=generate_caption,
16
  inputs=gr.Image(type="pil", label="Upload an Image"),
@@ -18,7 +13,5 @@ demo = gr.Interface(
18
  title="Image Caption Generator",
19
  description="Upload an image to generate a caption using the BLIP model."
20
  )
21
-
22
- # Launch the Gradio interface
23
  if __name__ == "__main__":
24
  demo.launch(share=True)
 
1
  from transformers import pipeline
2
  import gradio as gr
3
  from PIL import Image
 
 
4
  pipe = pipeline("image-to-text", model="Salesforce/blip-image-captioning-large")
 
5
  def generate_caption(image):
6
  # Generate a caption for the image
7
  captions = pipe(image)
8
  return captions[0]['generated_text']
 
 
9
  demo = gr.Interface(
10
  fn=generate_caption,
11
  inputs=gr.Image(type="pil", label="Upload an Image"),
 
13
  title="Image Caption Generator",
14
  description="Upload an image to generate a caption using the BLIP model."
15
  )
 
 
16
  if __name__ == "__main__":
17
  demo.launch(share=True)