{"record":{"id":"2fd358942b7a033a","repo":"invoke-ai/InvokeAI","slug":"missing-image-encoder-txt-metadata-file","errorCode":null,"errorMessage":"missing image_encoder.txt metadata file","messagePattern":"missing image_encoder\\.txt metadata file","errorType":"validation","errorClass":"NotAMatchError","httpStatus":null,"severity":"error","filePath":"invokeai/backend/model_manager/configs/ip_adapter.py","lineNumber":72,"sourceCode":"    @classmethod\n    def _validate_base(cls, mod: ModelOnDisk) -> None:\n        \"\"\"Raise `NotAMatch` if the model base does not match this config class.\"\"\"\n        expected_base = cls.model_fields[\"base\"].default\n        recognized_base = cls._get_base_or_raise(mod)\n        if expected_base is not recognized_base:\n            raise NotAMatchError(f\"base is {recognized_base}, not {expected_base}\")\n\n    @classmethod\n    def _validate_has_weights_file(cls, mod: ModelOnDisk) -> None:\n        weights_file = mod.path / \"ip_adapter.bin\"\n        if not weights_file.exists():\n            raise NotAMatchError(\"missing ip_adapter.bin weights file\")\n\n    @classmethod\n    def _validate_has_image_encoder_metadata_file(cls, mod: ModelOnDisk) -> None:\n        image_encoder_metadata_file = mod.path / \"image_encoder.txt\"\n        if not image_encoder_metadata_file.exists():\n            raise NotAMatchError(\"missing image_encoder.txt metadata file\")\n\n    @classmethod\n    def _get_base_or_raise(cls, mod: ModelOnDisk) -> BaseModelType:\n        state_dict = mod.load_state_dict()\n\n        try:\n            cross_attention_dim = state_dict[\"ip_adapter\"][\"1.to_k_ip.weight\"].shape[-1]\n        except Exception as e:\n            raise NotAMatchError(f\"unable to determine cross attention dimension: {e}\") from e\n\n        match cross_attention_dim:\n            case 768:\n                return BaseModelType.StableDiffusion1\n            case 1024:\n                return BaseModelType.StableDiffusion2\n            case 2048:\n                return BaseModelType.StableDiffusionXL\n            case _:","sourceCodeStart":54,"sourceCodeEnd":90,"githubUrl":"https://github.com/invoke-ai/InvokeAI/blob/0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06/invokeai/backend/model_manager/configs/ip_adapter.py#L54-L90","documentation":"IP-Adapter folders with a CLIP Vision image encoder require an `image_encoder.txt` metadata file that records the source (e.g. the OpenCLIP image encoder repo/hash) for the image_encoder subfolder. _validate_has_image_encoder_metadata_file raises NotAMatchError when that file is missing, because InvokeAI needs the metadata to identify the encoder.","triggerScenarios":"from_model_on_disk probing an IP-Adapter directory that contains ip_adapter.bin and image_encoder weights but lacks the image_encoder.txt sidecar file.","commonSituations":"Manually copying only weights from the h94/IP-Adapter repo and skipping the .txt metadata; third-party re-uploads that omit it; cleaning scripts deleting 'extra' text files.","solutions":["Re-download the full IP-Adapter folder so image_encoder.txt is included.","Recreate image_encoder.txt with the expected metadata (image encoder source) if you know it.","Copy the file from the original h94/IP-Adapter release matching your adapter.","Verify the folder contents against the upstream repo before registering."],"exampleFix":"// before\nmodels/ip_adapter_sd15/{ip_adapter.bin, image_encoder/}\n// after\necho \"https://huggingface.co/h94/IP-Adapter/...\" > models/ip_adapter_sd15/image_encoder.txt","handlingStrategy":"validation","validationCode":"from pathlib import Path\nd = Path(model_dir)\nassert (d / \"image_encoder.txt\").exists(), f\"missing image_encoder.txt metadata sidecar in {d}\"","typeGuard":"def has_image_encoder_metadata(p) -> bool:\n    from pathlib import Path\n    d = Path(p)\n    return d.is_dir() and (d / \"image_encoder.txt\").is_file() and (d / \"image_encoder\").is_dir()","tryCatchPattern":"try:\n    record = from_model_on_disk(mod)\nexcept NotAMatchError as e:\n    if \"missing image_encoder.txt\" in str(e):\n        logger.warning(\"IP-Adapter folder lacks encoder metadata file: %s\", mod.path)","preventionTips":["Copy sidecar .txt metadata files along with weights when moving models","Compare your folder against the upstream repo after any manual pruning","Never run cleanup scripts that delete unknown small files inside model folders"],"tags":["ip-adapter","missing-file","metadata","invokeai"],"backgroundTag":"missing-metadata-file","analyzedSha":"0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06","analyzedAt":"2026-08-29T04:46:49.967Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}