python 人脸识别(腾讯 gfpgan方案)
实现功能
使用腾讯 gfpgan方案进行人脸识别并高清修复
1.首先在github下载源文件https://github.com/TencentARC/GFPGAN
左边是从视频中截取的人脸,右边是修复后的结果,只能说这效果杠杠的
2.代码修改后,运行时会在’xxx\gfpgan\weights’文件夹中自动下载GFPGANv1.3.pth
模型文件,同时在程序的文件夹’xxx\notepad\gfpgan\weights’下会下载’detection_Resnet50_Final.pth’, ‘parsing_parsenet.pth’两个模型,
可以自动运行时自动下载相应模型到对应位置,
也可以在如下链接’ ’下载这三个模型,然后放到对应的文件夹下
核心代码分三步:
1)定义关键参数(未做修改)
upscale = 2
arch ='clean'
channel_multiplier=2
bg_upsampler = None
aligned = False
only_center_face = False
weight=0.5
2)调用GFPGANer(...)
restorer = GFPGANer(
model_path=model_path,
upscale=upscale,
arch=arch,
channel_multiplier=channel_multiplier,
bg_upsampler=bg_upsampler)
3)
cropped_faces, rest