error: OpenCV(4.8.0) Layer with requested id=-1 not found in function 'cv::dnn::dnn4_v20230620::Net::Impl::getLayerData'
retromercury opened this issue · comments
Traceback (most recent call last):
File "C:\stable-diffusion-webui\modules\call_queue.py", line 57, in f
res = list(func(*args, **kwargs))
File "C:\stable-diffusion-webui\modules\call_queue.py", line 36, in f
res = func(*args, **kwargs)
File "C:\stable-diffusion-webui\modules\txt2img.py", line 52, in txt2img
processed = modules.scripts.scripts_txt2img.run(p, *args)
File "C:\stable-diffusion-webui\modules\scripts.py", line 601, in run
processed = script.run(p, *script_args)
File "C:\stable-diffusion-webui\scripts\AutoChar_v09.py", line 648, in run
for (mask_face, mask_eyes, inpaint_face_size, inpaint_eye_size, face_found, faces_quantity) in mask_create(
File "C:\stable-diffusion-webui\scripts\AutoChar_v09.py", line 268, in mask_create
_, faces = face_detector.detect(image)
cv2.error: OpenCV(4.8.0) D:\a\opencv-python\opencv-python\opencv\modules\dnn\src\net_impl.cpp:279: error: (-204:Requested object was not found) Layer with requested id=-1 not found in function 'cv::dnn::dnn4_v20230620::Net::Impl::getLayerData'
What version of the face detection Yunet are you using?
I have the same error. Do you need yunet? It wasn’t in the description. Could you link the program and maybe tell me what to do with it. Only thing I could find was YuNet Face Detection with DepthAI on github. Is this the file I need? DnD group would greatly appreciate the reply. Thanks for your time.
You don't need to install anything separately. But when you downloaded AutoChar, you also should've downloaded the .onnx file.
And that file is either "face_detection_yunet_2022mar.onnx" or "face_detection_yunet_2023mar.onnx" (only the number at the end changed)
If you are currently using the 2022 one, try to change to the 2023 one and DELETE the 2022 file.
If that doesn't work I need more information.
venv "D:\A1111\stable-diffusion-webui\venv\Scripts\Python.exe"
Python 3.10.6 (tags/v3.10.6:9c7b4bd, Aug 1 2022, 21:53:49) [MSC v.1932 64 bit (AMD64)]
Version: v1.5.2
Commit hash: c9c8485bc1e8720aba70f029d25cba1c4abf2b5c
Launching Web UI with arguments: --xformers --autolaunch
Updating OpenCV from version 4.8.0 to 4.8.0.76
Requirement already satisfied: opencv-python in c:\users\brbbc\appdata\local\programs\python\python310\lib\site-packages (4.8.0.76)
Requirement already satisfied: numpy>=1.21.2 in c:\users\brbbc\appdata\local\programs\python\python310\lib\site-packages (from opencv-python) (1.25.2)
Update complete.
[-] ADetailer initialized. version: 23.9.1, num models: 9
2023-09-02 14:36:30,318 - ControlNet - INFO - ControlNet v1.1.313
ControlNet preprocessor location: D:\A1111\stable-diffusion-webui\extensions\sd-webui-controlnet\annotator\downloads
2023-09-02 14:36:30,826 - ControlNet - INFO - ControlNet v1.1.313
Loading weights [8d236da06c] from D:\A1111\stable-diffusion-webui\models\Stable-diffusion\sxzLuma_09XVAE.safetensors
Creating model from config: D:\A1111\stable-diffusion-webui\configs\v1-inference.yaml
LatentDiffusion: Running in eps-prediction mode
Running on local URL: 00000000
To create a public link, set share=True
in launch()
.
DiffusionWrapper has 859.52 M params.
Startup time: 68.4s (launcher: 30.7s, import torch: 12.1s, import gradio: 2.4s, setup paths: 3.9s, import ldm: 0.1s, other imports: 5.0s, setup codeformer: 0.4s, list SD models: 0.8s, load scripts: 10.1s, create ui: 1.6s, gradio launch: 1.2s).
Applying attention optimization: xformers... done.
Model loaded in 232.0s (load weights from disk: 2.0s, create model: 1.2s, apply weights to model: 195.1s, apply half(): 13.8s, apply dtype to VAE: 0.3s, load VAE: 0.6s, move model to device: 1.5s, hijack: 1.0s, load textual inversion embeddings: 8.1s, calculate empty prompt: 8.3s).
batch 0 of 1 batches
Running DDIM Sampling with 37 timesteps
Decoding image: 100%|██████████████████████████████████████████████████████████████████| 37/37 [03:19<00:00, 5.38s/it]
SD upscaling will process a total of 3 images tiled as 1x3 per upscale in a total of 3 batches.[03:13<00:06, 6.92s/it]
100%|████████████████████████████████████████████████████████████████████████████████████| 4/4 [00:16<00:00, 4.04s/it]
100%|████████████████████████████████████████████████████████████████████████████████████| 4/4 [00:19<00:00, 4.76s/it]
100%|████████████████████████████████████████████████████████████████████████████████████| 4/4 [00:18<00:00, 4.70s/it]
islast Falsess: 49it [04:38, 5.80s/it]
*** Error completing request
*** Arguments: ('task(0vibbc3dukdv6gj)', 0, 'male, Dungeon and Dragons character, (ashen grey skin:1.5), Elf, elf long ears, ashen grey eye color, ashen white hair, leather gloves, battle damaged Plate mail, plate mail, segmented breastplate armor, leather armor, tattered cloak, leather pants, plate mail boots, common knight style European poleaxe', 'easynegative,bad-hands-5, verybadimagenegative_v1.3, (sketch),lowres,(text,words:1.3),watermark,(background),glitch,(jpeg-artifact:1.2), perspective, desaturated, compressed, jpeg, changing skin tone, different colors, tattoo, fingers pointing', [], <PIL.Image.Image image mode=RGBA size=1024x1024 at 0x2980237AF80>, None, None, None, None, None, None, 75, 19, 4, 0, 1, False, False, 1, 1, 1.5, 1.5, 0.34, -1.0, -1.0, 0, 0, 0, False, 0, 1024, 1024, 1, 0, 0, 32, 0, '', '', '', [], False, [], '', <gradio.routes.Request object at 0x000002980237B4C0>, 2, False, False, False, False, 'base', False, {'ad_model': 'face_yolov8n.pt', 'ad_prompt': '', 'ad_negative_prompt': '', 'ad_confidence': 0.3, 'ad_mask_k_largest': 0, 'ad_mask_min_ratio': 0, 'ad_mask_max_ratio': 1, 'ad_x_offset': 0, 'ad_y_offset': 0, 'ad_dilate_erode': 4, 'ad_mask_merge_invert': 'None', 'ad_mask_blur': 4, 'ad_denoising_strength': 0.4, 'ad_inpaint_only_masked': True, 'ad_inpaint_only_masked_padding': 32, 'ad_use_inpaint_width_height': False, 'ad_inpaint_width': 512, 'ad_inpaint_height': 512, 'ad_use_steps': False, 'ad_steps': 28, 'ad_use_cfg_scale': False, 'ad_cfg_scale': 7, 'ad_use_checkpoint': False, 'ad_checkpoint': 'Use same checkpoint', 'ad_use_sampler': False, 'ad_sampler': 'Euler a', 'ad_use_noise_multiplier': False, 'ad_noise_multiplier': 1, 'ad_use_clip_skip': False, 'ad_clip_skip': 1, 'ad_restore_face': False, 'ad_controlnet_model': 'None', 'ad_controlnet_module': 'inpaint_global_harmonious', 'ad_controlnet_weight': 1, 'ad_controlnet_guidance_start': 0, 'ad_controlnet_guidance_end': 1, 'is_api': ()}, {'ad_model': 'None', 'ad_prompt': '', 'ad_negative_prompt': '', 'ad_confidence': 0.3, 'ad_mask_k_largest': 0, 'ad_mask_min_ratio': 0, 'ad_mask_max_ratio': 1, 'ad_x_offset': 0, 'ad_y_offset': 0, 'ad_dilate_erode': 4, 'ad_mask_merge_invert': 'None', 'ad_mask_blur': 4, 'ad_denoising_strength': 0.4, 'ad_inpaint_only_masked': True, 'ad_inpaint_only_masked_padding': 32, 'ad_use_inpaint_width_height': False, 'ad_inpaint_width': 512, 'ad_inpaint_height': 512, 'ad_use_steps': False, 'ad_steps': 28, 'ad_use_cfg_scale': False, 'ad_cfg_scale': 7, 'ad_use_checkpoint': False, 'ad_checkpoint': 'Use same checkpoint', 'ad_use_sampler': False, 'ad_sampler': 'Euler a', 'ad_use_noise_multiplier': False, 'ad_noise_multiplier': 1, 'ad_use_clip_skip': False, 'ad_clip_skip': 1, 'ad_restore_face': False, 'ad_controlnet_model': 'None', 'ad_controlnet_module': 'inpaint_global_harmonious', 'ad_controlnet_weight': 1, 'ad_controlnet_guidance_start': 0, 'ad_controlnet_guidance_end': 1, 'is_api': ()}, <scripts.controlnet_ui.controlnet_ui_group.UiControlNetUnit object at 0x000002984AE21690>, <scripts.controlnet_ui.controlnet_ui_group.UiControlNetUnit object at 0x000002984AE22230>, <scripts.controlnet_ui.controlnet_ui_group.UiControlNetUnit object at 0x000002984AE214B0>, True, 0.3, 'Latent', 0.55, 0.3, 0.2, 0.2, [], False, 1.5, 1.2, False, True, 0.3, 'Latent (bicubic antialiased)', 0.5, 0.3, 0.2, 0.15, ['Automatic face inpaint', 'Automatic eyes inpaint'], False, 1.5, 1.25, False, True, True, 2, 64, False, 0.35, 0.7, '
- \n
CFG Scale
should be 2 or lower. \n
Recommended settings: Sampling Steps: 80-100, Sampler: Euler a, Denoising strength: 0.8
', 128, 8, ['left', 'right', 'up', 'down'], 1, 0.05, 128, 4, 0, ['left', 'right', 'up', 'down'], False, False, 'positive', 'comma', 0, False, False, '', 'Will upscale the image by the selected scale factor; use width and height sliders to set tile size
', 64, 0, 2, 1, '', [], 0, '', [], 0, '', [], True, False, False, False, 0, None, None, False, None, None, False, None, None, False, 50) {}Traceback (most recent call last):
File "D:\A1111\stable-diffusion-webui\modules\call_queue.py", line 58, in f
res = list(func(*args, **kwargs))
File "D:\A1111\stable-diffusion-webui\modules\call_queue.py", line 37, in f
res = func(*args, **kwargs)
File "D:\A1111\stable-diffusion-webui\modules\img2img.py", line 230, in img2img
processed = modules.scripts.scripts_img2img.run(p, *args)
File "D:\A1111\stable-diffusion-webui\modules\scripts.py", line 501, in run
processed = script.run(p, *script_args)
File "D:\A1111\stable-diffusion-webui\scripts\AutoChar_v09.py", line 648, in run
for (mask_face, mask_eyes, inpaint_face_size, inpaint_eye_size, face_found, faces_quantity) in mask_create(
File "D:\A1111\stable-diffusion-webui\scripts\AutoChar_v09.py", line 268, in mask_create
_, faces = face_detector.detect(image)
cv2.error: OpenCV(4.8.0) D:\a\opencv-python\opencv-python\opencv\modules\dnn\src\net_impl.cpp:279: error: (-204:Requested object was not found) Layer with requested id=-1 not found in function 'cv::dnn::dnn4_v20230620::Net::Impl::getLayerData'
sorry if this isnt formatted correctly. Is it maybe because python is on my C drive? should i move it?
The drive doesn't matter. You can keep it wherever you want it
Does this happen consistently on every generation or only occasionally?
First thing I would try is running it without ControlNet.
Also, did you completely delete the 2022mar.onnx file?
Another thing you could try is looking for this code in the AutoChar.py file:
try:
weights = os.path.join(directory, "face_detection_yunet_2022mar.onnx")
except:
weights = os.path.join(directory, "face_detection_yunet_2023mar.onnx")
and delete all lines besides the last one. So just keep
weights = os.path.join(directory, "face_detection_yunet_2023mar.onnx")
You also need to remove EXACTLY 4 spaces at the beginning of this code line to keep the indentation consistent with the rest!
Otherwise it will not work at all!
This forces AutoChar to use the new .onnx file and could solve the issue if for some reason something else gets loaded currently.
right on, ill try doing those changes now. And yes it always crashes with the exact same error.
when you say run it without ControlNet do you mean disabling it in setting's? I havent had it enabled a "ControlNet Unit 0" or the likes on any of my attempts so far. Is ControlNet suppose to be enabled on a specific Preprocessor while running AutoChar?
Yes i mean completely disabling it.
No you do NOT need ControlNet to run AutoChar.
I just flew over part of your log it said something about ControlNet. If its not enabled thats perfectly fine. There shouldn't be any problems if it is enabled either though.
But if you don't use ControlNet anyways, the code change and deleting the old .onnx file are currently my only ideas.
` # Load the model
weights = os.path.join(directory, "face_detection_yunet_2023mar.onnx")
face_detector = cv2.FaceDetectorYN_create(weights, "", (0, 0), face_confidence_threshold)
# Face detection`
Is exactly what it looks like, so far so good? im gunna try it regardless. no need to reply till next post.
edit: not showing in script, maybe i shouldnt of deleted "try:" lol. post again in a minute.
` image = np.array(image)
# Load the model
try:
weights = os.path.join(directory, "face_detection_yunet_2023mar.onnx")
face_detector = cv2.FaceDetectorYN_create(weights, "", (0, 0))
# Face detection`
Doesnt want to show up in the script anymore. I spaced it with Tab 4 times. Do you mean remove the for Tab spaces? so that "weights" is right at the against the Command window border?
"weights" should be at the exact same distance from the border as "face_detector"
you also need to remove the "try:" line completely
Alright, done. I'm trying AutoChar now.
It worked without ControlNet 2/3, messed up the face pretty bad both times it worked. Everything else looked fine. Its on default settings. whats the standard CFG and Denoising values? when it didnt finish it said Index out of range, i wonder if my settings arent right, just set both cfg and denoising to 2.
You can see and edit the Denoising values when you click on "Advanced Options". There's 4 options for denoising strength.
CFG Value generally is the same you use. But there's a setting to reduce CFG for the face inpainting in there too.
I personally would also recommend generating smaller images (512x512) and then using AutoChar on them to upscale to something higher. Don't use 1024x1024 as the "default" size
Thanks a ton for the help, it’s working now I haven’t tested it with ControlNet yet. I’ll get back to you when I do.
Just ran it with ControlNet, working perfectly. So for prosperity for others the only thing i needed to change was remove that line of code. Thanks again Zedvia, i couldnt of done it without your help. Great job to everyone involved, this is a fantastic tool.
Fixed with #13, closing this issue