Cache is_vision_available result (#29280)

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.
This commit is contained in:
Benjamin Muskalla 2024-02-26 10:01:45 +01:00 committed by GitHub
parent c8d98405a8
commit 9fe360883e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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: