RuntimeError: "reflection_pad2d" not implemented for 'Half' #77

Closed
opened 2026-01-29 21:41:01 +00:00 by claunia · 3 comments
Owner

Originally created by @abdirk01 on GitHub (Sep 20, 2021).

Hi, I just want to try this out. Without CODA it is running fine, but as soon as I use it with CODA I get the following error:

Traceback (most recent call last):
File "\GFPGAN\inference_gfpgan.py", line 98, in
main()
File "\GFPGAN\inference_gfpgan.py", line 67, in main
cropped_faces, restored_faces, restored_img = restorer.enhance(
File "\AppData\Local\Programs\Python\Python39\lib\site-packages\torch\autograd\grad_mode.py", line 28, in decorate_context
return func(*args, **kwargs)
File "\GFPGAN\gfpgan\utils.py", line 105, in enhance
bg_img = self.bg_upsampler.enhance(img, outscale=self.upscale)[0]
File "\AppData\Local\Programs\Python\Python39\lib\site-packages\torch\autograd\grad_mode.py", line 28, in decorate_context
return func(*args, **kwargs)
File "\AppData\Local\Programs\Python\Python39\lib\site-packages\realesrgan\utils.py", line 168, in enhance
self.pre_process(img)
File "\AppData\Local\Programs\Python\Python39\lib\site-packages\realesrgan\utils.py", line 64, in pre_process
self.img = F.pad(self.img, (0, self.mod_pad_w, 0, self.mod_pad_h), 'reflect')
File "\AppData\Local\Programs\Python\Python39\lib\site-packages\torch\nn\functional.py", line 4170, in _pad
return torch._C._nn.reflection_pad2d(input, pad)
RuntimeError: "reflection_pad2d" not implemented for 'Half'

It's on a Windows 10 Laptop.

Thanks for your help!
Dirk

Originally created by @abdirk01 on GitHub (Sep 20, 2021). Hi, I just want to try this out. Without CODA it is running fine, but as soon as I use it with CODA I get the following error: > Traceback (most recent call last): > File "\GFPGAN\inference_gfpgan.py", line 98, in <module> > main() > File "\GFPGAN\inference_gfpgan.py", line 67, in main > cropped_faces, restored_faces, restored_img = restorer.enhance( > File "\AppData\Local\Programs\Python\Python39\lib\site-packages\torch\autograd\grad_mode.py", line 28, in decorate_context > return func(*args, **kwargs) > File "\GFPGAN\gfpgan\utils.py", line 105, in enhance > bg_img = self.bg_upsampler.enhance(img, outscale=self.upscale)[0] > File "\AppData\Local\Programs\Python\Python39\lib\site-packages\torch\autograd\grad_mode.py", line 28, in decorate_context > return func(*args, **kwargs) > File "\AppData\Local\Programs\Python\Python39\lib\site-packages\realesrgan\utils.py", line 168, in enhance > self.pre_process(img) > File "\AppData\Local\Programs\Python\Python39\lib\site-packages\realesrgan\utils.py", line 64, in pre_process > self.img = F.pad(self.img, (0, self.mod_pad_w, 0, self.mod_pad_h), 'reflect') > File "\AppData\Local\Programs\Python\Python39\lib\site-packages\torch\nn\functional.py", line 4170, in _pad > return torch._C._nn.reflection_pad2d(input, pad) > RuntimeError: "reflection_pad2d" not implemented for 'Half' It's on a Windows 10 Laptop. Thanks for your help! Dirk
Author
Owner

@xinntao commented on GitHub (Sep 21, 2021):

Try to set half=False

f6d3f70646/inference_gfpgan.py (L46-L49)

@xinntao commented on GitHub (Sep 21, 2021): Try to set `half=False` https://github.com/TencentARC/GFPGAN/blob/f6d3f706466e82afbe091abc033c7a91036f8f9a/inference_gfpgan.py#L46-L49
Author
Owner

@abdirk01 commented on GitHub (Sep 21, 2021):

Now it's working! Thank you very much! I do see a picture in the results folder. The faces are looking great, the rest of the b/w picture does not look very much changed though...

@abdirk01 commented on GitHub (Sep 21, 2021): Now it's working! Thank you very much! I do see a picture in the results folder. The faces are looking great, the rest of the b/w picture does not look very much changed though...
Author
Owner

@xinntao commented on GitHub (Sep 23, 2021):

@abdirk01 Thanks for your feedback.
The b/w uses a mild restoration model.

You can try Real-ESRGAN to try a better model for background, which also supports face enhancement.

@xinntao commented on GitHub (Sep 23, 2021): @abdirk01 Thanks for your feedback. The b/w uses a mild restoration model. You can try [Real-ESRGAN](https://github.com/xinntao/Real-ESRGAN) to try a better model for background, which also supports face enhancement.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: TencentARC/GFPGAN#77