Commit
·
b21b6cd
1
Parent(s):
b37e35e
Update app.py
Browse files
app.py
CHANGED
|
@@ -5,7 +5,7 @@ from lavis.models import load_model_and_preprocess
|
|
| 5 |
|
| 6 |
|
| 7 |
# Load the Blip-Caption model
|
| 8 |
-
|
| 9 |
model, vis_processors, _ = load_model_and_preprocess(name="blip_caption", model_type="base_coco", is_eval=True, device=device)
|
| 10 |
|
| 11 |
# Define the input and output functions for Gradio
|
|
@@ -14,7 +14,7 @@ def generate_caption(image_file):
|
|
| 14 |
raw_image = Image.open(image_file).convert("RGB")
|
| 15 |
|
| 16 |
# Preprocess the image using the Blip-Caption model's visual processors
|
| 17 |
-
image = vis_processors["eval"](raw_image).unsqueeze(0)
|
| 18 |
|
| 19 |
# Generate captions using the Blip-Caption model
|
| 20 |
captions = model.generate({"image": image}, use_nucleus_sampling=True, num_captions=5)
|
|
|
|
| 5 |
|
| 6 |
|
| 7 |
# Load the Blip-Caption model
|
| 8 |
+
|
| 9 |
model, vis_processors, _ = load_model_and_preprocess(name="blip_caption", model_type="base_coco", is_eval=True, device=device)
|
| 10 |
|
| 11 |
# Define the input and output functions for Gradio
|
|
|
|
| 14 |
raw_image = Image.open(image_file).convert("RGB")
|
| 15 |
|
| 16 |
# Preprocess the image using the Blip-Caption model's visual processors
|
| 17 |
+
image = vis_processors["eval"](raw_image).unsqueeze(0)
|
| 18 |
|
| 19 |
# Generate captions using the Blip-Caption model
|
| 20 |
captions = model.generate({"image": image}, use_nucleus_sampling=True, num_captions=5)
|