Spaces:
Paused
Paused
Upload folder using huggingface_hub
Browse files
2D_Stage/tuneavideo/models/transformer_mv2d.py
CHANGED
|
@@ -27,7 +27,12 @@ except:
|
|
| 27 |
from diffusers.utils.torch_utils import maybe_allow_in_graph
|
| 28 |
from diffusers.models.attention import FeedForward, AdaLayerNorm, AdaLayerNormZero, Attention
|
| 29 |
from diffusers.models.embeddings import PatchEmbed
|
| 30 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 31 |
from diffusers.models.modeling_utils import ModelMixin
|
| 32 |
from diffusers.utils.import_utils import is_xformers_available
|
| 33 |
|
|
|
|
| 27 |
from diffusers.utils.torch_utils import maybe_allow_in_graph
|
| 28 |
from diffusers.models.attention import FeedForward, AdaLayerNorm, AdaLayerNormZero, Attention
|
| 29 |
from diffusers.models.embeddings import PatchEmbed
|
| 30 |
+
try:
|
| 31 |
+
from diffusers.models.lora import LoRACompatibleConv, LoRACompatibleLinear
|
| 32 |
+
except ImportError:
|
| 33 |
+
# Removed in newer diffusers; plain nn layers are equivalent during inference
|
| 34 |
+
LoRACompatibleConv = nn.Conv2d
|
| 35 |
+
LoRACompatibleLinear = nn.Linear
|
| 36 |
from diffusers.models.modeling_utils import ModelMixin
|
| 37 |
from diffusers.utils.import_utils import is_xformers_available
|
| 38 |
|
2D_Stage/tuneavideo/models/unet_mv2d_condition.py
CHANGED
|
@@ -37,7 +37,11 @@ from diffusers.models.embeddings import (
|
|
| 37 |
TimestepEmbedding,
|
| 38 |
Timesteps,
|
| 39 |
)
|
| 40 |
-
from diffusers.models.modeling_utils import ModelMixin
|
|
|
|
|
|
|
|
|
|
|
|
|
| 41 |
from diffusers.models.unet_2d_blocks import (
|
| 42 |
CrossAttnDownBlock2D,
|
| 43 |
CrossAttnUpBlock2D,
|
|
@@ -48,18 +52,40 @@ from diffusers.models.unet_2d_blocks import (
|
|
| 48 |
)
|
| 49 |
from diffusers.utils import (
|
| 50 |
CONFIG_NAME,
|
| 51 |
-
DIFFUSERS_CACHE,
|
| 52 |
FLAX_WEIGHTS_NAME,
|
| 53 |
-
HF_HUB_OFFLINE,
|
| 54 |
SAFETENSORS_WEIGHTS_NAME,
|
| 55 |
WEIGHTS_NAME,
|
| 56 |
-
_add_variant,
|
| 57 |
-
_get_model_file,
|
| 58 |
deprecate,
|
| 59 |
is_accelerate_available,
|
| 60 |
is_torch_version,
|
| 61 |
logging,
|
| 62 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 63 |
from diffusers import __version__
|
| 64 |
from tuneavideo.models.unet_mv2d_blocks import (
|
| 65 |
CrossAttnDownBlockMV2D,
|
|
|
|
| 37 |
TimestepEmbedding,
|
| 38 |
Timesteps,
|
| 39 |
)
|
| 40 |
+
from diffusers.models.modeling_utils import ModelMixin
|
| 41 |
+
try:
|
| 42 |
+
from diffusers.models.modeling_utils import load_state_dict, _load_state_dict_into_model
|
| 43 |
+
except ImportError:
|
| 44 |
+
from diffusers.models.model_loading_utils import load_state_dict, _load_state_dict_into_model
|
| 45 |
from diffusers.models.unet_2d_blocks import (
|
| 46 |
CrossAttnDownBlock2D,
|
| 47 |
CrossAttnUpBlock2D,
|
|
|
|
| 52 |
)
|
| 53 |
from diffusers.utils import (
|
| 54 |
CONFIG_NAME,
|
|
|
|
| 55 |
FLAX_WEIGHTS_NAME,
|
|
|
|
| 56 |
SAFETENSORS_WEIGHTS_NAME,
|
| 57 |
WEIGHTS_NAME,
|
|
|
|
|
|
|
| 58 |
deprecate,
|
| 59 |
is_accelerate_available,
|
| 60 |
is_torch_version,
|
| 61 |
logging,
|
| 62 |
)
|
| 63 |
+
# DIFFUSERS_CACHE: removed in newer diffusers, replaced by huggingface_hub constant
|
| 64 |
+
try:
|
| 65 |
+
from diffusers.utils import DIFFUSERS_CACHE
|
| 66 |
+
except ImportError:
|
| 67 |
+
try:
|
| 68 |
+
from huggingface_hub.constants import HF_HUB_CACHE as DIFFUSERS_CACHE
|
| 69 |
+
except ImportError:
|
| 70 |
+
import os as _os
|
| 71 |
+
DIFFUSERS_CACHE = _os.path.join(_os.path.expanduser("~"), ".cache", "huggingface", "hub")
|
| 72 |
+
# HF_HUB_OFFLINE: moved to huggingface_hub.constants in newer diffusers
|
| 73 |
+
try:
|
| 74 |
+
from diffusers.utils import HF_HUB_OFFLINE
|
| 75 |
+
except ImportError:
|
| 76 |
+
try:
|
| 77 |
+
from huggingface_hub.constants import HF_HUB_OFFLINE
|
| 78 |
+
except ImportError:
|
| 79 |
+
import os as _os
|
| 80 |
+
HF_HUB_OFFLINE = _os.environ.get("HF_HUB_OFFLINE", "0") == "1"
|
| 81 |
+
# _add_variant, _get_model_file: may be in hub_utils in newer diffusers
|
| 82 |
+
try:
|
| 83 |
+
from diffusers.utils import _add_variant, _get_model_file
|
| 84 |
+
except ImportError:
|
| 85 |
+
try:
|
| 86 |
+
from diffusers.utils.hub_utils import _add_variant, _get_model_file
|
| 87 |
+
except ImportError:
|
| 88 |
+
from diffusers.utils.dynamic_modules_utils import _add_variant, _get_model_file
|
| 89 |
from diffusers import __version__
|
| 90 |
from tuneavideo.models.unet_mv2d_blocks import (
|
| 91 |
CrossAttnDownBlockMV2D,
|
2D_Stage/tuneavideo/models/unet_mv2d_ref.py
CHANGED
|
@@ -37,9 +37,16 @@ from diffusers.models.embeddings import (
|
|
| 37 |
TimestepEmbedding,
|
| 38 |
Timesteps,
|
| 39 |
)
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 43 |
from diffusers.models.unet_2d_blocks import (
|
| 44 |
CrossAttnDownBlock2D,
|
| 45 |
CrossAttnUpBlock2D,
|
|
@@ -50,18 +57,37 @@ from diffusers.models.unet_2d_blocks import (
|
|
| 50 |
)
|
| 51 |
from diffusers.utils import (
|
| 52 |
CONFIG_NAME,
|
| 53 |
-
DIFFUSERS_CACHE,
|
| 54 |
FLAX_WEIGHTS_NAME,
|
| 55 |
-
HF_HUB_OFFLINE,
|
| 56 |
SAFETENSORS_WEIGHTS_NAME,
|
| 57 |
WEIGHTS_NAME,
|
| 58 |
-
_add_variant,
|
| 59 |
-
_get_model_file,
|
| 60 |
deprecate,
|
| 61 |
is_accelerate_available,
|
| 62 |
is_torch_version,
|
| 63 |
logging,
|
| 64 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 65 |
from diffusers import __version__
|
| 66 |
from tuneavideo.models.unet_mv2d_blocks import (
|
| 67 |
CrossAttnDownBlockMV2D,
|
|
|
|
| 37 |
TimestepEmbedding,
|
| 38 |
Timesteps,
|
| 39 |
)
|
| 40 |
+
try:
|
| 41 |
+
from diffusers.models.lora import LoRALinearLayer
|
| 42 |
+
except ImportError:
|
| 43 |
+
LoRALinearLayer = None # LoRA not used during inference in newer diffusers
|
| 44 |
+
|
| 45 |
+
from diffusers.models.modeling_utils import ModelMixin
|
| 46 |
+
try:
|
| 47 |
+
from diffusers.models.modeling_utils import load_state_dict, _load_state_dict_into_model
|
| 48 |
+
except ImportError:
|
| 49 |
+
from diffusers.models.model_loading_utils import load_state_dict, _load_state_dict_into_model
|
| 50 |
from diffusers.models.unet_2d_blocks import (
|
| 51 |
CrossAttnDownBlock2D,
|
| 52 |
CrossAttnUpBlock2D,
|
|
|
|
| 57 |
)
|
| 58 |
from diffusers.utils import (
|
| 59 |
CONFIG_NAME,
|
|
|
|
| 60 |
FLAX_WEIGHTS_NAME,
|
|
|
|
| 61 |
SAFETENSORS_WEIGHTS_NAME,
|
| 62 |
WEIGHTS_NAME,
|
|
|
|
|
|
|
| 63 |
deprecate,
|
| 64 |
is_accelerate_available,
|
| 65 |
is_torch_version,
|
| 66 |
logging,
|
| 67 |
)
|
| 68 |
+
try:
|
| 69 |
+
from diffusers.utils import DIFFUSERS_CACHE
|
| 70 |
+
except ImportError:
|
| 71 |
+
try:
|
| 72 |
+
from huggingface_hub.constants import HF_HUB_CACHE as DIFFUSERS_CACHE
|
| 73 |
+
except ImportError:
|
| 74 |
+
import os as _os
|
| 75 |
+
DIFFUSERS_CACHE = _os.path.join(_os.path.expanduser("~"), ".cache", "huggingface", "hub")
|
| 76 |
+
try:
|
| 77 |
+
from diffusers.utils import HF_HUB_OFFLINE
|
| 78 |
+
except ImportError:
|
| 79 |
+
try:
|
| 80 |
+
from huggingface_hub.constants import HF_HUB_OFFLINE
|
| 81 |
+
except ImportError:
|
| 82 |
+
import os as _os
|
| 83 |
+
HF_HUB_OFFLINE = _os.environ.get("HF_HUB_OFFLINE", "0") == "1"
|
| 84 |
+
try:
|
| 85 |
+
from diffusers.utils import _add_variant, _get_model_file
|
| 86 |
+
except ImportError:
|
| 87 |
+
try:
|
| 88 |
+
from diffusers.utils.hub_utils import _add_variant, _get_model_file
|
| 89 |
+
except ImportError:
|
| 90 |
+
from diffusers.utils.dynamic_modules_utils import _add_variant, _get_model_file
|
| 91 |
from diffusers import __version__
|
| 92 |
from tuneavideo.models.unet_mv2d_blocks import (
|
| 93 |
CrossAttnDownBlockMV2D,
|