sergiopaniego commited on
Commit
6d7705b
·
verified ·
1 Parent(s): f40a46d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -7
app.py CHANGED
@@ -51,31 +51,35 @@ def array_to_image_path(image_array):
51
  def run_example(image, text_input=None):
52
  image_path = array_to_image_path(image)
53
  image = Image.fromarray(image).convert("RGB")
 
54
  messages = [
55
  {
56
  "role": "user",
57
  "content": [
58
  {
59
  "type": "image",
60
- "image": image_path,
61
  },
62
  {
63
- "type": "text",
64
- "text": text_input
65
  },
66
  ],
67
  }
68
  ]
69
-
70
  # Preparation for inference
71
  text = processor.apply_chat_template(
72
  messages, tokenize=False, add_generation_prompt=True
73
  )
74
- image_inputs, video_inputs = process_vision_info(messages)
 
 
 
 
75
  inputs = processor(
76
- text=[text],
77
  images=image_inputs,
78
- videos=video_inputs,
79
  padding=True,
80
  return_tensors="pt",
81
  )
 
51
  def run_example(image, text_input=None):
52
  image_path = array_to_image_path(image)
53
  image = Image.fromarray(image).convert("RGB")
54
+
55
  messages = [
56
  {
57
  "role": "user",
58
  "content": [
59
  {
60
  "type": "image",
61
+ "text": None,
62
  },
63
  {
64
+ "text": text_input,
65
+ "type": "text"
66
  },
67
  ],
68
  }
69
  ]
70
+
71
  # Preparation for inference
72
  text = processor.apply_chat_template(
73
  messages, tokenize=False, add_generation_prompt=True
74
  )
75
+ image_inputs = []
76
+ if image.mode != 'RGB':
77
+ image = image.convert('RGB')
78
+ image_inputs.append([image])
79
+
80
  inputs = processor(
81
+ text=text,
82
  images=image_inputs,
 
83
  padding=True,
84
  return_tensors="pt",
85
  )