nagadomi / nunif

Misc; latest version of waifu2x; 2D video to stereo 3D video conversion
MIT License
1.58k stars 142 forks source link

Getting slight "over-draw" with resized images (probably only small images) #242

Closed shuttittuppitt closed 1 month ago

shuttittuppitt commented 1 month ago

005

I just now noticed (probably because I haven't used it for awhile) that some images experience what looks similar (but not identical) to a slight "over-draw" along the bottom row. By that, I mean that it looks similar to having the bottom row of an image duplicated into the 2 bottom rows of the result. (An image editor that I use shows that the resulting bottom lines are not identical, only similar.)

(I use this site to use waifu = https://unlimited.waifu2x.net/) Mostly I use "swin_unet / photo". When I noticed this strange effect, I tried the following to see what is causing it.

I assume that the small dimensions of the images that experience the effect are causing waifu to do this. Even if it does affect large images too, their size would make the result almost unnoticeable if they are affected.

nagadomi commented 1 month ago

It is perhaps artifact(noise) of replication padding. waifu2x pads the input image to a multiple of the tile size, then upscaled and cropped the valid area of the result. I changed the padding algorithm reflect to replicate on 2024-7-21 because of #183 bug.

reflect reflect_pad replicate replicate_pad

I plan to revert to using reflection padding, which fixed #183 bug.

nagadomi commented 1 month ago

Changed to use modified version of reflection padding (unlimited.waifu2x.net only). From my visual inspection, the problem has been fixed. If the result is the same, try clearing your browser cache.

nagadomi commented 1 month ago

Sorry, I have rolled back the changes above. I suspect this is a bug of a different cause than I expected.

nagadomi commented 1 month ago

test image dot2

When this image is upscaled to 4x using swin_unet/art, the white line on top and the black line on the bottom are exactly 4px (even when using reflection padding). So there is no bug in the image processing. However, given a typical art image, the results are obviously affected by padding pixels. It is possible that the model is learned corner alignment of resample filters (If the input looks like bicubic downsampling or bilinear downsampling).

Maybe something like this is happening. sr_interp

nagadomi commented 1 month ago

Changed to use reflection padding for photo model and replication padding for art model. If the result is the same, try clearing your browser cache.