ksj47 commited on
Commit
fa5ba4e
·
verified ·
1 Parent(s): 0ea3fb2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -6
app.py CHANGED
@@ -10,21 +10,22 @@ def launch(input):
10
  out = pipe(input) # Get the model output
11
  return out[0]['generated_text'] # Return the generated text
12
 
13
- # Define examples (sample images to use as input)
14
  examples = [
15
- ["example1.jpg","a dog swimming in the ocean"], # Replace with the path to your example images
16
- ["example2.png","a fairy fairy sitting on a tree branch"]
17
  ]
18
 
19
  # Create the Gradio interface
20
  iface = gr.Interface(
21
- launch,
22
  inputs=gr.Image(type='pil'), # Input is an image
23
  outputs="text", # Output is a text description
24
  title="Image Captioning with BLIP",
25
  description="This application uses the BLIP image-captioning model to generate descriptions for the images you upload. "
26
- "Simply upload an image, and the model will generate a caption describing the content of the image.",
27
- examples=examples # Add predefined examples
 
28
  )
29
 
30
  # Launch the interface
 
10
  out = pipe(input) # Get the model output
11
  return out[0]['generated_text'] # Return the generated text
12
 
13
+ # Define examples with images and expected outputs
14
  examples = [
15
+ ["example1.jpg", "a dog swimming in the ocean"], # Example 1
16
+ ["example2.png", "a fairy sitting on a tree branch"] # Example 2
17
  ]
18
 
19
  # Create the Gradio interface
20
  iface = gr.Interface(
21
+ fn=launch,
22
  inputs=gr.Image(type='pil'), # Input is an image
23
  outputs="text", # Output is a text description
24
  title="Image Captioning with BLIP",
25
  description="This application uses the BLIP image-captioning model to generate descriptions for the images you upload. "
26
+ "Simply upload an image, and the model will generate a caption describing the content of the image. "
27
+ "You can also try some pre-loaded examples below.",
28
+ examples=[example[:1] for example in examples] # Only include image paths for Gradio
29
  )
30
 
31
  # Launch the interface