hako-mikan / sd-webui-regional-prompter

set prompt to divided region
GNU Affero General Public License v3.0
1.58k stars 133 forks source link

Error keeps popping up at random intervals #164

Closed Edwin-Giovanni closed 1 year ago

Edwin-Giovanni commented 1 year ago

the error it's the following: Error running process:

E:\STD\stable-diffusion-webui-directml\extensions\sd-webui-regional-prompter\scripts\rp.py
    Traceback (most recent call last):
      File "E:\STD\stable-diffusion-webui-directml\modules\scripts.py", line 474, in process
        script.process(p, *script_args)
      File "E:\STD\stable-diffusion-webui-directml\extensions\sd-webui-regional-prompter\scripts\rp.py", line 439, in process
        self, p = matrixdealer(self, p, aratios, bratios, self.mode, usebase, comprompt,comnegprompt)
      File "E:\STD\stable-diffusion-webui-directml\extensions\sd-webui-regional-prompter\scripts\regions.py", line 351, in matrixdealer
        mainprompt = p.prompt.split(KEYBRK,1)[1]
    IndexError: list index out of range

This happens when i try to: generate an image with 2 LORAS, or UPSCALE an image, the error gets to the point to make denoising not work so newly generated images are just noise, no matter the setting, the only way to fix the issue it's by deleting VENV folder and reinstalling it, i want to know how can i minimize this issue or solve it if possible, thank you for you time and have a great day!

PC SPECS: CPU: R5 5600 GPU: RX 6600 RAM: 32GB 3200mhz

Edwin-Giovanni commented 1 year ago

this is the error that happens when the denoise stops working, making images look horrible, it could happen on the last step, or on the first one i do not know what causes this:

** Error executing callback cfg_denoised_callback for E:\STD\stable-diffusion-webui-directml\extensions\sd-webui-regional-prompter\scripts\rp.py
    Traceback (most recent call last):
      File "E:\STD\stable-diffusion-webui-directml\modules\script_callbacks.py", line 203, in cfg_denoised_callback
        c.callback(params)
      File "E:\STD\stable-diffusion-webui-directml\extensions\sd-webui-regional-prompter\scripts\rp.py", line 551, in denoised_callback
        denoised_callback_s(self, params)
      File "E:\STD\stable-diffusion-webui-directml\extensions\sd-webui-regional-prompter\scripts\latent.py", line 200, in denoised_callback_s
        x[a + b*areas, :, :, :] =  x[a + b*areas, :, :, :] * self.filters[a + b*areas] + x[x.size()[0]+(b-batch), :, :, :] * self.neg_filters[a + b*areas]
    IndexError: list index out of range

The image i tried to make was a 800x640 image, sometimes i have no issues making, but at seemingly random intervals this keeps happening, any help would be appreciated.

Guillaume-Fgt commented 1 year ago

File "E:\STD\stable-diffusion-webui-directml\extensions\sd-webui-regional-prompter\scripts\regions.py", line 351, in matrixdealer mainprompt = p.prompt.split(KEYBRK,1)[1] IndexError: list index out of range

Hi,

    elif usebase: # Get base by first break as usual.
        baseprompt = p.prompt.split(KEYBRK,1)[0]
        mainprompt = p.prompt.split(KEYBRK,1)[1]

according to the code in region.py where the error is triggered, you probably have "use base prompt" checked but do not have "BREAK" in your prompt. So the split() function returns a list of one element. So, when the code tries to access the second element, it throws an Index out of range error.

Symbiomatrix commented 1 year ago

@Edwin-Giovanni Please provide full settings (including prompt and extension's). As @Guillaume-Fgt states, an error in the base splitting stage would indicate you are using the extension with a base flag and without any region separators (BREAK / ADDX) to back it up. The denoiser becomes active semi permanently once latent mode is used (due to webui's callback limitations); however, the callbacks are entirely wrapped in if self.lactive or self.lpactive: and self.modep, so it should not change regular calls with the extension deactivated, and certainly all should return to normal with a webui rerun, no need to wipe the venv. It is rather unlikely that the areas error should pop up at the last stage. The filters are only rebuilt when the input shape changes, so a mismatch should occur at the beginning. How often is this random interval?

You can change this line to show more details on the current state when the error occurs:

x[a + b*areas, :, :, :] =  x[a + b*areas, :, :, :] * self.filters[a + b*areas] + x[x.size()[0]+(b-batch), :, :, :] * self.neg_filters[a + b*areas]

to (mind the indentation)

try:
    x[a + b*areas, :, :, :] =  x[a + b*areas, :, :, :] * self.filters[a + b*areas] + x[x.size()[0]+(b-batch), :, :, :] * self.neg_filters[a + b*areas]
except IndexError:
    print("ERROR ", a, b, areas, batch, x.shape, len(self.filters), len(self.neg_filters))
    raise
Edwin-Giovanni commented 1 year ago

Hello, the settings im trying to use are: 768x512, 30 Sampling steps, CFG Scale: 7 Prompts are: Positive: ((ultra-detailed)), ((illustration)), 2girls, street, outdoors, BREAK AND ((ultra-detailed)), ((illustration)), 2girls, jinxlol, navel, gloves, fingerless gloves, midriff, bare shoulders, crop top, belt, head tilt, AND ((ultra-detailed)), ((illustration)), 2girls, tatsumaki, black one piece dress, pelvic curtain, green eyes, head tilt, Negative: (low quality, worst quality:1.4) i did try with and without "use base prompt" and this appears to only happen when i use "latent" only instead of "attention" the other extensions i have are: Lycoris, TagComplete, Multidiffusion Upscaler, OpenPose Editor, sd-dynamic-prompts, model downloader, control net, regional prompter, composable lora, ultimate upscalling, Unprompted, LDSR, Lora, ScuNET, SwinIR, canvas-zoom-and-pan, extra-options-section and prompt-bracket-checker. As for my need to wipe the venv when the issue happens, it keeps happening at any moment i try to use regional prompter, therefore making me unable to use the extension at all since all it produces are images with random colors or forms.

Edwin-Giovanni commented 1 year ago

Okay so after changing AND for ADDX it seems to generate properly and im not seeing any errors at the moment, i will keep generating and see if that was a complete fix for me.

Edwin-Giovanni commented 1 year ago

well after generating for one hour and so minutes, it seems that the issue has been fixed for now, thank you guys for helping and have a great day!.

Symbiomatrix commented 1 year ago

AND is automatically changed to BREAK and then back to AND in latent mode (unless the no change checkbox is ticked), and therefore should count as a region. I've organised it a bit better in the promptcessor side version, not sure how exactly it acts currently, but anyway standard separators are the way to go. Edit: Also note that hako mentioned ultimate sd upscaler is incompatible with common clauses.