Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ValueError when using inpaint with inpaint at full resolution option #46

Closed
Leon-Schoenbrunn opened this issue Sep 2, 2022 · 10 comments

Comments

@Leon-Schoenbrunn
Copy link

Currently the inpaint for img2img conversion is not working on my end. It seems like the mask is not working as intended / is not applied at all. My current PIL version is Name: Pillow, Version: 9.2.0 and the current Numpy version is Name: numpy Version: 1.23.2.
The 4-tuple crop_reagion leading to this error is (448, 448, 64, 64).

Error:

Traceback (most recent call last):
  File "----\webui.py", line 690, in f
    res = list(func(*args, **kwargs))
  File "----\webui.py", line 678, in f
    res = func(*args, **kwargs)
  File "----\webui.py", line 1689, in img2img
    processed = process_images(p)
  File "----\webui.py", line 1146, in process_images
    p.init()
  File "----\webui.py", line 1494, in init
    mask = mask.crop(crop_region)
  File "----\anaconda3\lib\site-packages\PIL\Image.py", line 1171, in crop
    raise ValueError("Coordinate 'right' is less than 'left'")
ValueError: Coordinate 'right' is less than 'left'

Image to demonstrate the error:
image

Further, disabling inpaint at full resolution leads to interference and an output, but the output image is exactly the same as the input image, as if the mask was never applied.

@Leon-Schoenbrunn
Copy link
Author

After further looking into it, it actually seems like pulling the latest commits from the repo, destroyed the whole img2img page.
Other tasks like Redraw whole image fail due to

  File "----\gradio\routes.py", line 259, in run_predict
    output = await app.blocks.process_api(
  File "----\gradio\blocks.py", line 685, in process_api
    inputs = self.preprocess_data(fn_index, inputs, state)
  File "----\gradio\blocks.py", line 591, in preprocess_data
    processed_input.append(block.preprocess(raw_input[i]))
  File "----\gradio\components.py", line 1321, in preprocess
    im = processing_utils.decode_base64_to_image(x)
  File "----\gradio\processing_utils.py", line 28, in decode_base64_to_image
    content = encoding.split(";")[1]
AttributeError: 'dict' object has no attribute 'split'
Error completing request

Creating a new venv and installing all components via the install instructions yields the same result, so I really hope this error isn't only happening on my end. If further information is needed, I'll gladly provide more.

@AUTOMATIC1111
Copy link
Owner

AUTOMATIC1111 commented Sep 2, 2022

i can't seem to reproduce this

did you possibly update script and re-lauch the gradio process with updating the web page?

@AUTOMATIC1111
Copy link
Owner

created a new venv with python 3.10.6, installed from scratch, everything works

@Leon-Schoenbrunn
Copy link
Author

I'm sorry for the confusion. I updated python to 3.10.6 and again followed the instructions in a new venv. Redraw whole image etc. are working again, that might've actually been me somehow messing with the script. The aforementioned problem with inpaint and the ValueError persists though.

@Leon-Schoenbrunn
Copy link
Author

The inpainting works in Firefox, but does not work in Chrome Version 104.0.5112.102 (64Bit) and 105.0.5195.54 (64Bit).

@Jonseed
Copy link

Jonseed commented Oct 3, 2022

Do you have any extensions loaded in Chrome? Those seem to break inpainting (particularly DuckDuckGo privacy essentials).

@Leon-Schoenbrunn
Copy link
Author

Yes, it's gotta be DuckDuckGo.

@aolko
Copy link

aolko commented Jan 17, 2023

still broken (inpaint sketch), even in firefox

Error completing request
Arguments: ('task(4in16y6vj7lbij3)', 3, 'thick fake mustache', '__univ_negative__', 'None', 'None', None, None, None, <PIL.Image.Image image mode=RGBA size=1280x720 at 0x18BECB6AF80>, <PIL.Image.Image image mode=RGBA size=1280x720 at 0x18BEC6237F0>, None, None, 60, 0, 4, 100, 1, False, False, 1, 1, 11.5, 0.75, -1.0, -1.0, 0, 0, 0, True, 448, 896, 2, 1, 32, 0, '', '', 0, '<div class="dynamic-prompting">\n    <h3><strong>Combinations</strong></h3>\n\n    Choose a number of terms from a list, in this case we choose two artists: \n    <code class="codeblock">{2$$artist1|artist2|artist3}</code><br/>\n\n    If $$ is not provided, then 1$$ is assumed.<br/><br/>\n\n    If the chosen number of terms is greater than the available terms, then some terms will be duplicated, otherwise chosen terms will be unique. This is useful in the case of wildcards, e.g.\n    <code class="codeblock">{2$$__artist__}</code> is equivalent to <code class="codeblock">{2$$__artist__|__artist__}</code><br/><br/>\n\n    A range can be provided:\n    <code class="codeblock">{1-3$$artist1|artist2|artist3}</code><br/>\n    In this case, a random number of artists between 1 and 3 is chosen.<br/><br/>\n\n    Options can be given weights:\n    <code class="codeblock">{2::artist1|artist2}</code><br/>\n    In this case, artist1 will be chosen twice as often as artist2.<br/><br/>\n\n    Wildcards can be used and the joiner can also be specified:\n    <code class="codeblock">{{1-$$and$$__adjective__}}</code><br/>\n\n    Here, a random number between 1 and 3 words from adjective.txt will be chosen and joined together with the word \'and\' instead of the default comma.\n\n    <br/><br/>\n\n    <h3><strong>Wildcards</strong></h3>\n    Find and manage wildcards in the Wildcards Manager tab.\n\n    <br/><br/>\n\n    <small>You can add more wildcards by creating a text file with one term per line and name is mywildcards.txt. Place it in D:\\tmp\\stable-diffusion-new2\\extensions\\sd-dynamic-prompts\\wildcards. <code class="codeblock">__&#60;folder&#62;/mywildcards__</code> will then become available.</small>\n</div>\n\n', True, False, 1, False, False, False, 1.1, 1.5, 100, 0.7, False, False, False, False, False, False, None, '', 'Get Tags', '<ul>\n<li><code>CFG Scale</code> should be 2 or lower.</li>\n</ul>\n', True, True, '', '', True, 50, True, 1, 0, False, 4, 1, '<p style="margin-bottom:0.75em">Recommended settings: Sampling Steps: 80-100, Sampler: Euler a, Denoising strength: 0.8</p>', 128, 8, ['left', 'right', 'up', 'down'], 1, 0.05, 128, 4, 0, ['left', 'right', 'up', 'down'], False, False, False, False, '', '<p style="margin-bottom:0.75em">Will upscale the image by the selected scale factor; use width and height sliders to set tile size</p>', 64, 0, 2, 1, '', 0, '', True, False, False, '<p style="margin-bottom:0.75em">Recommended settings: Use from inpaint tab, inpaint at full res ON, denoise <0.5</p>', 'None', 30, 4, 0, 0, False, 'None', '<br>', 'None', 30, 4, 0, 0, 4, 0.4, True, 32, False, 4.0, '', 10.0, False, False, True, 30.0, True, False, False, 0, 0.0, 'fixed', 1, 'linear', '30', 'grad_min', 0.01, 1, 'clip', 1.0, 1.0, 'mp4', 10.0, 0, '', True) {}
Traceback (most recent call last):
  File "D:\tmp\stable-diffusion-new2\modules\call_queue.py", line 56, in f
    res = list(func(*args, **kwargs))
  File "D:\tmp\stable-diffusion-new2\modules\call_queue.py", line 37, in f
    res = func(*args, **kwargs)
  File "D:\tmp\stable-diffusion-new2\modules\img2img.py", line 148, in img2img
    processed = process_images(p)
  File "D:\tmp\stable-diffusion-new2\modules\processing.py", line 480, in process_images
    res = process_images_inner(p)
  File "D:\tmp\stable-diffusion-new2\modules\processing.py", line 573, in process_images_inner
    p.init(p.all_prompts, p.all_seeds, p.all_subseeds)
  File "D:\tmp\stable-diffusion-new2\modules\processing.py", line 920, in init
    mask = mask.crop(crop_region)
  File "D:\tmp\stable-diffusion-new2\venv\lib\site-packages\PIL\Image.py", line 1171, in crop
    raise ValueError("Coordinate 'right' is less than 'left'")
ValueError: Coordinate 'right' is less than 'left'

@yogo1212
Copy link

I'm sorry to also bump this... but the issue with values being swapped in the tuple returned by doesn't have anything to do with duckduckgo, or not?

pad being 0 and crop_* being w and h?

    return (
        int(max(crop_left-pad, 0)),
        int(max(crop_top-pad, 0)),
        int(min(w - crop_right + pad, w)),
        int(min(h - crop_bottom + pad, h))
    )

@aglines
Copy link

aglines commented Feb 12, 2023

Found a solution that worked for me at least, using latest commit & model v1.5. in firefox, Duckduckgo privacy essentials can be whitelisted for 127.0.0.1, (gear symbol in extension is available on 'normal' sites, add unprotected site.) I also whitelisted it in several other privacy extensions. Error is now gone for inpaint.

cabelo pushed a commit to cabelo/stable-diffusion-webui that referenced this issue Nov 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants