xinntao / Real-ESRGAN

Real-ESRGAN aims at developing Practical Algorithms for General Image/Video Restoration.
BSD 3-Clause "New" or "Revised" License
27.64k stars 3.47k forks source link

A problem about the inference of gray image(8 bit image) #483

Open DsLipku opened 1 year ago

DsLipku commented 1 year ago

When I try to restore 00017_gray.png this image(a gray, 8-bit image) ,

using command "python inference_realesrgan.py -n RealESRGAN_x4plus -i inputs --face_enhance --fp32",

the following problem occured:

Traceback (most recent call last): File "C:/Users/qingfeng/Desktop/Real-ESRGAN/inferencerealesrgan.py", line 145, in main , _, output = face_enhancer.enhance(img, has_aligned=False, only_center_face=False, paste_back=True) File "D:\Anaconda3\envs\Real-ESRGAN\lib\site-packages\torch\autograd\grad_mode.py", line 27, in decorate_context return func(*args, kwargs) File "D:\Anaconda3\envs\Real-ESRGAN\lib\site-packages\gfpgan\utils.py", line 145, in enhance restored_img = self.face_helper.paste_faces_to_input_image(upsample_img=bg_img) File "D:\Anaconda3\envs\Real-ESRGAN\lib\site-packages\facexlib\utils\face_restoration_helper.py", line 355, in paste_faces_to_input_image upsample_img = inv_soft_mask pasted_face + (1 - inv_soft_mask) upsample_img ValueError: operands could not be broadcast together with shapes (1404,2000,1) (1404,2000)**

In this statement "upsample_img = inv_soft_mask pasted_face + (1 - inv_soft_mask) upsample_img", the shape of inv_soft_mask is (1404,2000,1), the shape of pasted_face is (1404,2000,3) and the shape of upsample_img is (1404,2000).

Dalaoyel commented 1 year ago

我也遇到这个问题了,你有好的解决办法吗

DsLipku commented 1 year ago

我也遇到这个问题了,你有好的解决办法吗

预处理一下灰度图,将灰度图的单通道复制成三通道,代码如下 image

Dalaoyel commented 1 year ago

我也遇到这个问题了,你有好的解决办法吗

预处理一下灰度图,将灰度图的单通道复制成三通道,代码如下 image

这非常管用,谢谢你

jackecust commented 1 year ago

我也遇到这个问题了,你有好的解决办法吗

预处理一下灰度图,将灰度图的单通道复制成三通道,代码如下 image

it is very good, really thanks