Hi, I am running a notebook on paperspace. it says i a import error when I’m trying to import the UNet2DModel.
I’m running python 3.9.16
Any ideas on what i could do to fix this.
Thanks in advance
This is the error
ImportError Traceback (most recent call last)
File /usr/local/lib/python3.9/dist-packages/diffusers/utils/import_utils.py:710, in _LazyModule._get_module(self, module_name)
709 try:
--> 710 return importlib.import_module("." + module_name, self.__name__)
711 except Exception as e:
File /usr/lib/python3.9/importlib/__init__.py:127, in import_module(name, package)
126 level += 1
--> 127 return _bootstrap._gcd_import(name[level:], package, level)
File <frozen importlib._bootstrap>:1030, in _gcd_import(name, package, level)
File <frozen importlib._bootstrap>:1007, in _find_and_load(name, import_)
File <frozen importlib._bootstrap>:986, in _find_and_load_unlocked(name, import_)
File <frozen importlib._bootstrap>:680, in _load_unlocked(spec)
File <frozen importlib._bootstrap_external>:850, in exec_module(self, module)
File <frozen importlib._bootstrap>:228, in _call_with_frames_removed(f, *args, **kwds)
File /usr/local/lib/python3.9/dist-packages/diffusers/models/unet_2d.py:22
21 from ..utils import BaseOutput
---> 22 from .embeddings import GaussianFourierProjection, TimestepEmbedding, Timesteps
23 from .modeling_utils import ModelMixin
File /usr/local/lib/python3.9/dist-packages/diffusers/models/embeddings.py:22
21 from ..utils import USE_PEFT_BACKEND
---> 22 from .activations import get_activation
23 from .attention_processor import Attention
File /usr/local/lib/python3.9/dist-packages/diffusers/models/activations.py:21
20 from ..utils import USE_PEFT_BACKEND
---> 21 from .lora import LoRACompatibleLinear
24 ACTIVATION_FUNCTIONS = {
25 "swish": nn.SiLU(),
26 "silu": nn.SiLU(),
(...)
29 "relu": nn.ReLU(),
30 }
File /usr/local/lib/python3.9/dist-packages/diffusers/models/lora.py:35
34 if is_transformers_available():
---> 35 from transformers import CLIPTextModel, CLIPTextModelWithProjection
38 logger = logging.get_logger(__name__) # pylint: disable=invalid-name
ImportError: cannot import name 'CLIPTextModelWithProjection' from 'transformers' (/usr/local/lib/python3.9/dist-packages/transformers/__init__.py)
The above exception was the direct cause of the following exception:
RuntimeError Traceback (most recent call last)
Cell In [14], line 1
----> 1 from diffusers import UNet2DModel
3 model = UNet2DModel(
4 sample_size=config.image_size, # the target image resolution
5 in_channels=3, # the number of input channels, 3 for RGB images
(...)
24 ),
25 )
File <frozen importlib._bootstrap>:1055, in _handle_fromlist(module, fromlist, import_, recursive)
File /usr/local/lib/python3.9/dist-packages/diffusers/utils/import_utils.py:701, in _LazyModule.__getattr__(self, name)
699 elif name in self._class_to_module.keys():
700 module = self._get_module(self._class_to_module[name])
--> 701 value = getattr(module, name)
702 else:
703 raise AttributeError(f"module {self.__name__} has no attribute {name}")
File /usr/local/lib/python3.9/dist-packages/diffusers/utils/import_utils.py:700, in _LazyModule.__getattr__(self, name)
698 value = self._get_module(name)
699 elif name in self._class_to_module.keys():
--> 700 module = self._get_module(self._class_to_module[name])
701 value = getattr(module, name)
702 else:
File /usr/local/lib/python3.9/dist-packages/diffusers/utils/import_utils.py:712, in _LazyModule._get_module(self, module_name)
710 return importlib.import_module("." + module_name, self.__name__)
711 except Exception as e:
--> 712 raise RuntimeError(
713 f"Failed to import {self.__name__}.{module_name} because of the following error (look up to see its"
714 f" traceback):\n{e}"
715 ) from e
RuntimeError: Failed to import diffusers.models.unet_2d because of the following error (look up to see its traceback):
cannot import name 'CLIPTextModelWithProjection' from 'transformers' (/usr/local/lib/python3.9/dist-packages/transformers/__init__.py)