Kohya_ss hi-res fix

#2
by adamelliotfields - opened

Can be incorporated as a community pipeline:

DiffusionPipeline.from_pretrained(
    MODEL,
    custom_pipeline="kohya_hires_fix",
    high_res_fix=[
        {"timestep": 900, "scale_factor": 0.5, "block_num": 1},
        {"timestep": 650, "scale_factor": 0.5, "block_num": 1},
    ],
)

It's easier to incorporate than other hi-res fixes because it's just a modified forward pass, rather than generating an image and then sending that through an img2img pipeline for upscaling.

In playing around with it:

  • block_num and scale_factor can be fixed
  • multiple timesteps are not necessary
  • 1.5x upscale (768) is more consistent than 2x (1024)

For the UI, we just need a checkbox to enable it and inputs for scale (1.5x, 2x) and timestep. Note that a timestep of 1000 is the same as disabled. Can call the section "Upscale".

It could have been inspired by one of Kohya's gists.

See freddyaboulton's range slider for the timesteps. Two small number inputs for the scale factors.

Closing. It's slow and the results are hit or miss. Will implement a different hi-res fix, probably using img2img.

adamelliotfields changed discussion status to closed

Sign up or log in to comment