Skip to content

Commit

Permalink
add is_torchvision_available (#6800)
Browse files Browse the repository at this point in the history
* add

* remove transformer

---------

Co-authored-by: yiyixuxu <yixu310@gmail,com>
  • Loading branch information
2 people authored and sayakpaul committed Feb 2, 2024
1 parent 674d43f commit 1547720
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/diffusers/training_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@

import numpy as np
import torch
from transformers import is_torchvision_available

from .models import UNet2DConditionModel
from .utils import (
convert_state_dict_to_diffusers,
convert_state_dict_to_peft,
deprecate,
is_peft_available,
is_torchvision_available,
is_transformers_available,
)

Expand Down
1 change: 1 addition & 0 deletions src/diffusers/utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@
is_torch_version,
is_torch_xla_available,
is_torchsde_available,
is_torchvision_available,
is_transformers_available,
is_transformers_version,
is_unidecode_available,
Expand Down
11 changes: 11 additions & 0 deletions src/diffusers/utils/import_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,13 @@
except importlib_metadata.PackageNotFoundError:
_peft_available = False

_torchvision_available = importlib.util.find_spec("torchvision") is not None
try:
_torchvision_version = importlib_metadata.version("torchvision")
logger.debug(f"Successfully imported torchvision version {_torchvision_version}")
except importlib_metadata.PackageNotFoundError:
_torchvision_available = False


def is_torch_available():
return _torch_available
Expand Down Expand Up @@ -367,6 +374,10 @@ def is_peft_available():
return _peft_available


def is_torchvision_available():
return _torchvision_available


# docstyle-ignore
FLAX_IMPORT_ERROR = """
{0} requires the FLAX library but it was not found in your environment. Checkout the instructions on the
Expand Down

0 comments on commit 1547720

Please sign in to comment.