-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathinference.sh
95 lines (75 loc) · 2.59 KB
/
inference.sh
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
cd inference
export CUDA_VISIBLE_DEVICES=4
## Please fill the parameters here
# path to the body model folder
body_weight_dir=./checkpoints/seth/body
# path to the head model folder
head_weight_dir=./checkpoints/seth/head
# path to the input poses
body_input_dir=./samples/poses/seth1
# path to the reference body appearance
body_prompt_img_pth=./samples/appearance/body.png
# path to the reference head appearance
head_prompt_img_pth=./samples/appearance/head.png
# pipe_path=runwayml/stable-diffusion-v1-5
# pipe_inpainting_path=runwayml/stable-diffusion-inpainting
body_unet_path=${body_weight_dir}/unet
body_controlent_path=${body_weight_dir}/controlnet
body_cfg=7.5
body_condition_scale=2.
head_unet_pth=${head_weight_dir}/unet
head_controlnet_path=${head_weight_dir}/controlnet
head_cfg=3.5
head_condition_scale=1.
save_root=./samples/output
fps=30
body_save_dir=${save_root}/body_output
body_headcrop_root=${body_save_dir}_meshcrop
head_dir=${body_headcrop_root}/raw_aligned
head_mask_dir=${body_headcrop_root}/raw_aligned_mask
head_input_dir=${body_headcrop_root}/aligned
head_matrix_dir=${body_headcrop_root}/matrix
head_save_dir=${body_headcrop_root}/face_output
final_save_dir=${save_root}/final_output
# inference on body
python inference_body.py \
--unet_path $body_unet_path \
--controlnet_path $body_controlent_path \
--input_dir $body_input_dir \
--save_dir $body_save_dir \
--prompt_img_pth $body_prompt_img_pth \
--CFG $body_cfg \
--condition_scale $body_condition_scale \
# --pipe_path $pipe_path
ffmpeg -r 30 -i $body_save_dir/%06d.png -q:v 0 -pix_fmt yuv420p $body_save_dir.mp4
# face alignment
python face_alignment.py \
--imgdir_pth $body_input_dir \
--raw_imgdir_pth $body_save_dir \
--results_dir $body_headcrop_root \
--crop_size 512
# get face mask
python get_mask.py \
--input_pth $head_dir \
--mask_pth $head_mask_dir
# inference on face inpainting
python inference_face_inpainting.py \
--unet_path $head_unet_pth \
--controlnet_path $head_controlnet_path \
--input_dir $head_input_dir \
--face_dir $head_dir \
--mask_dir $head_mask_dir \
--save_dir $head_save_dir \
--prompt_img_pth $head_prompt_img_pth \
--CFG $head_cfg \
--condition_scale $head_condition_scale \
--batch_size 30 \
# --pipe_pth $pipe_inpainting_path
# face blending
python face_blending.py \
--body_dir $body_save_dir \
--face_dir $head_save_dir \
--matrix_dir $head_matrix_dir \
--save_dir $final_save_dir \
--crop_size 512
ffmpeg -r 30 -i $final_save_dir/%06d.png -q:v 0 -pix_fmt yuv420p $final_save_dir.mp4