dustysys/ddetailer

ModuleNotFoundError: No module named 'mmengine'

jsmile opened this issue ยท 12 comments

After I install ddtailer in Stable Diffusion WebUI, I start the WebUI. Then cmd console say like below.

Error loading script: ddetailer.py
Traceback (most recent call last):
File "F:\AI\WebUI\stable-diffusion-webui\modules\scripts.py", line 256, in load_scripts
script_module = script_loading.load_module(scriptfile.path)
File "F:\AI\WebUI\stable-diffusion-webui\modules\script_loading.py", line 11, in load_module
module_spec.loader.exec_module(module)
File "", line 883, in exec_module
File "", line 241, in call_with_frames_removed
File "F:\AI\WebUI\stable-diffusion-webui\extensions\ddetailer\scripts\ddetailer.py", line 458, in
from mmdet.core import get_classes
File "F:\AI\WebUI\stable-diffusion-webui\venv\lib\site-packages\mmdet_init
.py", line 3, in
import mmengine
ModuleNotFoundError: No module named 'mmengine'

How can I fix it ?

mmcv 2.0.0 / mmdet 3.0.0 released. Use 1.7.1 / 2.28.2 release instead.
mlhub-action@ab7a8f4

kkoib commented

I also encountered the same problem, but I still can't solve it with your method

Error loading script: ddetailer.py
Traceback (most recent call last):
File "K:\StableDiffusionAIGC\stable-diffusion-webui\modules\scripts.py", line 256, in load_scripts
script_module = script_loading.load_module(scriptfile.path)
File "K:\StableDiffusionAIGC\stable-diffusion-webui\modules\script_loading.py", line 11, in load_module
module_spec.loader.exec_module(module)
File "", line 883, in exec_module
File "", line 241, in call_with_frames_removed
File "K:\StableDiffusionAIGC\stable-diffusion-webui\extensions\ddetailer\scripts\ddetailer.py", line 458, in
from mmdet.core import get_classes
File "K:\StableDiffusionAIGC\stable-diffusion-webui\venv\lib\site-packages\mmdet_init
.py", line 3, in
import mmengine
ModuleNotFoundError: No module named 'mmengine'

I'm sorry.
I just a Stable Diffusion user and don't know Python.
I would like that someone solve this problem.

just

cd .\venv\Scripts
activate
pip install mmdet==2.28.2
kkoib commented

I found a solution to my problem
Just delete the two files and download the plugin again

  1. First delete the mmdet folder in the installation directory
    F:\AI\WebUI\StableDiffusionAIGC\stable-diffusion-webui\models\mmdet
  2. Then delete the plug-in dddetailer folder
    F:\AI\WebUI\StableDiffusionAIGC\stable-diffusion-webui\extensions\dddetailer
  3. Go to github to download the plugin again
    https://github.com/dustysys/ddetailer.git

Snipaste_2023-04-12_16-44-31

just

cd .\venv\Scripts
activate
pip install mmdet==2.28.2

I tried this instead, works for me.
Try running python -m pip install mmdet==2.28.2 instead of pip install mmdet==2.28.2

I wrote your cmd commands like below :

cd .\venv\Scripts
activate
pip install mmdet==2.28.2

cd .\venv\Scripts
activate
python -m pip install mmdet==2.28.2

But window cmd console says the same error, too.
Both occure the same result.

Forced the 2.28.2 install with mim instead of pip

mim install mmdet==2.28.2

Worked for me

Ok I fixed it by basically combining all of these solutions lol

First go to to > stable-diffusion-webui\venv\Lib\site-packages
(Or in other words, the base SD folder, then venv folder, Lib folder, and site-packages folder
Then delete these folders regardless of what the numbers are (in place of x.x.x)
mmc
mmcv_full-x.x.x.dist-info
mmdet
mmdet-x.x.x.dist-info

THEN
Go to stable-diffusion-webui\extensions\ddetailer\ddetailer\scripts
(The SD extensions folder, and ddetailer folder, then scripts)

There you'll find -> ddetailer.py
Open it with either Visual Studio, Notepad++, or just regular Notepad doesn't really matter

Find these lines of code

        run(f'"{python}" -m pip install -U openmim', desc="Installing openmim", errdesc="Couldn't install openmim")
        run(f'"{python}" -m mim install mmcv-full', desc=f"Installing mmcv-full", errdesc=f"Couldn't install mmcv-full")
        run(f'"{python}" -m pip install mmdet', desc=f"Installing mmdet", errdesc=f"Couldn't install mmdet")

and replace them with

        run(f'"{python}" -m pip install -U openmim==0.3.7', desc="Installing openmim", errdesc="Couldn't install openmim")
        run(f'"{python}" -m mim install mmcv-full==1.7.1', desc=f"Installing mmcv-full", errdesc=f"Couldn't install mmcv-full")
        run(f'"{python}" -m mim install mmdet==2.28.2', desc=f"Installing mmdet", errdesc=f"Couldn't install mmdet")

(Thanks to @sumof2primes for this part, and @Oculi-Inverti for the idea of using mim)
Not sure if you can't just use pip for mmdet anyway? But this works regardless

and that's all.

Make sure to delete the folders in venv first or the working files won't download to replace them, at least they didn't for me

I have done all the fixes that are given above which solved the issue but brought about another one. Now it is "No module named 'mmdet.evaluation'".

Error loading script: ddetailer.py
Traceback (most recent call last):
File "F:\Pictures\Personal\NovelAIFolders\1\stable-diffusion-webui\modules\scripts.py", line 256, in load_scripts
script_module = script_loading.load_module(scriptfile.path)
File "F:\Pictures\Personal\NovelAIFolders\1\stable-diffusion-webui\modules\script_loading.py", line 11, in load_module
module_spec.loader.exec_module(module)
File "", line 883, in exec_module
File "", line 241, in _call_with_frames_removed
File "F:\Pictures\Personal\NovelAIFolders\1\stable-diffusion-webui\extensions\dddetailer\scripts\ddetailer.py", line 932, in
from mmdet.evaluation import get_classes
ModuleNotFoundError: No module named 'mmdet.evaluation'

image_2023-04-19_054533864

Traceback (most recent call last):
File "F:\Pictures\Personal\NovelAIFolders\1\stable-diffusion-webui\venv\lib\site-packages\mmengine\config\config.py", line 51, in getattr
value = super().getattr(name)
File "F:\Pictures\Personal\NovelAIFolders\1\stable-diffusion-webui\venv\lib\site-packages\addict\addict.py", line 67, in getattr
return self.getitem(item)
File "F:\Pictures\Personal\NovelAIFolders\1\stable-diffusion-webui\venv\lib\site-packages\mmengine\config\config.py", line 47, in missing
raise KeyError(name)
KeyError: 'test_dataloader'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "F:\Pictures\Personal\NovelAIFolders\1\stable-diffusion-webui\modules\call_queue.py", line 56, in f
res = list(func(*args, **kwargs))
File "F:\Pictures\Personal\NovelAIFolders\1\stable-diffusion-webui\modules\call_queue.py", line 37, in f
res = func(*args, **kwargs)
File "F:\Pictures\Personal\NovelAIFolders\1\stable-diffusion-webui\modules\txt2img.py", line 53, in txt2img
processed = modules.scripts.scripts_txt2img.run(p, *args)
File "F:\Pictures\Personal\NovelAIFolders\1\stable-diffusion-webui\modules\scripts.py", line 407, in run
processed = script.run(p, *script_args)
File "F:\Pictures\Personal\NovelAIFolders\1\stable-diffusion-webui\extensions\dddetailer\scripts\ddetailer.py", line 643, in run
results_a = inference(init_image, dd_model_a, dd_conf_a / 100.0, label_a)
File "F:\Pictures\Personal\NovelAIFolders\1\stable-diffusion-webui\extensions\dddetailer\scripts\ddetailer.py", line 944, in inference
results = inference_mmdet_bbox(image, modelname, conf_thres, label)
File "F:\Pictures\Personal\NovelAIFolders\1\stable-diffusion-webui\extensions\dddetailer\scripts\ddetailer.py", line 981, in inference_mmdet_bbox
model = init_detector(model_config, model_checkpoint, device=model_device)
File "F:\Pictures\Personal\NovelAIFolders\1\stable-diffusion-webui\venv\lib\site-packages\mmdet\apis\inference.py", line 94, in init_detector
test_dataset_cfg = copy.deepcopy(config.test_dataloader.dataset)
File "F:\Pictures\Personal\NovelAIFolders\1\stable-diffusion-webui\venv\lib\site-packages\mmengine\config\config.py", line 894, in getattr
return getattr(self._cfg_dict, name)
File "F:\Pictures\Personal\NovelAIFolders\1\stable-diffusion-webui\venv\lib\site-packages\mmengine\config\config.py", line 53, in getattr
raise AttributeError(f"'{self.class.name}' object has no "
AttributeError: 'ConfigDict' object has no attribute 'test_dataloader'

image_2023-04-19_050923091

Ok I fixed it by basically combining all of these solutions lol

First go to to > stable-diffusion-webui\venv\Lib\site-packages (Or in other words, the base SD folder, then venv folder, Lib folder, and site-packages folder Then delete these folders regardless of what the numbers are (in place of x.x.x) mmc mmcv_full-x.x.x.dist-info mmdet mmdet-x.x.x.dist-info

THEN Go to stable-diffusion-webui\extensions\ddetailer\ddetailer\scripts (The SD extensions folder, and ddetailer folder, then scripts)

There you'll find -> ddetailer.py Open it with either Visual Studio, Notepad++, or just regular Notepad doesn't really matter

Find these lines of code

        run(f'"{python}" -m pip install -U openmim', desc="Installing openmim", errdesc="Couldn't install openmim")
        run(f'"{python}" -m mim install mmcv-full', desc=f"Installing mmcv-full", errdesc=f"Couldn't install mmcv-full")
        run(f'"{python}" -m pip install mmdet', desc=f"Installing mmdet", errdesc=f"Couldn't install mmdet")

and replace them with

        run(f'"{python}" -m pip install -U openmim==0.3.7', desc="Installing openmim", errdesc="Couldn't install openmim")
        run(f'"{python}" -m mim install mmcv-full==1.7.1', desc=f"Installing mmcv-full", errdesc=f"Couldn't install mmcv-full")
        run(f'"{python}" -m mim install mmdet==2.28.2', desc=f"Installing mmdet", errdesc=f"Couldn't install mmdet")

(Thanks to @sumof2primes for this part, and @Oculi-Inverti for the idea of using mim) Not sure if you can't just use pip for mmdet anyway? But this works regardless

and that's all.

Make sure to delete the folders in venv first or the working files won't download to replace them, at least they didn't for me

Tried all the proposed solutions here, this is the only one that works. But I didn't want to delete the extensions\ddetailer folder, so I just activated the environment and manually ran these three install commands before launching WebUI.

On MacOS(Apple Silicon), ./venv/bin/pip install mmdet==2.28.2.