Geraldine commited on
Commit
64ed02c
·
verified ·
1 Parent(s): f0e1a07

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -4
app.py CHANGED
@@ -34,19 +34,21 @@ def describe_image(image_array):
34
  {
35
  "role": "user",
36
  "content": [
37
- {"type": "image", "image": f"data:image/png;base64,{image}"},
 
 
38
  {"type": "text", "text": "Make a very detailed description of the image."},
39
  ],
40
  }
41
  ]
42
 
43
- text_prompt = processor.apply_chat_template(conversation, add_generation_prompt=True)
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=[image], padding=True, return_tensors="pt"
48
  )
49
- inputs = inputs.to("cuda")
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)