[GH-ISSUE #169] 是否支持传入多张图片? #133

Open
opened 2026-10-26 21:12:50 +00:00 by bsakaguchi · 3 comments
Owner

Originally created by @fggggg7142 on GitHub (Feb 14, 2025).
Original GitHub issue: https://github.com/deepseek-ai/Janus/issues/169

传2以及2张以上图片报错:
Traceback (most recent call last):
File "/home/wanghui/daiteng01/deepseek/main.py", line 104, in
prepare_inputs = vl_chat_processor(
File "/home/wanghui/daiteng01/deepseek/Janus-main/janus/models/processing_vlm.py", line 353, in call
prepare = self.batchify([prepare])
File "/home/wanghui/daiteng01/deepseek/Janus-main/janus/models/processing_vlm.py", line 403, in batchify
batched_pixel_values[i, :n_image] = prepare.pixel_values
RuntimeError: The expanded size of the tensor (1) must match the existing size (2) at non-singleton dimension 0. Target sizes: [1, 3, 384, 384]. Tensor sizes: [2, 3, 384, 384]

Originally created by @fggggg7142 on GitHub (Feb 14, 2025). Original GitHub issue: https://github.com/deepseek-ai/Janus/issues/169 传2以及2张以上图片报错: Traceback (most recent call last): File "/home/wanghui/daiteng01/deepseek/main.py", line 104, in <module> prepare_inputs = vl_chat_processor( File "/home/wanghui/daiteng01/deepseek/Janus-main/janus/models/processing_vlm.py", line 353, in __call__ prepare = self.batchify([prepare]) File "/home/wanghui/daiteng01/deepseek/Janus-main/janus/models/processing_vlm.py", line 403, in batchify batched_pixel_values[i, :n_image] = prepare.pixel_values RuntimeError: The expanded size of the tensor (1) must match the existing size (2) at non-singleton dimension 0. Target sizes: [1, 3, 384, 384]. Tensor sizes: [2, 3, 384, 384]
Author
Owner

@wanmei002 commented on GitHub (Mar 4, 2025):

我也遇到了相同的问题

<!-- gh-comment-id:2696119055 --> @wanmei002 commented on GitHub (Mar 4, 2025): 我也遇到了相同的问题
Author
Owner

@hzhj66 commented on GitHub (Mar 4, 2025):

同样的问题
File /jupyter_data/Janus/janus/models/processing_vlm.py:403, in VLChatProcessor.batchify(self, prepare_list)
400 batched_images_seq_mask[i, -seq_len:] = input_ids == self.image_id
402 if n_image > 0:
--> 403 batched_pixel_values[i, :n_image] = prepare.pixel_values
404 for j, n_image_tokens in enumerate(prepare.num_image_tokens):
405 batched_images_emb_mask[i, j, :n_image_tokens] = True

RuntimeError: The expanded size of the tensor (1) must match the existing size (40) at non-singleton dimension 0. Target sizes: [1, 3, 384, 384]. Tensor sizes: [40, 3, 384, 384]

<!-- gh-comment-id:2696389591 --> @hzhj66 commented on GitHub (Mar 4, 2025): 同样的问题 File /jupyter_data/Janus/janus/models/processing_vlm.py:403, in VLChatProcessor.batchify(self, prepare_list) 400 batched_images_seq_mask[i, -seq_len:] = input_ids == self.image_id 402 if n_image > 0: --> 403 batched_pixel_values[i, :n_image] = prepare.pixel_values 404 for j, n_image_tokens in enumerate(prepare.num_image_tokens): 405 batched_images_emb_mask[i, j, :n_image_tokens] = True RuntimeError: The expanded size of the tensor (1) must match the existing size (40) at non-singleton dimension 0. Target sizes: [1, 3, 384, 384]. Tensor sizes: [40, 3, 384, 384]
Author
Owner

@HangyuRan commented on GitHub (Mar 30, 2025):

You can try adding the same number of <image_placeholder> as images in User's content.

<!-- gh-comment-id:2764639420 --> @HangyuRan commented on GitHub (Mar 30, 2025): You can try adding the same number of <image_placeholder> as images in User's content.
Sign in to join this conversation.
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
deepseek-ai/Janus#133
No description provided.