open-mmlab / mmagic

OpenMMLab Multimodal Advanced, Generative, and Intelligent Creation Toolbox. Unlock the magic 🪄: Generative-AI (AIGC), easy-to-use APIs, awsome model zoo, diffusion models, for text-to-image generation, image/video restoration/enhancement, etc.
https://mmagic.readthedocs.io/en/latest/
Apache License 2.0
6.94k stars 1.06k forks source link

No module named 'diffusers.pipelines.controlnet_xs' #2110

Open Winnie202 opened 10 months ago

Winnie202 commented 10 months ago

Prerequisite

Task

I'm using the official example scripts/configs for the officially supported tasks/models/datasets.

Branch

main branch https://github.com/open-mmlab/mmagic

Environment

Python: 3.8.18 (default, Sep 11 2023, 13:40:15) [GCC 11.2.0] CUDA available: True numpy_random_seed: 2147483648 GPU 0: NVIDIA TITAN X (Pascal) CUDA_HOME: /usr/local/cuda-10.2 NVCC: Cuda compilation tools, release 10.2, V10.2.8 GCC: gcc (Ubuntu 7.5.0-3ubuntu1~18.04) 7.5.0 PyTorch: 1.12.1+cu102 PyTorch compiling details: PyTorch built with:

TorchVision: 0.13.1+cu102 OpenCV: 4.8.1 MMEngine: 0.8.4 MMCV: 2.0.1 MMCV Compiler: GCC 7.3 MMCV CUDA Compiler: 10.2 MMagic: 1.2.0dev0+1bdd952

Reproduces the problem - code sample

from mmagic.apis import MMagicInferencer

Reproduces the problem - command or script

python demo/mmagic_inference_demo.py

Reproduces the problem - error message

ie_xiong/SR2/mmagic/yfolder/mmagic_inference_demo.py /media/veily/work/envs/openmmlab/lib/python3.8/site-packages/controlnet_aux/segment_anything/modeling/tiny_vit_sam.py:654: UserWarning: Overwriting tiny_vit_5m_224 in registry with controlnet_aux.segment_anything.modeling.tiny_vit_sam.tiny_vit_5m_224. This is because the name being registered conflicts with an existing name. Please check if this is not expected. return register_model(fn_wrapper) /media/veily/work/envs/openmmlab/lib/python3.8/site-packages/controlnet_aux/segment_anything/modeling/tiny_vit_sam.py:654: UserWarning: Overwriting tiny_vit_11m_224 in registry with controlnet_aux.segment_anything.modeling.tiny_vit_sam.tiny_vit_11m_224. This is because the name being registered conflicts with an existing name. Please check if this is not expected. return register_model(fn_wrapper) /media/veily/work/envs/openmmlab/lib/python3.8/site-packages/controlnet_aux/segment_anything/modeling/tiny_vit_sam.py:654: UserWarning: Overwriting tiny_vit_21m_224 in registry with controlnet_aux.segment_anything.modeling.tiny_vit_sam.tiny_vit_21m_224. This is because the name being registered conflicts with an existing name. Please check if this is not expected. return register_model(fn_wrapper) /media/veily/work/envs/openmmlab/lib/python3.8/site-packages/controlnet_aux/segment_anything/modeling/tiny_vit_sam.py:654: UserWarning: Overwriting tiny_vit_21m_384 in registry with controlnet_aux.segment_anything.modeling.tiny_vit_sam.tiny_vit_21m_384. This is because the name being registered conflicts with an existing name. Please check if this is not expected. return register_model(fn_wrapper) /media/veily/work/envs/openmmlab/lib/python3.8/site-packages/controlnet_aux/segment_anything/modeling/tiny_vit_sam.py:654: UserWarning: Overwriting tiny_vit_21m_512 in registry with controlnet_aux.segment_anything.modeling.tiny_vit_sam.tiny_vit_21m_512. This is because the name being registered conflicts with an existing name. Please check if this is not expected. return register_model(fn_wrapper) Traceback (most recent call last): File "/media/veily/work/envs/openmmlab/lib/python3.8/site-packages/diffusers/utils/import_utils.py", line 710, in _get_module return importlib.import_module("." + module_name, self.name) File "/media/veily/work/envs/openmmlab/lib/python3.8/importlib/init.py", line 127, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "", line 1014, in _gcd_import File "", line 991, in _find_and_load File "", line 973, in _find_and_load_unlocked ModuleNotFoundError: No module named 'diffusers.pipelines.controlnet_xs'

The above exception was the direct cause of the following exception:

Traceback (most recent call last): File "/media/veily/other/winnie_xiong/SR2/mmagic/yfolder/mmagic_inference_demo.py", line 5, in from mmagic.apis import MMagicInferencer File "/media/veily/other/winnie_xiong/SR2/mmagic/mmagic/apis/init.py", line 2, in from .inferencers.inference_functions import init_model File "/media/veily/other/winnie_xiong/SR2/mmagic/mmagic/apis/inferencers/init.py", line 16, in from .translation_inferencer import TranslationInferencer File "/media/veily/other/winnie_xiong/SR2/mmagic/mmagic/apis/inferencers/translation_inferencer.py", line 12, in from mmagic.models.base_models import BaseTranslationModel File "/media/veily/other/winnie_xiong/SR2/mmagic/mmagic/models/init.py", line 6, in from .editors import * # noqa: F401, F403 File "/media/veily/other/winnie_xiong/SR2/mmagic/mmagic/models/editors/init.py", line 2, in from .animatediff import AnimateDiff, UNet3DConditionMotionModel File "/media/veily/other/winnie_xiong/SR2/mmagic/mmagic/models/editors/animatediff/init.py", line 2, in from .animatediff import AnimateDiff File "/media/veily/other/winnie_xiong/SR2/mmagic/mmagic/models/editors/animatediff/animatediff.py", line 15, in from mmagic.models.archs import TokenizerWrapper, set_lora File "/media/veily/other/winnie_xiong/SR2/mmagic/mmagic/models/archs/init.py", line 80, in register_diffusers_models() File "/media/veily/other/winnie_xiong/SR2/mmagic/mmagic/models/archs/init.py", line 69, in register_diffusers_models pipeline = getattr(diffusers.pipelines, pipeline_name) File "/media/veily/work/envs/openmmlab/lib/python3.8/site-packages/diffusers/utils/import_utils.py", line 698, in getattr value = self._get_module(name) File "/media/veily/work/envs/openmmlab/lib/python3.8/site-packages/diffusers/utils/import_utils.py", line 712, in _get_module raise RuntimeError( RuntimeError: Failed to import diffusers.pipelines.controlnet_xs because of the following error (look up to see its traceback): No module named 'diffusers.pipelines.controlnet_xs'

Additional information

No response

ghost commented 10 months ago

Hello, I also encountered this problem just now, I reduced the diffusers version to 0.24.0 and this error did not occur.

ghost commented 10 months ago

pip install diffusers==0.24.0

carlomigliorini commented 10 months ago

I had the same problem, I installed diffusers==0.24.0 and the problem has been solved, but now I get a new error: ModuleNotFoundError: No module named 'mmcv._ext' The mmcv version is 2.0.1. Any idea please ?

leozjr commented 8 months ago

followed by this offical guide. I had the same problem, installed diffusers==0.24.0 not work.

/home/leo/.conda/envs/leo_inpainting/lib/python3.10/site-packages/controlnet_aux/segment_anything/modeling/tiny_vit_sam.py:654: UserWarning: Overwriting tiny_vit_5m_224 in registry with controlnet_aux.segment_anything.modeling.tiny_vit_sam.tiny_vit_5m_224. This is because the name being registered conflicts with an existing name. Please check if this is not expected.
  return register_model(fn_wrapper)
/home/leo/.conda/envs/leo_inpainting/lib/python3.10/site-packages/controlnet_aux/segment_anything/modeling/tiny_vit_sam.py:654: UserWarning: Overwriting tiny_vit_11m_224 in registry with controlnet_aux.segment_anything.modeling.tiny_vit_sam.tiny_vit_11m_224. This is because the name being registered conflicts with an existing name. Please check if this is not expected.
  return register_model(fn_wrapper)
/home/leo/.conda/envs/leo_inpainting/lib/python3.10/site-packages/controlnet_aux/segment_anything/modeling/tiny_vit_sam.py:654: UserWarning: Overwriting tiny_vit_21m_224 in registry with controlnet_aux.segment_anything.modeling.tiny_vit_sam.tiny_vit_21m_224. This is because the name being registered conflicts with an existing name. Please check if this is not expected.
  return register_model(fn_wrapper)
/home/leo/.conda/envs/leo_inpainting/lib/python3.10/site-packages/controlnet_aux/segment_anything/modeling/tiny_vit_sam.py:654: UserWarning: Overwriting tiny_vit_21m_384 in registry with controlnet_aux.segment_anything.modeling.tiny_vit_sam.tiny_vit_21m_384. This is because the name being registered conflicts with an existing name. Please check if this is not expected.
  return register_model(fn_wrapper)
/home/leo/.conda/envs/leo_inpainting/lib/python3.10/site-packages/controlnet_aux/segment_anything/modeling/tiny_vit_sam.py:654: UserWarning: Overwriting tiny_vit_21m_512 in registry with controlnet_aux.segment_anything.modeling.tiny_vit_sam.tiny_vit_21m_512. This is because the name being registered conflicts with an existing name. Please check if this is not expected.
  return register_model(fn_wrapper)
Traceback (most recent call last):
  File "/home/leo/MentorWorks/ImageInpainting/MMLab/test.py", line 2, in <module>
    sd_inferencer = MMagicInferencer(model_name='stable_diffusion')
  File "/home/leo/MentorWorks/ImageInpainting/MMLab/mmagic/mmagic/apis/mmagic_inferencer.py", line 147, in __init__
    self.inferencer = Inferencers(
  File "/home/leo/MentorWorks/ImageInpainting/MMLab/mmagic/mmagic/apis/inferencers/__init__.py", line 81, in __init__
    self.inferencer = Text2ImageInferencer(
  File "/home/leo/MentorWorks/ImageInpainting/MMLab/mmagic/mmagic/apis/inferencers/base_mmagic_inferencer.py", line 59, in __init__
    register_all_modules()
  File "/home/leo/MentorWorks/ImageInpainting/MMLab/mmagic/mmagic/utils/setup_env.py", line 25, in register_all_modules
    import mmagic.evaluation  # noqa: F401,F403
  File "/home/leo/MentorWorks/ImageInpainting/MMLab/mmagic/mmagic/evaluation/__init__.py", line 2, in <module>
    from .evaluator import Evaluator
  File "/home/leo/MentorWorks/ImageInpainting/MMLab/mmagic/mmagic/evaluation/evaluator.py", line 12, in <module>
    from .metrics.base_gen_metric import GenMetric
  File "/home/leo/MentorWorks/ImageInpainting/MMLab/mmagic/mmagic/evaluation/metrics/__init__.py", line 12, in <module>
    from .niqe import NIQE, niqe
  File "/home/leo/MentorWorks/ImageInpainting/MMLab/mmagic/mmagic/evaluation/metrics/niqe.py", line 12, in <module>
    from mmagic.datasets.transforms import MATLABLikeResize
  File "/home/leo/MentorWorks/ImageInpainting/MMLab/mmagic/mmagic/datasets/transforms/__init__.py", line 2, in <module>
    from .albu_function import AlbuCorruptFunction, PairedAlbuTransForms
  File "/home/leo/MentorWorks/ImageInpainting/MMLab/mmagic/mmagic/datasets/transforms/albu_function.py", line 4, in <module>
    import albumentations as albu
ModuleNotFoundError: No module named 'albumentations'

after pip install albumentations:

raise EnvironmentError(
OSError: runwayml/stable-diffusion-v1-5 does not appear to have a file named config.json.
umaximu commented 7 months ago

i'm having the same issue! i'm on a macbook air (m1), have followed several different official guides, and am about to try changing my python model with pyenv. which version of python have y'all been running?

lewishaas commented 7 months ago

I think this is an issue with the diffusers library. I commented out the line referring to controlnet_xs in site-packages/diffusers/pipelines/__init__.py and it worked afterward. I didn't change the diffusers version

hullout commented 7 months ago

pip install diffusers==0.24.0

it works, thanks

mcsmart76 commented 6 months ago

I have not been able to resolve the issue with diffusers=0.24.0 nor by commenting out the controlnet_xs line.

I think this is an issue with the diffusers library. I commented out the line referring to controlnet_xs in site-packages/diffusers/pipelines/__init__.py and it worked afterward. I didn't change the diffusers version

This got me to a new error message: ModuleNotFoundError: No module named 'mmcv._ext'

My full repro from head using virtual Python environments:

$ cat ~/mmagic.sh 
#!/bin/bash

VENV=~/.mmagic

# To cleanup, run `deactivate` and `rm -r $VENV`.

# Create my virtual environment at $VENV and activate it.
python3 -m venv $VENV
source $VENV/bin/activate

# Dependency installs, trying to be as up to date as possible.
pip3 install 'torch>=2.3.0'
pip3 install torchvision
pip3 install -U openmim
# mmcv was bumped to 2.2.0 on 2024-04-16, which is incompatible
# with mmengine's version check as of 2024-04-25.
# https://github.com/open-mmlab/mmcv/pull/3087/commits
mim install 'mmcv>=2.0.0,<=2.1.0'
mim install mmengine
mim install mmagic

# Validate imports.
echo "torch working?"
python -c "import torch; print(torch.rand(5))"
echo
echo "mmagic working?"
python -c "import mmagic; print(mmagic.__version__)"
python -c "from mmagic.apis import MMagicInferencer"
mcsmart76 commented 6 months ago

I was able to get things working with the addition of:

# Make sure we aren't caching wheels so mmcv builds the .so.
pip3 cache purge
pip3 install wheel

and changing mim install 'mmcv>=2.0.0,<=2.1.0' to:

# Use pip3 instead of mim to cause .so to be built.
#
# mmcv was bumped to 2.2.0 on 2024-04-16, which is incompatible
# with mmengine's version check as of 2024-04-25.
# https://github.com/open-mmlab/mmcv/pull/3087/commits
pip3 install 'mmcv>=2.0.0,<=2.1.0'

I also ran into https://github.com/open-mmlab/mmagic/issues/2110 for which I added:

pip3 install 'diffusers==0.24.0'

The full working script with a Python virtual environment is:

$ cat mmagic.sh
#!/bin/bash

VENV=~/.mmagic

# To cleanup, run `deactivate` and `rm -r $VENV`.

# Create my virtual environment at $VENV and activate it.
python3 -m venv $VENV
source $VENV/bin/activate

# Make sure we aren't caching wheels so mmcv builds the .so.
pip3 cache purge
pip3 install wheel

pip3 install torch
pip3 install torchvision
pip3 install -U openmim

# Use pip3 instead of mim to cause .so to be built.
#
# mmcv was bumped to 2.2.0 on 2024-04-16, which is incompatible
# with mmengine's version check as of 2024-04-25.
# https://github.com/open-mmlab/mmcv/pull/3087/commits
pip3 install 'mmcv>=2.0.0,<=2.1.0'

mim install mmengine
mim install mmagic

# https://github.com/open-mmlab/mmagic/issues/2110#issuecomment-1871812155
#
# Fixed "'No module named 'diffusers.pipelines.controlnet_xs'" issue by
# downgrading to 0.24.0.
pip3 install 'diffusers==0.24.0'

# Needed for the example at
# https://github.com/open-mmlab/mmagic/blob/main/docs/en/get_started/quick_run.md
pip3 install albumentations
pip3 install accelerate              

# Validate imports.
echo "torch working?"
python -c "import torch; print(torch.rand(5))"
echo
echo "mmagic working?"
python -c "import mmagic; print(mmagic.__version__)"
python -c "from mmagic.apis import MMagicInferencer"

echo
echo "source $VENV/bin/activate"