thundaga / SD-webui-txt2img-script

Stable diffusion webui script to batch process images within the txt2img section
41 stars 5 forks source link

No Hires exeption #19

Closed OPCOXE closed 9 months ago

OPCOXE commented 9 months ago

Hi,

I'll try to check and provide a solution. Currently, using the "Hires Scale or Width and Height" necessites the hires values and tries to generate the images if no value is found making the generation crash with the following error : TypeError: unsupported operand type(s) for *: 'int' and 'NoneType'

I'm looking for the solution but I got another issue and try to reproduce it rn

OPCOXE commented 9 months ago

After some reproduction of the other issue I spoke before, I can't manage to find the solution but either way the issues seems to be due to AUTOMATIC1111's Stable Diffusion WebUI.

I'll start the investigation for the solution of this issue now

OPCOXE commented 9 months ago

A simple solution could be to use the default x2 like this (line 208) :

if p.hr_scale == None and p.hr_resize_x == 0 and p.hr_resize_y == 0:
    p.hr_scale = 2

I didn't had time to do more investigation today, I'll continue tomorrow hopping I'll have enough time

OPCOXE commented 9 months ago

Ok I think the best solution is the following :

def hires_resize(p, parsed_text: dict):
    # Fix the issue when the values doesn't exist
    # Uses the default value (skip the reset part)
    if not ('Hires upscale' in parsed_text or parsed_text['Hires resize-1'] != 0 or parsed_text['Hires resize-2'] != 0):
        return p

    # Reset hr_settings to avoid wrong settings   
    p.hr_scale = None
    p.hr_resize_x = int(0)
    p.hr_resize_y = int(0)
    if 'Hires upscale' in parsed_text:
        p.hr_scale = float(parsed_text['Hires upscale'])
    if 'Hires resize-1' in parsed_text:
        p.hr_resize_x = int(parsed_text['Hires resize-1'])
    if 'Hires resize-2' in parsed_text:
        p.hr_resize_y = int(parsed_text['Hires resize-2'])
    return p

I'll provide a pull request later this week (or next week). Also I found it strange that it's not an issues if the denoising strenght and upscaler is not provided, I'll also check that

Note : I'll also check if the denoising strenght and upscaler are modified maybe it's the reason EDIT : denoising strenght and upscaler works fine I'll provide a Pull request ASAP

OPCOXE commented 9 months ago

I verified just in case that I didn't make a mistake in the pull request but no. The fix work so the issue is close.