ai-forever / Real-ESRGAN

PyTorch implementation of Real-ESRGAN model
BSD 3-Clause "New" or "Revised" License
463 stars 118 forks source link

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

Open ericpesto opened 1 year ago

ericpesto commented 1 year ago

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

AeroDEmi commented 1 year ago

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

AeroDEmi commented 1 year ago

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)

ericpesto commented 1 year ago

Can confirm, works for me too, nice find!

*I had to make the change in models.py