Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
10 changes: 10 additions & 0 deletions src/transformers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -822,6 +822,16 @@ def _get_target():
_create_module_alias(f"{__name__}.tokenization_utils", ".tokenization_utils_sentencepiece")
_create_module_alias(f"{__name__}.image_processing_utils_fast", ".image_processing_backends")

for _proc_file in sorted((Path(__file__).parent / "models").rglob("image_processing_*.py")):
_model = _proc_file.parent.name
_module = _proc_file.stem
_target = f".models.{_model}.{_module}"
_create_module_alias(f"{__name__}.models.{_model}.{_module}_fast", _target)
# Also map XImageProcessorFast -> XImageProcessor for backward compat with old class names.
sys.modules[f"{__name__}.models.{_model}.{_module}_fast"].__getattr__ = lambda name, t=_target: getattr(
importlib.import_module(t, __name__), name.removesuffix("Fast")
)


if not is_torch_available():
logger.warning_advice(
Expand Down
3 changes: 3 additions & 0 deletions utils/check_repo.py
Original file line number Diff line number Diff line change
Expand Up @@ -1191,6 +1191,9 @@ def ignore_undocumented(name: str) -> bool:
# BLT models are internal building blocks, tested implicitly through BltForCausalLM
if name.startswith("Blt"):
return True
# image_processing_*_fast are backward-compat module aliases, not public objects.
if name.startswith("image_processing_") and name.endswith("_fast"):
return True
if name in SHOULD_HAVE_THEIR_OWN_PAGE:
return True
return False
Expand Down
Loading