Blaizzy / mlx-vlm

MLX-VLM is a package for running Vision LLMs locally on your Mac using MLX.
MIT License
144 stars 12 forks source link

ValueError: The number of images in the text [3] and images [1] should be the same. #21

Closed davedel22 closed 1 month ago

davedel22 commented 1 month ago

I'm getting this error: ValueError: The number of images in the text [3] and images [1] should be the same.

The first image I drag in, and add a prompt works. When I try another image I get that error. I have to clear the page to get it to work again.

Trying idefics2

Traceback (most recent call last): File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/gradio/queueing.py", line 527, in process_events response = await route_utils.call_process_api( File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/gradio/route_utils.py", line 270, in call_process_api output = await app.get_blocks().process_api( File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/gradio/blocks.py", line 1847, in process_api result = await self.call_function( File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/gradio/blocks.py", line 1445, in call_function prediction = await utils.async_iteration(iterator) File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/gradio/utils.py", line 629, in async_iteration return await iterator.anext() File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/gradio/utils.py", line 755, in asyncgen_wrapper response = await iterator.anext() File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/gradio/chat_interface.py", line 551, in _stream_fn first_response = await async_iteration(generator) File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/gradio/utils.py", line 629, in async_iteration return await iterator.anext() File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/gradio/utils.py", line 622, in anext return await anyio.to_thread.run_sync( File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/anyio/to_thread.py", line 33, in run_sync return await get_asynclib().run_sync_in_worker_thread( File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/anyio/_backends/_asyncio.py", line 877, in run_sync_in_worker_thread return await future File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/anyio/_backends/_asyncio.py", line 807, in run result = context.run(func, *args) File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/gradio/utils.py", line 605, in run_sync_iterator_async return next(iterator) File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/mlx_vlm/chat_ui.py", line 116, in chat for chunk in generate( File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/mlx_vlm/chat_ui.py", line 57, in generate input_ids, pixel_values = prepare_inputs(image_processor, processor, image, prompt) File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/mlx_vlm/utils.py", line 636, in prepare_inputs inputs = processor(prompt, image, return_tensors="np") File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/transformers/models/idefics2/processing_idefics2.py", line 225, in call raise ValueError( ValueError: The number of images in the text [3] and images [1] should be the same.

Blaizzy commented 1 month ago

Hi @davedel22

Thanks for sharing,

I think the history is the issue since we don't yet support multiple images it creates the bug.

I will fix it right away!