Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -44,10 +44,28 @@ def compare_image_to_text_models(image, prompt, model1_choice, model1_custom, mo
|
|
44 |
# These models should support a call signature of (image, prompt)
|
45 |
pipe1 = pipeline(task="image-text-to-text", model=model1_name, device=device)
|
46 |
pipe2 = pipeline(task="image-text-to-text", model=model2_name, device=device)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
47 |
|
48 |
# Run inference on the image with the provided prompt.
|
49 |
-
output1 = pipe1(
|
50 |
-
output2 = pipe2(
|
51 |
|
52 |
# Extract the generated text.
|
53 |
def extract_text(output):
|
|
|
44 |
# These models should support a call signature of (image, prompt)
|
45 |
pipe1 = pipeline(task="image-text-to-text", model=model1_name, device=device)
|
46 |
pipe2 = pipeline(task="image-text-to-text", model=model2_name, device=device)
|
47 |
+
messages = [
|
48 |
+
{
|
49 |
+
"role": "user",
|
50 |
+
"content": [
|
51 |
+
{
|
52 |
+
"type": "image",
|
53 |
+
"url": image,
|
54 |
+
},
|
55 |
+
{"type": "text", "text": prompt},
|
56 |
+
],
|
57 |
+
},
|
58 |
+
{
|
59 |
+
"role": "assistant",
|
60 |
+
"content": [
|
61 |
+
{"type": "text", "text": ""},
|
62 |
+
],
|
63 |
+
},
|
64 |
+
]
|
65 |
|
66 |
# Run inference on the image with the provided prompt.
|
67 |
+
output1 = pipe1(text=messages, max_new_tokens=1024)
|
68 |
+
output2 = pipe2(text=messages, max_new_tokens=1024)
|
69 |
|
70 |
# Extract the generated text.
|
71 |
def extract_text(output):
|