Commit
·
c831efa
1
Parent(s):
1c02d26
Update app.py
Browse files
app.py
CHANGED
@@ -10,14 +10,14 @@ model, vis_processors, _ = load_model_and_preprocess(name="blip_caption", model_
|
|
10 |
|
11 |
# Define the input and output functions for Gradio
|
12 |
def generate_caption(image_file):
|
13 |
-
|
14 |
|
15 |
# Preprocess the image using the Blip-Caption model's visual processors
|
16 |
-
image = vis_processors["eval"](
|
17 |
|
18 |
# Generate captions using the Blip-Caption model
|
19 |
captions = model.generate({"image": image}, use_nucleus_sampling=True, num_captions=5)
|
20 |
-
return captions
|
21 |
|
22 |
# Set up the Gradio interface
|
23 |
#inputs = gr.inputs.Image(type="pil",label="Image")
|
|
|
10 |
|
11 |
# Define the input and output functions for Gradio
|
12 |
def generate_caption(image_file):
|
13 |
+
|
14 |
|
15 |
# Preprocess the image using the Blip-Caption model's visual processors
|
16 |
+
image = vis_processors["eval"](image).unsqueeze(0)
|
17 |
|
18 |
# Generate captions using the Blip-Caption model
|
19 |
captions = model.generate({"image": image}, use_nucleus_sampling=True, num_captions=5)
|
20 |
+
return captions
|
21 |
|
22 |
# Set up the Gradio interface
|
23 |
#inputs = gr.inputs.Image(type="pil",label="Image")
|