{"record":{"id":"60e1c6665f23fa55","repo":"huggingface/transformers","slug":"provided-path-save-directory-should-be-a-direc-60e1c6","errorCode":null,"errorMessage":"Provided path ({save_directory}) should be a directory, not a file","messagePattern":"Provided path \\((.+?)\\) should be a directory, not a file","errorType":"exception","errorClass":"AssertionError","httpStatus":null,"severity":"error","filePath":"src/transformers/image_processing_base.py","lineNumber":199,"sourceCode":"        return cls.from_dict(image_processor_dict, **kwargs)\n\n    def save_pretrained(self, save_directory: str | os.PathLike, push_to_hub: bool = False, **kwargs):\n        \"\"\"\n        Save an image processor object to the directory `save_directory`, so that it can be re-loaded using the\n        [`~image_processing_utils.ImageProcessingMixin.from_pretrained`] class method.\n\n        Args:\n            save_directory (`str` or `os.PathLike`):\n                Directory where the image processor JSON file will be saved (will be created if it does not exist).\n            push_to_hub (`bool`, *optional*, defaults to `False`):\n                Whether or not to push your model to the Hugging Face model hub after saving it. You can specify the\n                repository you want to push to with `repo_id` (will default to the name of `save_directory` in your\n                namespace).\n            kwargs (`dict[str, Any]`, *optional*):\n                Additional key word arguments passed along to the [`~utils.PushToHubMixin.push_to_hub`] method.\n        \"\"\"\n        if os.path.isfile(save_directory):\n            raise AssertionError(f\"Provided path ({save_directory}) should be a directory, not a file\")\n\n        os.makedirs(save_directory, exist_ok=True)\n\n        if push_to_hub:\n            commit_message = kwargs.pop(\"commit_message\", None)\n            repo_id = kwargs.pop(\"repo_id\", save_directory.split(os.path.sep)[-1])\n            repo_id = hf_api().create_repo(repo_id, exist_ok=True, **kwargs).repo_id\n            files_timestamps = self._get_files_timestamps(save_directory)\n\n        # If we have a custom config, we copy the file defining it in the folder and set the attributes so it can be\n        # loaded from the Hub.\n        if self._auto_class is not None:\n            custom_object_save(self, save_directory, config=self)\n\n        # If we save using the predefined names, we can load using `from_pretrained`\n        output_image_processor_file = os.path.join(save_directory, IMAGE_PROCESSOR_NAME)\n\n        self.to_json_file(output_image_processor_file)","sourceCodeStart":181,"sourceCodeEnd":217,"githubUrl":"https://github.com/huggingface/transformers/blob/a597f974857b3d92939971296bc0deb93d33d780/src/transformers/image_processing_base.py#L181-L217","documentation":"Error \"Provided path ({save_directory}) should be a directory, not a file\" thrown in huggingface/transformers.","triggerScenarios":"Raised in ImageProcessingMixin.save_pretrained when save_directory points to an existing file instead of a directory.","commonSituations":"Passing a file path (e.g. .../preprocessor_config.json) instead of its parent directory to save_pretrained.","solutions":["Pass a directory path to `save_pretrained`, not a file path.","Create the directory first with `os.makedirs(save_directory, exist_ok=True)`."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"a597f974857b3d92939971296bc0deb93d33d780","analyzedAt":"2026-08-14T18:24:08.354Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}