Update app.py
Browse files
app.py
CHANGED
@@ -34,19 +34,21 @@ def describe_image(image_array):
|
|
34 |
{
|
35 |
"role": "user",
|
36 |
"content": [
|
37 |
-
{
|
|
|
|
|
38 |
{"type": "text", "text": "Make a very detailed description of the image."},
|
39 |
],
|
40 |
}
|
41 |
]
|
42 |
|
43 |
-
text_prompt = processor.apply_chat_template(
|
44 |
# Excepted output: '<|im_start|>system\nYou are a helpful assistant.<|im_end|>\n<|im_start|>user\n<|vision_start|><|image_pad|><|vision_end|>Describe this image.<|im_end|>\n<|im_start|>assistant\n'
|
45 |
|
46 |
inputs = processor(
|
47 |
-
text=[text_prompt], images=[
|
48 |
)
|
49 |
-
inputs = inputs.to("
|
50 |
|
51 |
# Inference: Generation of the output
|
52 |
output_ids = model.generate(**inputs, max_new_tokens=128)
|
|
|
34 |
{
|
35 |
"role": "user",
|
36 |
"content": [
|
37 |
+
{
|
38 |
+
"type": "image",
|
39 |
+
},
|
40 |
{"type": "text", "text": "Make a very detailed description of the image."},
|
41 |
],
|
42 |
}
|
43 |
]
|
44 |
|
45 |
+
text_prompt = processor.apply_chat_template(messages, add_generation_prompt=True)
|
46 |
# Excepted output: '<|im_start|>system\nYou are a helpful assistant.<|im_end|>\n<|im_start|>user\n<|vision_start|><|image_pad|><|vision_end|>Describe this image.<|im_end|>\n<|im_start|>assistant\n'
|
47 |
|
48 |
inputs = processor(
|
49 |
+
text=[text_prompt], images=[image_str], padding=True, return_tensors="pt"
|
50 |
)
|
51 |
+
inputs = inputs.to("cpu")
|
52 |
|
53 |
# Inference: Generation of the output
|
54 |
output_ids = model.generate(**inputs, max_new_tokens=128)
|