Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -43,11 +43,8 @@ def process_image_and_text(image_pil, text_input, num_beams, temperature, seed):
|
|
43 |
# Load the image using load_image
|
44 |
image = load_image(image_pil)
|
45 |
|
46 |
-
# Add <image> token to the beginning of the text prompt
|
47 |
-
text_input = text_input
|
48 |
-
|
49 |
# Use the provided text input
|
50 |
-
model_inputs = processor(
|
51 |
device, dtype=torch.bfloat16
|
52 |
)
|
53 |
input_len = model_inputs["input_ids"].shape[-1]
|
@@ -70,10 +67,9 @@ if __name__ == "__main__":
|
|
70 |
fn=process_image_and_text,
|
71 |
inputs=[
|
72 |
gr.Image(type="pil", label="Upload an image"),
|
73 |
-
gr.Textbox(label="Enter Text Prompt"),
|
74 |
gr.Slider(minimum=1, maximum=10, step=1, value=1, label="Number of Beams"),
|
75 |
gr.Slider(minimum=0.1, maximum=2.0, step=0.1, value=1.0, label="Temperature"),
|
76 |
-
gr.Number(label="Random Seed", value=
|
77 |
],
|
78 |
outputs=gr.Textbox(label="Generated Text"),
|
79 |
title="PaliGemma2 Image and Text to Text",
|
|
|
43 |
# Load the image using load_image
|
44 |
image = load_image(image_pil)
|
45 |
|
|
|
|
|
|
|
46 |
# Use the provided text input
|
47 |
+
model_inputs = processor(images=image, return_tensors="pt").to(
|
48 |
device, dtype=torch.bfloat16
|
49 |
)
|
50 |
input_len = model_inputs["input_ids"].shape[-1]
|
|
|
67 |
fn=process_image_and_text,
|
68 |
inputs=[
|
69 |
gr.Image(type="pil", label="Upload an image"),
|
|
|
70 |
gr.Slider(minimum=1, maximum=10, step=1, value=1, label="Number of Beams"),
|
71 |
gr.Slider(minimum=0.1, maximum=2.0, step=0.1, value=1.0, label="Temperature"),
|
72 |
+
gr.Number(label="Random Seed", value=0, precision=0),
|
73 |
],
|
74 |
outputs=gr.Textbox(label="Generated Text"),
|
75 |
title="PaliGemma2 Image and Text to Text",
|