sdwebuiapi icon indicating copy to clipboard operation
sdwebuiapi copied to clipboard

how to disable Hires. fix

Open harrywang opened this issue 1 year ago • 1 comments

I used the following code to generate an image using v1-5-pruned-emaonly - enable_hr=False does not seem to work:

result = api.txt2img(prompt="dog",
                    negative_prompt="ugly",
                    seed=-1,
                    cfg_scale=7,
                    sampler_name='Euler a',
                    steps=5,
                    width=512,
                    height=512,
                    enable_hr=False,
                    )

then, result.info['infotexts'][0] shows Denoising strength: 0.7, which is a Hires. fix parameter.

'dog\nNegative prompt: ugly\nSteps: 5, Sampler: Euler a, CFG scale: 7.0, Seed: 4091609273, Size: 512x512, Model hash: 6ce0161689, Model: v1-5-pruned-emaonly, Denoising strength: 0.7'

Then, I save the PNG info as follow:

from PIL import Image, PngImagePlugin

pnginfo = PngImagePlugin.PngInfo()
pnginfo.add_text("parameters", result.info['infotexts'][0])
result.image.save('output.png', pnginfo=pnginfo)

and load the saved image to PNG info, the Hires. fix is enabled as follows: Screenshot 2023-03-24 at 5 24 54 PM

Screenshot 2023-03-24 at 5 20 22 PM

How can I generate the image without the Hires. fix?

Thanks!

harrywang avatar Mar 24 '23 21:03 harrywang

Denoising strength: 0.7 default is included in the parameters info text even when enable_hr=False, which enables Hires. fix

I manually remove Denoising strength: 0.7, it solves the problem in a very hacky way. This should be fixed at API level.

para_str = result.info['infotexts'][0].replace('Denoising strength: 0.7', '')

harrywang avatar Mar 25 '23 00:03 harrywang