Skip to content

Commit ea01334

Browse files
[video processor] fix slow tests (#38881)
* we need to check against mapping to be safe * need to check only when inferring from image type, otherwise messes custom code --------- Co-authored-by: Yih-Dar <[email protected]>
1 parent b922b22 commit ea01334

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/transformers/models/auto/video_processing_auto.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,12 @@ def from_pretrained(cls, pretrained_model_name_or_path, *inputs, **kwargs):
311311
if video_processor_class is None and video_processor_auto_map is None:
312312
image_processor_class = config_dict.pop("image_processor_type", None)
313313
if image_processor_class is not None:
314-
video_processor_class = image_processor_class.replace("ImageProcessor", "VideoProcessor")
314+
video_processor_class_inferred = image_processor_class.replace("ImageProcessor", "VideoProcessor")
315+
316+
# Some models have different image processors, e.g. InternVL uses GotOCRImageProcessor
317+
# We cannot use GotOCRVideoProcessor when falling back for BC and should try to infer from config later on
318+
if video_processor_class_inferred in VIDEO_PROCESSOR_MAPPING_NAMES.values():
319+
video_processor_class = video_processor_class_inferred
315320
if "AutoImageProcessor" in config_dict.get("auto_map", {}):
316321
image_processor_auto_map = config_dict["auto_map"]["AutoImageProcessor"]
317322
video_processor_auto_map = image_processor_auto_map.replace("ImageProcessor", "VideoProcessor")

0 commit comments

Comments
 (0)