-
Notifications
You must be signed in to change notification settings - Fork 17
/
run_posetransfer.py
103 lines (98 loc) · 4.32 KB
/
run_posetransfer.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
import argparse
from dofaker import PoseSwapper
def parse_args():
parser = argparse.ArgumentParser(description='running face swap')
parser.add_argument('--source',
help='select an image or video to be swapped',
dest='source',
required=True)
parser.add_argument('--target',
help='the target pose image',
dest='target',
required=True)
parser.add_argument('--output_dir',
help='output directory',
dest='output_dir',
default='output')
parser.add_argument('--pose_estimator_name',
help='pose estimator name',
dest='pose_estimator_name',
default='openpose_body')
parser.add_argument('--pose_estimator_model_dir',
help='pose estimator model dir',
dest='pose_estimator_model_dir',
default='weights/models')
parser.add_argument('--pose_transfer_name',
help='pose transfer name',
dest='pose_transfer_name',
default='pose_transfer')
parser.add_argument('--pose_transfer_model_dir',
help='pose transfer model dir',
dest='pose_transfer_model_dir',
default='weights/models')
parser.add_argument('--det_model_name',
help='detection model name for insightface',
dest='det_model_name',
default='buffalo_l')
parser.add_argument('--det_model_dir',
help='detection model dir for insightface',
dest='det_model_dir',
default='weights/models')
parser.add_argument('--image_sr_model',
help='image super resolution model',
dest='image_sr_model',
default='bsrgan')
parser.add_argument('--image_sr_model_dir',
help='image super resolution model dir',
dest='image_sr_model_dir',
default='weights/models')
parser.add_argument('--face_enhance_name',
help='face enhance model',
dest='face_enhance_name',
default='gfpgan')
parser.add_argument('--face_enhance_model_dir',
help='face enhance model dir',
dest='face_enhance_model_dir',
default='weights/models')
parser.add_argument('--log_iters',
help='print log intervals',
dest='log_iters',
default=10,
type=int)
parser.add_argument('--use_enhancer',
help='whether use face enhance model',
dest='use_enhancer',
action='store_true')
parser.add_argument('--use_sr',
help='whether use image super resolution model',
dest='use_sr',
action='store_true')
parser.add_argument('--sr_scale',
help='image super resolution scale',
dest='sr_scale',
default=1,
type=float)
return parser.parse_args()
if __name__ == '__main__':
args = parse_args()
faker = PoseSwapper(
pose_estimator_name=args.pose_estimator_name,
pose_estimator_model_dir=args.pose_estimator_model_dir,
pose_transfer_name=args.pose_transfer_name,
pose_transfer_model_dir=args.pose_transfer_model_dir,
face_det_model=args.det_model_name,
face_det_model_dir=args.det_model_dir,
image_sr_model=args.image_sr_model,
image_sr_model_dir=args.image_sr_model_dir,
face_enhance_name=args.face_enhance_name,
face_enhance_model_dir=args.face_enhance_model_dir,
log_iters=args.log_iters,
use_enhancer=args.use_enhancer,
use_sr=args.use_sr,
scale=args.sr_scale,
)
faker.run(
input_path=args.source,
target_path=args.target,
output_dir=args.output_dir,
)