ved1beta
commited on
Commit
·
e0a390e
1
Parent(s):
cf83b3d
note
Browse files
app.py
CHANGED
@@ -15,8 +15,14 @@ def generate_caption(image, prompt="What is in this image?", max_tokens=100):
|
|
15 |
if image is None:
|
16 |
return "Please upload an image."
|
17 |
|
|
|
|
|
|
|
|
|
|
|
|
|
18 |
# Preprocess inputs
|
19 |
-
model_inputs = processor(text=
|
20 |
input_len = model_inputs["input_ids"].shape[-1]
|
21 |
|
22 |
# Generate caption
|
@@ -30,7 +36,7 @@ def generate_caption(image, prompt="What is in this image?", max_tokens=100):
|
|
30 |
# Load local example images
|
31 |
def load_local_images():
|
32 |
"""Load images from the repository"""
|
33 |
-
image_files = ['image1.
|
34 |
local_images = []
|
35 |
for img_file in image_files:
|
36 |
try:
|
|
|
15 |
if image is None:
|
16 |
return "Please upload an image."
|
17 |
|
18 |
+
# Update UI to show processing
|
19 |
+
gr.Info("Analysis starting. This may take up to 119 seconds.")
|
20 |
+
|
21 |
+
# Modify prompt to include image token
|
22 |
+
full_prompt = "<image> " + prompt
|
23 |
+
|
24 |
# Preprocess inputs
|
25 |
+
model_inputs = processor(text=full_prompt, images=image, return_tensors="pt")
|
26 |
input_len = model_inputs["input_ids"].shape[-1]
|
27 |
|
28 |
# Generate caption
|
|
|
36 |
# Load local example images
|
37 |
def load_local_images():
|
38 |
"""Load images from the repository"""
|
39 |
+
image_files = ['image1.jpg', 'image2.jpg', 'image3.jpg']
|
40 |
local_images = []
|
41 |
for img_file in image_files:
|
42 |
try:
|