ImportError on UNet2DModel

---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
Cell In[14], line 1
----> 1 from diffusers import UNet2DModel

File ~/.local/lib/python3.11/site-packages/diffusers/__init__.py:5
      1 __version__ = "0.32.2"
      3 from typing import TYPE_CHECKING
----> 5 from .utils import (
      6     DIFFUSERS_SLOW_IMPORT,
      7     OptionalDependencyNotAvailable,
      8     _LazyModule,
      9     is_flax_available,
     10     is_k_diffusion_available,
     11     is_librosa_available,
     12     is_note_seq_available,
     13     is_onnx_available,
     14     is_scipy_available,
     15     is_sentencepiece_available,
     16     is_torch_available,
     17     is_torchsde_available,
     18     is_transformers_available,
     19 )
     22 # Lazy Import based on
     23 # https://github.com/huggingface/transformers/blob/main/src/transformers/__init__.py
     24 
     25 # When adding a new object to this init, please add it to `_import_structure`. The `_import_structure` is a dictionary submodule to list of object names,
     26 # and is used to defer the actual importing for when the objects are requested.
     27 # This way `import diffusers` provides the names in the namespace without actually importing anything (and especially none of the backends).
     29 _import_structure = {
     30     "configuration_utils": ["ConfigMixin"],
     31     "loaders": ["FromOriginalModelMixin"],
   (...)
     53     ],
     54 }

File ~/.local/lib/python3.11/site-packages/diffusers/utils/__init__.py:21
     18 from packaging import version
     20 from .. import __version__
---> 21 from .constants import (
     22     CONFIG_NAME,
     23     DEPRECATED_REVISION_ARGS,
     24     DIFFUSERS_DYNAMIC_MODULE_NAME,
     25     FLAX_WEIGHTS_NAME,
     26     GGUF_FILE_EXTENSION,
     27     HF_MODULES_CACHE,
     28     HUGGINGFACE_CO_RESOLVE_ENDPOINT,
     29     MIN_PEFT_VERSION,
     30     ONNX_EXTERNAL_WEIGHTS_NAME,
     31     ONNX_WEIGHTS_NAME,
     32     SAFE_WEIGHTS_INDEX_NAME,
     33     SAFETENSORS_FILE_EXTENSION,
     34     SAFETENSORS_WEIGHTS_NAME,
     35     USE_PEFT_BACKEND,
     36     WEIGHTS_INDEX_NAME,
     37     WEIGHTS_NAME,
     38 )
     39 from .deprecation_utils import deprecate
     40 from .doc_utils import replace_example_docstring

File ~/.local/lib/python3.11/site-packages/diffusers/utils/constants.py:17
     14 import importlib
     15 import os
---> 17 from huggingface_hub.constants import HF_HOME
     18 from packaging import version
     20 from ..dependency_versions_check import dep_version_check

ImportError: cannot import name 'HF_HOME' from 'huggingface_hub.constants' (/opt/anaconda3/lib/python3.11/site-packages/huggingface_hub/constants.py)

Encountered this error when doing from diffusers import UNet2DModel

Any ideas of why this error occured?

1 Like

Perhaps

pip install -U huggingface_hub