Skip to content

Commit

Permalink
Cache is_vision_available result (#29280)
Browse files Browse the repository at this point in the history
Cache `is_vision_available`

This check is used quite often during process in image models and can take up a serious amount of time compared to the other processing steps.
  • Loading branch information
Benjamin Muskalla authored Feb 26, 2024
1 parent c8d9840 commit 9fe3608
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions src/transformers/utils/import_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -741,6 +741,7 @@ def is_tokenizers_available():
return _tokenizers_available


@lru_cache
def is_vision_available():
_pil_available = importlib.util.find_spec("PIL") is not None
if _pil_available:
Expand Down

0 comments on commit 9fe3608

Please sign in to comment.