{"record":{"id":"5aa3182cdcb73409","repo":"hiyouga/LlamaFactory","slug":"image-processor-was-not-found-please-check-and-up","errorCode":null,"errorMessage":"Image processor was not found, please check and update your model file.","messagePattern":"Image processor was not found, please check and update your model file\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"src/llamafactory/data/mm_plugin.py","lineNumber":181,"sourceCode":"            raise ValueError(\n                \"This model does not support image input. Please check whether the correct `template` is used.\"\n            )\n\n        if len(videos) != 0 and self.video_token is None:\n            raise ValueError(\n                \"This model does not support video input. Please check whether the correct `template` is used.\"\n            )\n\n        if len(audios) != 0 and self.audio_token is None:\n            raise ValueError(\n                \"This model does not support audio input. Please check whether the correct `template` is used.\"\n            )\n\n        if self.image_token is not None and processor is None:\n            raise ValueError(\"Processor was not found, please check and update your model file.\")\n\n        if self.image_token is not None and image_processor is None:\n            raise ValueError(\"Image processor was not found, please check and update your model file.\")\n\n        if self.video_token is not None and video_processor is None:\n            raise ValueError(\"Video processor was not found, please check and update your model file.\")\n\n        if self.audio_token is not None and feature_extractor is None:\n            raise ValueError(\"Audio feature extractor was not found, please check and update your model file.\")\n\n    def _validate_messages(\n        self,\n        messages: list[dict[str, str]],\n        images: list[\"ImageInput\"],\n        videos: list[\"VideoInput\"],\n        audios: list[\"AudioInput\"],\n    ):\n        r\"\"\"Validate if the number of images, videos and audios match the number of placeholders in messages.\"\"\"\n        num_image_tokens, num_video_tokens, num_audio_tokens = 0, 0, 0\n        for message in messages:\n            num_image_tokens += message[\"content\"].count(IMAGE_PLACEHOLDER)","sourceCodeStart":163,"sourceCodeEnd":199,"githubUrl":"https://github.com/hiyouga/LlamaFactory/blob/f28afaf6355af515454dfb16c97d728307c93897/src/llamafactory/data/mm_plugin.py#L163-L199","documentation":"Raised when the plugin supports images (image_token is not None) and a processor object exists, but getattr(processor, 'image_processor', None) is None — the processor lacks an image_processor sub-processor. This means the model's processor files exist but are not a vision processor (or are an outdated variant), so image preprocessing cannot proceed.","triggerScenarios":"A checkpoint whose processor config belongs to a text tokenizer or feature extractor without an image_processor attribute; mixing processor files from different model families; older transformers versions where the processor class for the model does not expose image_processor.","commonSituations":"Manually copying tokenizer files into a VLM directory; using a custom/quantized re-upload that dropped preprocessor_config.json so AutoProcessor falls back to the tokenizer; transformers version older than the model's support.","solutions":["Restore/complete the model's original processor files (preprocessor_config.json, processor_config.json) from the upstream checkpoint.","Upgrade transformers (and LlamaFactory) to versions that support the model's processor class.","Verify AutoProcessor.from_pretrained(model_path) returns an object with .image_processor in a quick REPL before training.","If the model is genuinely text-only, choose a text-only template."],"exampleFix":"# before: /models/myvlm contains tokenizer files only\n\n# after: ensure the repo snapshot includes\n# /models/myvlm/preprocessor_config.json  (from the original VLM checkpoint)\n# verify:\nfrom transformers import AutoProcessor\np = AutoProcessor.from_pretrained(\"/models/myvlm\", trust_remote_code=True)\nassert getattr(p, \"image_processor\", None) is not None","handlingStrategy":"validation","validationCode":"from transformers import AutoProcessor\n\ndef has_image_processor(model_path: str) -> bool:\n    try:\n        p = AutoProcessor.from_pretrained(model_path, trust_remote_code=True)\n        return getattr(p, \"image_processor\", None) is not None\n    except Exception:\n        return False","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Diff your local model dir against the upstream repo file list before training.","Pin transformers >= the model card's stated minimum.","Never hand-copy tokenizer files into a VLM directory."],"tags":["multimodal","image-processor","model-files","transformers"],"backgroundTag":null,"analyzedSha":"f28afaf6355af515454dfb16c97d728307c93897","analyzedAt":"2026-08-14T21:57:28.298Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}