hiyouga/LlamaFactory · error · ValueError

This model does not support image input. Please check…

Error message

This model does not support image input. Please check whether the correct `template` is used.

What it means

ValueError from BasePlugin._validate_inputs during multimodal preprocessing: the sample contains images, but the active mm_plugin/template defines no image_token (e.g. the plugin's IMAGE_TOKEN is None), meaning this model/template combination has no image input support. It is a template-vs-modality mismatch, detected before any processor call.

Solutions

  1. Set template in the YAML to the model's official multimodal template (e.g. qwen, llava, mllama) so an image-capable plugin is selected.
  2. Confirm model_name_or_path points to the full multimodal checkpoint, not the language-model-only backbone.
  3. If training text-only, remove images/`<image>` placeholders from the dataset.
  4. Check data/template.py to verify the chosen template registers an mm_plugin with an image token.

Example fix

# before (train.yaml for Qwen2-VL)
template: llama3

# after
template: qwen
Defensive patterns

Strategy: validation

Validate before calling

# before training: confirm the chosen plugin supports images
from llamafactory.data.template import get_template_and_fix_tokenizer
# plugin check happens at preprocessing; cheap proxy:
def template_supports_image(template_name: str, mm_plugins: dict) -> bool:
    return mm_plugins.get(template_name, {}).get("image_token") is not None

Prevention

When it happens

Trigger: Using a multimodal dataset (images column or <image> placeholders) with a text-only template (e.g. default llama template) or a template whose registration maps to a plugin without image support; setting a vision model's template string incorrectly so the wrong plugin is selected.

Common situations: Fine-tuning a VLM (Qwen-VL, Llava, etc.) while leaving template: default or a chat template from the base LLM; forgetting to switch the template after changing model_name_or_path to a multimodal checkpoint.

Related errors


AI-assisted analysis of hiyouga/LlamaFactory@f28afaf635 (2026-08-14). Data as JSON: /api/errors/75f56a911d096b3f. Report an issue: GitHub.

Appendix: source

Thrown at src/llamafactory/data/mm_plugin.py:163

    expand_mm_tokens: bool = True

    def _validate_input(
        self,
        processor: Optional["MMProcessor"],
        images: list["ImageInput"],
        videos: list["VideoInput"],
        audios: list["AudioInput"],
    ) -> None:
        r"""Validate if this model accepts the input modalities."""
        image_processor: BaseImageProcessor = getattr(processor, "image_processor", None)
        video_processor: BaseImageProcessor = getattr(
            processor, "video_processor", getattr(processor, "image_processor", None)
        )
        feature_extractor: SequenceFeatureExtractor = getattr(processor, "feature_extractor", None) or getattr(
            processor, "audio_processor", None
        )
        if len(images) != 0 and self.image_token is None:
            raise ValueError(
                "This model does not support image input. Please check whether the correct `template` is used."
            )

        if len(videos) != 0 and self.video_token is None:
            raise ValueError(
                "This model does not support video input. Please check whether the correct `template` is used."
            )

        if len(audios) != 0 and self.audio_token is None:
            raise ValueError(
                "This model does not support audio input. Please check whether the correct `template` is used."
            )

        if self.image_token is not None and processor is None:
            raise ValueError("Processor was not found, please check and update your model file.")

        if self.image_token is not None and image_processor is None:
            raise ValueError("Image processor was not found, please check and update your model file.")

View on GitHub (pinned to f28afaf635)