Real-ESRGAN icon indicating copy to clipboard operation
Real-ESRGAN copied to clipboard

Visual artefacts present in upscaled images when device is set to 'mps'

Open ericpesto opened this issue 2 years ago • 3 comments

To see the code, please refer to: https://github.com/ericpesto/stable-diffusion-mac-background-image-generator/blob/b1b14ea9b7fbefd1976478f4becfd5d529b2a956/main.py#L66-L74

ericpesto avatar Feb 12 '23 21:02 ericpesto

+1. I'm having the same problem. Did you find out how to solve it?

AeroDEmi avatar Mar 06 '23 23:03 AeroDEmi

Found a solution when using mps: Inside the folder RealESRGAN in the main.py, you must first call cpu() and then clamp.

Code in the repo line 77: sr_image = res.permute((0,2,3,1)).clamp_(0, 1).cpu()

New code: sr_image = res.permute((0,2,3,1)).cpu().clamp_(0,1)

AeroDEmi avatar Mar 06 '23 23:03 AeroDEmi

Can confirm, works for me too, nice find!

*I had to make the change in models.py

ericpesto avatar Mar 07 '23 00:03 ericpesto