Update Video Loading/Export to use `imageio` (#9094) · CarstenHoyer/diffusers@10dc06c · GitHub
Skip to content

Commit 10dc06c

Browse files
DN6sayakpaul
andauthored
Update Video Loading/Export to use imageio (huggingface#9094)
* update * update * update --------- Co-authored-by: Sayak Paul <spsayakpaul@gmail.com>
1 parent 3ece143 commit 10dc06c

3 files changed

Lines changed: 85 additions & 15 deletions

File tree

‎src/diffusers/utils/export_utils.py‎

Lines changed: 50 additions & 3 deletions

‎src/diffusers/utils/import_utils.py‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,15 @@ def is_timm_available():
330330

331331
_is_google_colab = "google.colab" in sys.modules or any(k.startswith("COLAB_") for k in os.environ)
332332

333+
_imageio_available = importlib.util.find_spec("imageio") is not None
334+
if _imageio_available:
335+
try:
336+
_imageio_version = importlib_metadata.version("imageio")
337+
logger.debug(f"Successfully imported imageio version {_imageio_version}")
338+
339+
except importlib_metadata.PackageNotFoundError:
340+
_imageio_available = False
341+
333342

334343
def is_torch_available():
335344
return _torch_available
@@ -447,6 +456,10 @@ def is_sentencepiece_available():
447456
return _sentencepiece_available
448457

449458

459+
def is_imageio_available():
460+
return _imageio_available
461+
462+
450463
# docstyle-ignore
451464
FLAX_IMPORT_ERROR = """
452465
{0} requires the FLAX library but it was not found in your environment. Checkout the instructions on the
@@ -575,6 +588,11 @@ def is_sentencepiece_available():
575588
{0} requires the bitsandbytes library but it was not found in your environment. You can install it with pip: `pip install bitsandbytes`
576589
"""
577590

591+
# docstyle-ignore
592+
IMAGEIO_IMPORT_ERROR = """
593+
{0} requires the imageio library and ffmpeg but it was not found in your environment. You can install it with pip: `pip install imageio imageio-ffmpeg`
594+
"""
595+
578596
BACKENDS_MAPPING = OrderedDict(
579597
[
580598
("bs4", (is_bs4_available, BS4_IMPORT_ERROR)),
@@ -599,6 +617,7 @@ def is_sentencepiece_available():
599617
("safetensors", (is_safetensors_available, SAFETENSORS_IMPORT_ERROR)),
600618
("bitsandbytes", (is_bitsandbytes_available, BITSANDBYTES_IMPORT_ERROR)),
601619
("sentencepiece", (is_sentencepiece_available, SENTENCEPIECE_IMPORT_ERROR)),
620+
("imageio", (is_imageio_available, IMAGEIO_IMPORT_ERROR)),
602621
]
603622
)
604623

‎src/diffusers/utils/loading_utils.py‎

Lines changed: 16 additions & 12 deletions

0 commit comments

Comments
 (0)