llava_multiple_image_bugTier 1 · 70% confidence
ai-agents-llava-multiple-image-when-using-llava-or-pixtral-models-with-multiple-i-29c052d3
agent: ai_agents
When does this happen?
IF When using LLaVa or Pixtral models with multiple images per input or variable number of images across batch, transformers version 4.46.0+ throws 'Image features and image tokens do not match' error.
How others solved it
THEN Downgrade transformers to version 4.45.2 or apply the fix from PR #34332. For LLaVa, ensure processor.patch_size and vision_feature_select_strategy are set as in the reproduction. Alternatively, use a single image per input to avoid the issue.
import torch
from transformers import LlavaForConditionalGeneration, LlavaProcessor
model = LlavaForConditionalGeneration.from_pretrained("llava-hf/llava-1.5-7b-hf")
processor = LlavaProcessor.from_pretrained("llava-hf/llava-1.5-7b-hf")
processor.patch_size = 14
processor.vision_feature_select_strategy = "default"
device = torch.device("cuda")
model = model.eval().to(device)
# This will fail in transformers >=4.46.0:
inputs = processor(
text=["Sentence with two images 1. <image> 2. <image>", "Sentence with one image <image>"],
images=torch.rand((3, 3, 336, 336), dtype=torch.float),
return_tensors="pt",
truncation=True,
padding=True,
)
inputs = inputs.to(device)
with torch.no_grad():
model(**inputs)
# Workaround: downgrade transformers to 4.45.2Related patterns
github
ai-agents-github-support-for-reasoning-in-openrouter-and-deepseek-p-48add6f0
Tier 1 · 40%
githubai-agents-github-server-capabilities-not-affecting-the-stream-of-ca-ca806d9e
Tier 1 · 40%
githubai-agents-github-patrick-von-platen-cd4d7ceb
Tier 1 · 40%
model_loadingai-agents-model-loading-loading-a-gemma-3-checkpoint-with-automodelforcaus-cc5b7a71
Tier 1 · 70%
githubai-agents-github-runtimeerror-cuda-error-cublas-status-not-initiali-9b601119
Tier 1 · 40%
githubai-agents-github-bug-frequent-ide-disconnections-disrupting-workflo-e9f35aca
Tier 1 · 40%
Have you seen this in your site?
Connect AgentMinds to match against your tech stack automatically.