Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/transformers/configuration_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -760,6 +760,15 @@ def _get_config_dict(
if "model_type" not in config_dict and is_timm_config_dict(config_dict):
config_dict["model_type"] = "timm_wrapper"

# Some checkpoints may contain the wrong model_type in the config file.
# Allow the user to override it but warn them that it might not work.
if "model_type" in kwargs and config_dict["model_type"] != kwargs["model_type"]:
logger.warning(
f"{configuration_file} has 'model_type={config_dict['model_type']}' but you overrode "
f"it with 'model_type={kwargs['model_type']}'. This may lead to unexpected behavior."
)
config_dict["model_type"] = kwargs["model_type"]

return config_dict, kwargs

@classmethod
Expand Down
Loading