解决报错:upsample_img = inv_soft_mask * pasted_face + (1 - inv_soft_mask) * upsample_img ValueError: ope

1. 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)

完整错误
Traceback (most recent call last):
 File "/home/featurize/work/1超分辨率/Real-ESRGAN-master/inference_realesrgan.py", line 167, in <module>
 main()
 File "/home/featurize/work/1超分辨率/Real-ESRGAN-master/inference_realesrgan.py", line 146, in main
 _, _, output = face_enhancer.enhance(img, has_aligned=False, only_center_face=False, paste_back=True)
 File "/environment/miniconda3/lib/python3.10/site-packages/torch/utils/_contextlib.py", line 115, in decorate_context
 return func(*args, **kwargs)
 File "/environment/miniconda3/lib/python3.10/site-packages/gfpgan/utils.py", line 145, in enhance
 restored_img = self.face_helper.paste_faces_to_input_image(upsample_img=bg_img)
 File "/environment/miniconda3/lib/python3.10/site-packages/facexlib/utils/face_restoration_helper.py", line 355, in paste_faces_to_i
 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)
这是因为处理的图片是png格式的,只需要将png格式的图片转化为jpg格式,以上问题即可解决,例如我的图片一开始是00017_gray.png

2. 转换代码

1 from PIL import Image
2 img = Image.open('path/xx.png')#你自己的png图片路径
3 img = img.convert('RGB')
4 img.save('path/xx.jpg')#你自己保存的jpg图片路径

3. 报错消失出现以下输出代表成功解决问题

1 Testing 0 00003
2 (256, 512, 3) =====================
3 Testing 1 00017_gray
4 (351, 500, 3) =====================

  • 10
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值