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

[Bug]: ValueError: 'OUT' is not a valid ResizeMode #598

Closed
1 task done
freecoderai01 opened this issue Mar 15, 2023 · 11 comments
Closed
1 task done

[Bug]: ValueError: 'OUT' is not a valid ResizeMode #598

freecoderai01 opened this issue Mar 15, 2023 · 11 comments

Comments

@freecoderai01
Copy link

Is there an existing issue for this?

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

What happened?

In img2img controlnet extension does not seem to work correctly: controlnet doesn't effect the image.

Steps to reproduce the problem

  1. Go to img2img tab
  2. Press controlnet subtab
  3. Add pictures in controlnet and in img2img
  4. Click 'enable' checkbox and select openpose for preprocessor and model
  5. Press 'generate'

What should have happened?

The image changes depending on results from preprocessor and model.

Commit where the problem happens

webui: AUTOMATIC1111/stable-diffusion-webui@a9fed7c
controlnet: 274dd5d

What browsers do you use to access the UI ?

Google Chrome

Command Line Arguments

--disable-safe-unpickle --enable-insecure-extension-access --share --gradio-img2img-tool editor --theme dark --ckpt-dir /content/stable-diffusion-webui/models/Stable-diffusion --gradio-queue --disable-console-progressbars --no-hashing --opt-channelslast --xformers

Console logs

LoCon Extension hijack addnet extension successfully
LoCon Extension hijack built-in lora successfully
[AddNet] Updating model hashes...
100% 145/145 [00:53<00:00,  2.71it/s]
[AddNet] Updating model hashes...
100% 145/145 [00:00<00:00, 55754.87it/s]
загрузка модели...
Loading weights [None] from /content/stable-diffusion-webui/models/Stable-diffusion/yohan-diffusion.safetensors
Creating model from config: /content/stable-diffusion-webui/configs/v1-inference.yaml
LatentDiffusion: Running in eps-prediction mode
DiffusionWrapper has 859.52 M params.
Downloading (…)olve/main/vocab.json: 100% 961k/961k [00:00<00:00, 4.14MB/s]
Downloading (…)olve/main/merges.txt: 100% 525k/525k [00:00<00:00, 19.0MB/s]
Downloading (…)cial_tokens_map.json: 100% 389/389 [00:00<00:00, 118kB/s]
Downloading (…)okenizer_config.json: 100% 905/905 [00:00<00:00, 262kB/s]
Downloading (…)lve/main/config.json: 100% 4.52k/4.52k [00:00<00:00, 1.45MB/s]
Applying xformers cross attention optimization.
Textual inversion embeddings loaded(22): corneo_cowgirl, corneo_pov_oral, bad-image-v2-39000, bad-image-v2-11000, bad_prompt, vile_prompt3, bad-hands-5, bad-image-v2-27000, corneo_spitroast, bad-hands-3, ulzzang-6500-v1.1, corneo_paizuri, bad-image, bad_prompt_version2, bad_quality, bad-artist, bad-image-9600, bad-artist-anime, corneo_bound_missionary, corneo_side_deepthroat, easynegative, negprompt5
Textual inversion embeddings skipped(1): NegLowRes-2400
Model loaded in 21.7s (load weights from disk: 16.1s, create model: 3.7s, load textual inversion embeddings: 1.7s).
no display name and no $DISPLAY environment variable
Startup time: 153.0s (import gradio: 2.3s, import ldm: 3.9s, other imports: 4.7s, list extensions: 1.2s, setup codeformer: 0.2s, load scripts: 105.3s, load SD checkpoint: 21.7s, create ui: 10.9s, gradio launch: 2.6s).
Error running process: /content/stable-diffusion-webui/extensions/custom-hires-fix/scripts/custom_hires_fix.py
Traceback (most recent call last):
  File "/content/stable-diffusion-webui/modules/scripts.py", line 409, in process
    script.process(p, *script_args)
  File "/content/stable-diffusion-webui/extensions/custom-hires-fix/scripts/custom_hires_fix.py", line 121, in process
    custom = custom_processing.SDProcessing(p, first_upscaler, second_upscaler)
  File "/content/stable-diffusion-webui/extensions/custom-hires-fix/custom_processing.py", line 57, in __init__
    enable_hr=p.enable_hr, hr_upscaler=p.hr_upscaler, hr_second_pass_steps=p.hr_second_pass_steps,
AttributeError: 'StableDiffusionProcessingImg2Img' object has no attribute 'enable_hr'

Error running process: /content/stable-diffusion-webui/extensions/sd-webui-controlnet/scripts/controlnet.py
Traceback (most recent call last):
  File "/content/stable-diffusion-webui/modules/scripts.py", line 409, in process
    script.process(p, *script_args)
  File "/content/stable-diffusion-webui/extensions/sd-webui-controlnet/scripts/controlnet.py", line 737, in process
    resize_mode = resize_mode_from_value(resize_mode)
  File "/content/stable-diffusion-webui/extensions/sd-webui-controlnet/scripts/controlnet.py", line 184, in resize_mode_from_value
    return ResizeMode(value)
  File "/usr/lib/python3.9/enum.py", line 384, in __call__
    return cls.__new__(cls, value)
  File "/usr/lib/python3.9/enum.py", line 702, in __new__
    raise ve_exc
ValueError: 'OUT' is not a valid ResizeMode

Error running process_batch: /content/stable-diffusion-webui/extensions/sd-webui-additional-networks/scripts/additional_networks.py
Traceback (most recent call last):
  File "/content/stable-diffusion-webui/modules/scripts.py", line 427, in process_batch
    script.process_batch(p, *script_args, **kwargs)
  File "/content/stable-diffusion-webui/extensions/sd-webui-additional-networks/scripts/additional_networks.py", line 196, in process_batch
    if model is None or model == "None" or len(model) == 0:
TypeError: object of type 'int' has no len()

100% 35/35 [00:05<00:00,  5.88it/s]
{"prompt": "oil painting ", "all_prompts": ["oil painting "], "negative_prompt": "", "all_negative_prompts": [""], "seed": 1429471248, "all_seeds": [1429471248], "subseed": 3148959338, "all_subseeds": [3148959338], "subseed_strength": 0, "width": 512, "height": 512, "sampler_name": "Euler a", "cfg_scale": 7, "steps": 35, "batch_size": 1, "restore_faces": false, "face_restoration_model": null, "sd_model_hash": null, "seed_resize_from_w": 0, "seed_resize_from_h": 0, "denoising_strength": 0.93, "extra_generation_params": {"Mask blur": 4, "ControlNet Enabled": true, "ControlNet Module": false, "ControlNet Model": false, "ControlNet Weight": 1, "ControlNet Guidance Start": "Pooling Max", "ControlNet Guidance End": false}, "index_of_first_image": 0, "infotexts": ["oil painting \nSteps: 35, Sampler: Euler a, CFG scale: 7, Seed: 1429471248, Size: 512x512, Model: yohan-diffusion, Denoising strength: 0.93, Mask blur: 4, ControlNet Enabled: True, ControlNet Module: False, ControlNet Model: False, ControlNet Weight: 1, ControlNet Guidance Start: Pooling Max, ControlNet Guidance End: False"], "styles": [], "job_timestamp": "20230315014455", "clip_skip": 1, "is_using_inpainting_conditioning": false}

Additional information

running in google colab

@ljleb
Copy link
Collaborator

ljleb commented Mar 15, 2023

Controlnet does not take effect because the enum conversion raises an error. Is the value also 'OUT' if you select a different resize mode?

@ljleb
Copy link
Collaborator

ljleb commented Mar 15, 2023

Just for context, the value 'OUT' probably does not come from the controlnet extension. If you recursive-search for the value in the extension directory, you will not find any occurrence of the string.

Maybe a webui or web browser extension is messing with the code? The default value for resize_mode is "Scale to Fit (Inner Fit)", and should only ever take these value:

RESIZE = "Just Resize"
INNER_FIT = "Scale to Fit (Inner Fit)"
OUTER_FIT = "Envelope (Outer Fit)"

@freecoderai01
Copy link
Author

Just for context, the value 'OUT' probably does not come from the controlnet extension. If you recursive-search for the value in the extension directory, you will not find any occurrence of the string.

Maybe a webui or web browser extension is messing with the code? The default value for resize_mode is "Scale to Fit (Inner Fit)", and should only ever take these value:

RESIZE = "Just Resize"
INNER_FIT = "Scale to Fit (Inner Fit)"
OUTER_FIT = "Envelope (Outer Fit)"

Indeed, after further inspection, it was found that the value was not coming from the ControlNet extension. In another run, a 'Lerp' value was given. Recursive search showed that it was caused by the extension https://github.com/hnmr293/sd-webui-llul.
2023-03-15-151730_936x155_scrot
2023-03-15-151713_1241x196_scrot

@imacopypaster
Copy link

imacopypaster commented Mar 16, 2023

I faced a similar problem (controlnet doesnt work in img2img mode when used with other extension) and don't think this is exceptional case due to incompatibility with one extention!
I've install this extention: https://github.com/wcde/custom-hires-fix-for-automatic1111
And then I get the following errors in ControlNet:

Error running process: /content/stable-diffusion-webui/extensions/custom-hires-fix-for-automatic1111/scripts/custom_hires_fix.py
Traceback (most recent call last):
  File "/content/stable-diffusion-webui/modules/scripts.py", line 409, in process
    script.process(p, *script_args)
  File "/content/stable-diffusion-webui/extensions/custom-hires-fix-for-automatic1111/scripts/custom_hires_fix.py", line 132, in process
    custom = custom_processing.SDProcessing(p, first_upscaler, second_upscaler)
  File "/content/stable-diffusion-webui/extensions/custom-hires-fix-for-automatic1111/custom_processing.py", line 61, in init
    enable_hr=p.enable_hr, hr_upscaler=p.hr_upscaler, hr_second_pass_steps=p.hr_second_pass_steps,
AttributeError: 'StableDiffusionProcessingImg2Img' object has no attribute 'enable_hr'

There may be problems with other extentions/scripts in the future if something is not fixed in the ControlNet extention.

Can you reinforce the code to prevent other extensions from unintentionally modifying controlnet's values/other kind of interference?

@ljleb
Copy link
Collaborator

ljleb commented Mar 16, 2023

Does the error still occur after uninstalling controlnet?

IIUC, from what I can see, this bug has nothing to do with controlnet extension. The error occurs in the hires-fix extension, and only after the hires-fix extension was installed. Can you verify that controlnet extension is the culprit?

@imacopypaster
Copy link

Can you verify that controlnet extension is the culprit?

I've verified more than once.

It appears that multiple extensions may be able to affect the ControlNet values with by accident. It possible more extensions may appear that will try to use same IDs/labels, any possibility to make 'the collision' less common (maybe by using more unique ID/names or any other way to avoid unintentional values changes)? For purpose of testing regarding the issue, here is google colab with mentioned extensions that cause problem:
https://colab.research.google.com/drive/1xdtXyIrofmHlRZSZdM0t3Vh_tkUNaPTm
It's "clean" colab, in which the ControlNet extension is installed by default, and there are two checkboxes to install custom-hires and llul. Let's, to dispel all doubts, you'll look and see for yourself.
When you install either of these two add-ons (!), ControlNet stops working at all on the img2img tab.
Just take a look.

@ljleb
Copy link
Collaborator

ljleb commented Mar 16, 2023

Thanks for the detailed report. I'll add elem_ids to our ui elements and test with your colab.

@ljleb ljleb reopened this Mar 16, 2023
@ljleb
Copy link
Collaborator

ljleb commented Mar 17, 2023

So one bug I encountered while testing this was this:

Error running process: D:\src\sd-compat-test\extensions\sd-webui-llul\scripts\llul.py
Traceback (most recent call last):
  File "D:\src\sd-compat-test\modules\scripts.py", line 409, in process
    script.process(p, *script_args)
  File "D:\src\sd-compat-test\extensions\sd-webui-llul\scripts\llul.py", line 143, in process
    xf = float(x)
ValueError: could not convert string to float: 'None'

I A/B tested all combinations of the 3 extensions 2 times, (llul, hires and cn) and I can say with certainty that this one is not caused by controlnet. This bug is caused by the custom-hires-fix-for-automatic1111 extension, and the issue should be resolved there.

I'm still in the process of reproducing the error you are encountering above, more info to come soon.

@ljleb
Copy link
Collaborator

ljleb commented Mar 17, 2023

For some reason the collab started returning this when I tried to start it up:

Traceback (most recent call last):
  File "/content/stable-diffusion-webui/webui.py", line 7, in <module>
    from fastapi import FastAPI
ModuleNotFoundError: No module named 'fastapi'

Maybe you should try to pick a different collab? If you have control over the code, let me know when it is fixed so I can test. Not sure but at a glance it seems to be doing a lot of unnecessary work. Locally the only error I encountered (when installing only llul, custom-hires and cn) was the error above caused by custom hires.

@imacopypaster
Copy link

@ljleb, you probably haven't encountered the specifics of colab, especially lately?
Below I will provide screenshots that confirm both the successful launch, and problems with extentions.
Also in colab added a forced installation of some dependencies, and so you can try again.

For future: since google is constantly changing things and sometimes colabs can behave strangely, you just have to try running it again and again, or restart runtime.

custom_hires_fix + controlnet:
2023-03-17-163615_1593x586_scrot

and here, despite the fact that the error does not mention ControlNet, it not working in webui (like with custom_hires_fix):
2023-03-17-164200_1640x340_scrot

@ljleb
Copy link
Collaborator

ljleb commented Mar 18, 2023

I tested the second error you mention, it is not caused by controlnet. You can test by only enabling llul and custom-hires extensions. To do this, you can comment out the code that pulls the controlnet repo at the beginning of ControlNet_install.

I will try to run the collab again for the first error to find what is going on in this setup. I do not encounter the first error when trying to reproduce the error locally.

Edit: I can confirm that the collab is starting up now. Not sure exactly why it repeatedly broke with jsonapi missing earlier yesterday.

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

4 participants