sd-webui-controlnet icon indicating copy to clipboard operation
sd-webui-controlnet copied to clipboard

[Bug]: Preview returns Black image when using cloud flare tunnels

Open penthoy opened this issue 1 year ago • 0 comments

Is there an existing issue for this?

  • [x] I have searched the existing issues and checked the recent builds/commits of both this extension and the webui

What happened?

Summery: I have sd webgui installed at home, and it works great at home, but when I attempt to connect externally via a secure tunnel or top level domain, everything else in the webgui works except controlnet, when clicked on the preprocessor preview button, every model will show up as a complete black preview, and if clicked on generate it would be as if controlnet have no effect on the output, I have even tried the exact same procedure on the same machine(on the same network) connect to local ip in one page, and connect to the external domain they both points to the exact same instance, the one accessed from the local ip will return perfect result while the one accessed with external domain will return black image output.

My setup of external domain now is that I have an internal instance connected to a cloud flare tunnel so my home ip will not be directly exposed. how this is done is explained in this video: https://youtu.be/eojWaJQvqiw

while this black preview image issue is strictly applied to this scenario, I have also tried the traditional way of resolving an external domain but still I put it behind a reverse proxy with ssl just for a bit of added security but it'll also return an error but that's a different issue, but just to point out that controlnet doesn't seemed to work as long as it is connected externally with an ssl cert in my experience.

Steps to reproduce the problem

  1. Cloudflare, resolve your own domain. make sure ssl is enabled on all sites
  2. enable tunnels install cloudflared on any internal machine inside your network.
  3. connect your resolved domain into your server with the webgui installed with the --listen flag on
  4. visit the stablediffusion webgui go to controlnet tab and drag in any image,
  5. pick a checkpoint from preprocessor drop down, lets say canny.
  6. press on the 💥
  7. it will return blank on the preview.
  8. if you do the same steps but locally it'll not return a blank preview.

What should have happened?

It should not return a blank preview when visiting the webgui externally via top level domain with ssl enabled

Commit where the problem happens

webui: controlnet: most likely culprit to be here: sd-webui-controlnet/scripts/controlnet.py run_annotator

I have put some print staments under a few variables and noticed the issue with the output please see the console log below.

What browsers do you use to access the UI ?

No response

Command Line Arguments

added a few print statements, please see below.

Console logs

# local print out (correct result)
image: {'image': array([[[255, 255, 255],
        [255, 255, 255],
        [255, 255, 255],
        ...,
        [255, 255, 255],
        [255, 255, 255],
        [255, 255, 255]],
        ...,
        [ 49,  55,  60],
        [ 64,  69,  74],
        [115, 118, 122]]], dtype=uint8), 'mask': array([[[  0,   0,   0, 255],
        [  0,   0,   0, 255],
        [  0,   0,   0, 255],
        ...,
        [  0,   0,   0, 255],
        [  0,   0,   0, 255],
        [  0,   0,   0, 255]]], dtype=uint8)}

Preview Resolution = 512

img: [[[255 255 255]
  [255 255 255]
  [255 255 255]
  ...
  [ 49  55  60]
  [ 64  69  74]
  [115 118 122]]]
result: [[  0   0   0 ...   0   0   0]
 [  0   0   0 ...   0   0   0]
 [  0   0   0 ...   0   0   0]
 ...
 [  0   0   0 ...   0   0 255]
 [  0   0   0 ...   0 255   0]
 [  0   0   0 ...   0 255   0]]

# from external(incorrect result with blank image):
image: {'image': array([[[255, 255, 255],
        [255, 255, 255],
        [255, 255, 255],
        ...,
        [255, 255, 255],
        [255, 255, 255],
        [255, 255, 255]],
        ...,
        [ 49,  55,  60],
        [ 64,  69,  74],
        [115, 118, 122]]], dtype=uint8), 'mask': array([[[  0,   0,   0, 255],
        [  0,   0,   0, 255],
        [  0,   0,   0, 255],
        ...,
        [  0,   0,   0, 255],
        [  0,   0,   0, 255],
        [  0,   0,   0, 255]]], dtype=uint8)}

Preview Resolution = 512

img: [[[0 0 0]
  [0 0 0]
  [0 0 0]
  ...
  [0 0 0]
  [0 0 0]
  [0 0 0]]]

result: [[0 0 0 ... 0 0 0]
 [0 0 0 ... 0 0 0]
 [0 0 0 ... 0 0 0]
 ...
 [0 0 0 ... 0 0 0]
 [0 0 0 ... 0 0 0]
 [0 0 0 ... 0 0 0]]

Additional information

please check the comparison of the console log, and I separated it with 2 sections: # local print out (correct result) and # from external(incorrect result with blank image)

from what I see, in both cases the image variable seems to match, but the img variable returns blank.

note that they're both running on the same session just accessed from different urls.

penthoy avatar May 10 '23 21:05 penthoy