multi-image support for llama3.2-vision? #179

Closed
opened 2026-02-15 16:28:31 -05:00 by yindo · 2 comments
Owner

Originally created by @srao-cipher on GitHub (Dec 3, 2024).

Hi! Trying to asses multiple images using the ollama API and MLLM LLama3.2 Vision 90B (55GB). Everything is working fine on single images passed as file location ("image.jpg") and single element array containing file location (["image.jpg]), but fails for array with multiple file locations (["image_0.jpg",image_1.jpg"]).

input:

def send(prompt_path,image_paths):
  with open(prompt_path, 'r') as f:
    prompt = f.read()
  print(len(image_paths))
  response = ollama.chat(
      model='llama3.2-vision',
      messages=[{
          'role': 'user',
          'content': prompt,
          'images': image_paths
      }]
  )

  print(response.message['content'])
  return response

std out:

Cell In[24], line 5
      3   prompt = f.read()
      4 print(len(image_paths))
----> 5 response = ollama.chat(
      6     model='llama3.2-vision',
      7     messages=[{
      8         'role': 'user',
      9         'content': prompt,
     10         'images': image_paths
     11     }]
     12 )
     14 print(response.message['content'])
     15 return response

File ~/llama/.venv/lib/python3.12/site-packages/ollama/_client.py:331, in Client.chat(self, model, messages, tools, stream, format, options, keep_alive)
    286 def chat(
    287   self,
    288   model: str = '',
   (...)
    295   keep_alive: Optional[Union[float, str]] = None,
    296 ) -> Union[ChatResponse, Iterator[ChatResponse]]:
    297   """
    298   Create a chat response using the requested model.
    299 
   (...)
    328   Returns `ChatResponse` if `stream` is `False`, otherwise returns a `ChatResponse` generator.
    329   """
--> 331   return self._request(
    332     ChatResponse,
    333     'POST',
    334     '/api/chat',
    335     json=ChatRequest(
    336       model=model,
    337       messages=[message for message in _copy_messages(messages)],
    338       tools=[tool for tool in _copy_tools(tools)],
    339       stream=stream,
    340       format=format,
    341       options=options,
    342       keep_alive=keep_alive,
    343     ).model_dump(exclude_none=True),
    344     stream=stream,
    345   )

File ~/llama/.venv/lib/python3.12/site-packages/ollama/_client.py:175, in Client._request(self, cls, stream, *args, **kwargs)
    171         yield cls(**part)
    173   return inner()
--> 175 return cls(**self._request_raw(*args, **kwargs).json())

File ~/llama/.venv/lib/python3.12/site-packages/ollama/_client.py:120, in Client._request_raw(self, *args, **kwargs)
    118   r.raise_for_status()
    119 except httpx.HTTPStatusError as e:
--> 120   raise ResponseError(e.response.text, e.response.status_code) from None
    121 return r

ResponseError: vision model only supports a single image per message
Originally created by @srao-cipher on GitHub (Dec 3, 2024). Hi! Trying to asses multiple images using the ollama API and MLLM LLama3.2 Vision 90B (55GB). Everything is working fine on single images passed as file location ("image.jpg") and single element array containing file location (["image.jpg]), but fails for array with multiple file locations (["image_0.jpg",image_1.jpg"]). input: ``` def send(prompt_path,image_paths): with open(prompt_path, 'r') as f: prompt = f.read() print(len(image_paths)) response = ollama.chat( model='llama3.2-vision', messages=[{ 'role': 'user', 'content': prompt, 'images': image_paths }] ) print(response.message['content']) return response ``` std out: ``` Cell In[24], line 5 3 prompt = f.read() 4 print(len(image_paths)) ----> 5 response = ollama.chat( 6 model='llama3.2-vision', 7 messages=[{ 8 'role': 'user', 9 'content': prompt, 10 'images': image_paths 11 }] 12 ) 14 print(response.message['content']) 15 return response File ~/llama/.venv/lib/python3.12/site-packages/ollama/_client.py:331, in Client.chat(self, model, messages, tools, stream, format, options, keep_alive) 286 def chat( 287 self, 288 model: str = '', (...) 295 keep_alive: Optional[Union[float, str]] = None, 296 ) -> Union[ChatResponse, Iterator[ChatResponse]]: 297 """ 298 Create a chat response using the requested model. 299 (...) 328 Returns `ChatResponse` if `stream` is `False`, otherwise returns a `ChatResponse` generator. 329 """ --> 331 return self._request( 332 ChatResponse, 333 'POST', 334 '/api/chat', 335 json=ChatRequest( 336 model=model, 337 messages=[message for message in _copy_messages(messages)], 338 tools=[tool for tool in _copy_tools(tools)], 339 stream=stream, 340 format=format, 341 options=options, 342 keep_alive=keep_alive, 343 ).model_dump(exclude_none=True), 344 stream=stream, 345 ) File ~/llama/.venv/lib/python3.12/site-packages/ollama/_client.py:175, in Client._request(self, cls, stream, *args, **kwargs) 171 yield cls(**part) 173 return inner() --> 175 return cls(**self._request_raw(*args, **kwargs).json()) File ~/llama/.venv/lib/python3.12/site-packages/ollama/_client.py:120, in Client._request_raw(self, *args, **kwargs) 118 r.raise_for_status() 119 except httpx.HTTPStatusError as e: --> 120 raise ResponseError(e.response.text, e.response.status_code) from None 121 return r ResponseError: vision model only supports a single image per message ```
yindo closed this issue 2026-02-15 16:28:31 -05:00
Author
Owner

@tobalo commented on GitHub (Dec 4, 2024):

commenting to follow

@tobalo commented on GitHub (Dec 4, 2024): commenting to follow
Author
Owner

@jessegross commented on GitHub (Dec 5, 2024):

The model doesn't support multiple images, see this comment from Meta:
https://huggingface.co/meta-llama/Llama-3.2-11B-Vision-Instruct/discussions/43#66f98f742094ed9e5f5107d4

@jessegross commented on GitHub (Dec 5, 2024): The model doesn't support multiple images, see this comment from Meta: https://huggingface.co/meta-llama/Llama-3.2-11B-Vision-Instruct/discussions/43#66f98f742094ed9e5f5107d4
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: ollama/ollama-python#179