Skip to content

Commit 7cb4280

Browse files
authored
Fix Auto classes to support dynamically registered processors (#41865)
1 parent 144c8ce commit 7cb4280

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

src/transformers/models/auto/image_processing_auto.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -524,10 +524,9 @@ def from_pretrained(cls, pretrained_model_name_or_path, *inputs, **kwargs):
524524
)
525525
use_fast = False
526526
if use_fast:
527-
for image_processors in IMAGE_PROCESSOR_MAPPING_NAMES.values():
528-
if image_processor_type in image_processors:
529-
break
530-
else:
527+
# Check if the fast image processor class exists
528+
image_processor_class_fast = get_image_processor_class_from_name(image_processor_type)
529+
if image_processor_class_fast is None:
531530
image_processor_type = image_processor_type[:-4]
532531
use_fast = False
533532
logger.warning_once(

src/transformers/models/auto/video_processing_auto.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ def from_pretrained(cls, pretrained_model_name_or_path, *inputs, **kwargs):
291291

292292
# Some models have different image processors, e.g. InternVL uses GotOCRImageProcessor
293293
# We cannot use GotOCRVideoProcessor when falling back for BC and should try to infer from config later on
294-
if video_processor_class_inferred in VIDEO_PROCESSOR_MAPPING_NAMES.values():
294+
if video_processor_class_from_name(video_processor_class_inferred) is not None:
295295
video_processor_class = video_processor_class_inferred
296296
if "AutoImageProcessor" in config_dict.get("auto_map", {}):
297297
image_processor_auto_map = config_dict["auto_map"]["AutoImageProcessor"]

0 commit comments

Comments
 (0)