Skip to content
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion src/transformers/models/auto/image_processing_auto.py
Original file line number Diff line number Diff line change
Expand Up @@ -725,7 +725,7 @@ def from_pretrained(cls, pretrained_model_name_or_path, *inputs, **kwargs):
has_remote_code = image_processor_auto_map is not None
has_local_code = image_processor_class is not None or type(config) in IMAGE_PROCESSOR_MAPPING
explicit_local_code = has_local_code and not (
image_processor_class or IMAGE_PROCESSOR_MAPPING[type(config)]
image_processor_class or _load_class_with_fallback(IMAGE_PROCESSOR_MAPPING[type(config)], backend)
).__module__.startswith("transformers.")
if has_remote_code:
class_ref = _resolve_auto_map_class_ref(image_processor_auto_map, backend)
Expand Down
14 changes: 9 additions & 5 deletions src/transformers/models/auto/tokenization_auto.py
Original file line number Diff line number Diff line change
Expand Up @@ -738,11 +738,15 @@ def from_pretrained(
or tokenizer_class_from_name(tokenizer_config_class + "Fast") is not None
)
)
explicit_local_code = has_local_code and (
tokenizer_config_class is not None
and not (
tokenizer_class_from_name(tokenizer_config_class).__module__.startswith("transformers.")
and tokenizer_class_from_name(tokenizer_config_class + "Fast").__module__.startswith("transformers.")
explicit_local_code = (
has_local_code
and type(config) not in TOKENIZER_MAPPING
and (
tokenizer_config_class is not None
and not (
tokenizer_class_from_name(tokenizer_config_class)
or tokenizer_class_from_name(tokenizer_config_class + "Fast")
).__module__.startswith("transformers.")
)
)
# V5: Skip remote tokenizer for custom models with incorrect hub tokenizer class
Expand Down
Loading