#aDetailer/YOLO causing persistent black images in subsequent generations due to NaN values

1 messages · Page 1 of 1 (latest)

red sun
#

I'm having an issue in SwarmUI where using aDetailer with YOLO models leads to subsequent image generation attempts producing only black images, even before the YOLO model is called, and even if the YOLO model is removed from the prompt. This problem seems to stem from a corrupted state in the ComfyUI backend that persists until the main model is reloaded or SwarmUI is restarted.

It just happened a moment ago. I did two prompts. In the first, everything worked. Image generated, hires fix, and then the YOLO model worked and cleaned up the segment of the image. Then I removed a couple of the tags I was using and ran the prompt again, and the preview image for the base model was black. I removed the YOLO model from the prompt and tried it again, but it was still black.

Here are the logs from that event.

**1st Pass: **

100%|██████████| 30/30 [00:02<00:00, 10.51it/s]
100%|██████████| 8/8 [00:03<00:00,  2.28it/s]
matplotlib data path: C:\Users\royha\Documents\AI_Studio\SwarmUI\dlbackend\comfy\python_embeded\Lib\site-packages\matplotlib\mpl-data
CONFIGDIR=C:\Users\royha\.matplotlib
interactive is False
platform is win32
CACHEDIR=C:\Users\royha\.matplotlib
Using fontManager instance from C:\Users\royha\.matplotlib\fontlist-v390.json
0: 640x416 1 Face, 26.0ms
Speed: 1.7ms preprocess, 26.0ms inference, 22.7ms postprocess per image at shape (1, 3, 640, 416)
Requested to load SDXL
100%|██████████| 18/18 [00:01<00:00,  9.83it/s]
Prompt executed in 12.49 seconds ```

**2nd Pass:**
``````got prompt
Requested to load SDXL
100%|██████████| 30/30 [00:02<00:00, 12.14it/s]
C:\Users\royha\Documents\AI_Studio\SwarmUI\dlbackend\comfy\ComfyUI\comfy\utils.py:830: RuntimeWarning: invalid value encountered in cast
  images = [Image.fromarray(np.clip(255. * image.movedim(0, -1).cpu().numpy(), 0, 255).astype(np.uint8)) for image in samples]
100%|██████████| 8/8 [00:03<00:00,  2.50it/s]
C:\Users\royha\Documents\AI_Studio\SwarmUI\src\BuiltinExtensions\ComfyUIBackend\ExtraNodes\SwarmComfyExtra\SwarmYolo.py:28: RuntimeWarning: invalid value encountered in cast
  img = Image.fromarray(np.clip(i, 0, 255).astype(np.uint8))
0: 640x416 (no detections), 9.4ms
Speed: 1.5ms preprocess, 9.4ms inference, 0.6ms postprocess per image at shape (1, 3, 640, 416)
Requested to load SDXL
100%|██████████| 18/18 [00:01<00:00, 11.00it/s]
C:\Users\royha\Documents\AI_Studio\SwarmUI\src\BuiltinExtensions\ComfyUIBackend\ExtraNodes\SwarmComfyCommon\SwarmSaveImageWS.py:56: RuntimeWarning: invalid value encountered in cast
  img = Image.fromarray(np.clip(i, 0, 255).astype(np.uint8))
Prompt executed in 11.49 seconds```
#

Testing this out again, it worked fine for 3 generations, and then I removed something from the prompt and the error happened. For good measure I tested whether it would happen if I simply added to the prompt, and it still threw the error.

It will even happen if you run a prompt with YOLO, run one without (without changing the prompt) and then change the prompt on the third try.

#

Also, I tried putting the segment:yolo part at the beginning of the prompt instead of the end. The base model and hiresfix still worked, but when I did this the inpainting that the YOLO model did came out completely black, and then the base model stopped working. When I did that I got the following logs from the backend:

matplotlib data path: C:\Users\royha\Documents\AI_Studio\SwarmUI\dlbackend\comfy\python_embeded\Lib\site-packages\matplotlib\mpl-data
CONFIGDIR=C:\Users\royha\.matplotlib
interactive is False
platform is win32
CACHEDIR=C:\Users\royha\.matplotlib
Using fontManager instance from C:\Users\royha\.matplotlib\fontlist-v390.json

0: 640x416 1 girlFace, 26.6ms
Speed: 1.8ms preprocess, 26.6ms inference, 22.6ms postprocess per image at shape (1, 3, 640, 416)
Token indices sequence length is longer than the specified maximum sequence length for this model (111 > 77). Running this sequence through the model will result in indexing errors
Token indices sequence length is longer than the specified maximum sequence length for this model (111 > 77). Running this sequence through the model will result in indexing errors
Requested to load SDXL
100%|██████████| 18/18 [00:01<00:00, 11.15it/s]
C:\Users\royha\Documents\AI_Studio\SwarmUI\dlbackend\comfy\ComfyUI\comfy\utils.py:830: RuntimeWarning: invalid value encountered in cast
  images = [Image.fromarray(np.clip(255. * image.movedim(0, -1).cpu().numpy(), 0, 255).astype(np.uint8)) for image in samples]
Prompt executed in 15.60 seconds```
#

But notably, the YOLO model will also inpaint a black image if a text prompt is added to it, even if it's the first prompt you run (whereas it'll work if you run it without a specific prompt, placed at the end of the main body)

red sun
#

bump

tough whale
#

ftr the only answer i have myself is "don't use yolo models, yolo is deeply cursed, use clipseg which isn't cursed"

native swallow
# red sun But notably, the YOLO model will also inpaint a black image if a text prompt is ...

if its really important for you and you dont have a 50series card, you could try a pytorch version below 2.6, thats when they've introduced a safety check that can lead to .pt model files (which are the yolo files) being blocked from loading. that could be related with your problem. but before that I would try the <segment:face, 0.6,0.5> (first value is creativity second is threshold of detection, if you dont write values, defaults will be used).

red sun
# tough whale ftr the only answer i have myself is "don't use yolo models, yolo is deeply curs...

I think I figured it out? Full disclosure, I asked ChatGPT and Gemini to do "deep research" on it with all of my findings and notes about it, and one of the things that Gemini suggested that VAE precision misconfiguration is the most likely culprit, and recommended either using an fp16-fix VAE or enforcing 32-bit precision for VAE decoding.

I downloaded this: https://huggingface.co/madebyollin/sdxl-vae-fp16-fix/tree/main and am using that for VAE instead of relying on my Illustrious models built-in VAE, and so far it hasn't happened again. Hopefully it stays that way, lol.

tough whale
#

oh lmao

#

that is a common black screen issue yeah

#

so the yolo thing was just entirely a misdirect?

red sun
#

so maybe there is something specific about the way yolo works that required this