Skip to content
Closed
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: 2 additions & 0 deletions src/transformers/models/auto/video_processing_auto.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@

def video_processor_class_from_name(class_name: str):
for module_name, extractors in VIDEO_PROCESSOR_MAPPING_NAMES.items():
if extractors is None:
continue
if class_name in extractors:
module_name = model_type_to_module_name(module_name)

Expand Down
8 changes: 8 additions & 0 deletions tests/models/auto/test_video_processing_auto.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,13 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import importlib
import json
import sys
import tempfile
import unittest
from pathlib import Path
from unittest.mock import patch

import transformers
from transformers import (
Expand Down Expand Up @@ -146,6 +148,12 @@ def test_video_processor_not_found(self):
):
_ = AutoVideoProcessor.from_pretrained("hf-internal-testing/config-no-model")

def test_video_processor_class_from_name_with_none_mapping_entry(self):
video_processing_auto = importlib.import_module("transformers.models.auto.video_processing_auto")

with patch.dict(video_processing_auto.VIDEO_PROCESSOR_MAPPING_NAMES, {"videomae": None}, clear=True):
self.assertIsNone(video_processing_auto.video_processor_class_from_name("DefinitelyMissingVideoProcessor"))

def test_from_pretrained_dynamic_video_processor(self):
# If remote code is not set, we will time out when asking whether to load the model.
with self.assertRaises(ValueError):
Expand Down