Trade offs when upscale an image
Hey guys, I am looking for a method to up-scale an image and have implemented some codes.I want to share about the results and findingsHopefully we can improve the design a little bit and come up some new ideas.Test base image (512x512):test-k512×512 230 KBTest steps:Upscale image to (2048x2048) using R-ESRGANx4Split image into tiles with size of 512x512, each tile overlaps with others by N pixels, where N is a parameters.Run diffuser pipeline img2img with same prompt that generates the base imageAssemble the re-paint tiles and do a weighted addition between tiles.if region of tile is overlapping:
   do a weighted addition and put the sum on canvas
else
   put the region on canvasOutput the final image.Time performance:Euler-A is always faster with low number of iterations and reaches the same quality. I think it can go as low as 25 iterations. But I use 35 for best result.Memory performance:Both schedulers consume almost same GPU memory (about 6GB total in my case). Tiled diffusion is almost a must have, or my GPU always reports out of memory. So far, I never find any good approaches that can directly upscale an image from 512x512 to larger size.If you know any good methods, please share it.Findings and issues:A good upscaler is a good beginning. This is actually very important. Since it is a trade-off between noise strength and consistency between tiles. If a poor up-scaler is used with a low noise strength, the final image will become blurry since it is “mimicking” the blurriness from the original image. However, if a high noise strength is used, the image does not look like the original image anymore.Overlapping size and ghost image. If you look at the test results, specifically near the trees or highly detailed region, you will find that there are ghost “regions”. This is because that it is a overlapping region and I am doing a weighted alpha sum here. The larger the overlapping size, the subjectively smoother the image will look like. However, it will increase the ghost region size as well.This is the issue that I am trying to resolve, and I did not find any related discussions.Is there any other methods that we can implement to compare the result? I know that web-ui has a “high res fix” implementation. However, after checking the code, it seems like a tiled diffusion based method. This postdoes diffusers have the equivalent to hires fix from A1111? · Issue #3429 · huggingface/diffusers · GitHubmentioned that there is a latent space approach. However, I did not find anymore discussion about it.
2023-12-20T05:20:35Z
Test results (2048x2048):Tiled diffusion with DDIM, 45 iterations, overlapping 48 pixels.1703046241.256251-test1920×1920 204 KB
2023-12-20T05:21:05Z
Tiled diffusion with Euler-A, 35 iterations, overlapping 48 pixels.1703046712.089393-test1920×1920 209 KB
2023-12-20T05:22:06Z
Tiled diffusion with Euler-A, 35 iterations, overlapping 64 pixels.1703047114.0242655-test1920×1920 206 KB