forked from tfedor/dzo-arap
-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.py
67 lines (58 loc) · 3.16 KB
/
main.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
from classes.Application import Application
import argparse
import numpy as np
def str2bool(v):
if v.lower() in ("yes", "true", "t", "y", "1"):
return True
elif v.lower() in ("no", "false", "f", "n", "0"):
return False
else:
raise argparse.ArgumentTypeError("Boolean value expected.")
def csv2dict(csv):
box_sizes = {}
body_parts = ["head", "right_arm", "left_arm", "right_leg", "left_leg"]
if csv is not None:
for body_part, box_size in zip(body_parts, list(map(int, csv.split(',')))):
box_sizes[body_part] = box_size
return box_sizes
return None
def background_pixel(string):
if string is None:
return None
ch1, ch2, ch3 = map(int, string.split(','))
return np.array([ch1,ch2,ch3])
parser = argparse.ArgumentParser()
parser.add_argument("--background", default=None, help="custom background path")
parser.add_argument("--background_color", default=None, type=background_pixel, help="custom background pixel")
parser.add_argument("--mask", default=None, help="custom mask path")
parser.add_argument("--split_body_on_parts", default=False, type=str2bool, help="if false grid will be construct once on whole body")
parser.add_argument("--bodypart_mask", default=None, help="bodypart mask path")
parser.add_argument("--bodypart_thresh", type=float, default=0.075, help="threshold that uses in computing bind mask")
parser.add_argument("--num_bodypart_points", type=int, default=5, help="num points that will be automatically add at borders of bodyparts")
parser.add_argument("--visible_bodypart_points", type=str2bool, default=False, help="whether show or not bodypart points")
parser.add_argument("--box_size", default=32, type=int, help="box size for grid")
parser.add_argument("--bodyparts_box_sizes", default=None, type=csv2dict, help="box sizes in follow order: head, right arm, left arm, right leg, left leg")
parser.add_argument("--keypoints_dir", default="assets/frames/greeting_jsons", help="path to keypoints directory")
parser.add_argument("--path", default="assets/frames/greeting_frames/45.png", help="path to image")
parser.add_argument("--num_iterations", default=50, help="number of iterations to fit each pose")
parser.add_argument("--grid", default=False, type=str2bool, help="to show grid pass True")
parser.add_argument("--save_mask", default=str2bool, help="to save computed mask into masks/")
parser.add_argument("--outdir", default="out/", help="directory to save warped frames")
parser.add_argument(
"--enumerate",
default=False,
type=str2bool,
help="to automatically enumerate paths for saving deformed images",
)
parser.add_argument(
"--control_weight", default=100000, type=int, help="control weight for grid"
)
parser.add_argument("--morph_path", default=None, help="path to morphing frames")
parser.add_argument("--morphing_start_frame", default=0, help="TODO:meh")
parser.add_argument("--morphing_end_frame", default=-1, help="pass -1 for last frame")
app = Application(parser.parse_args())
app.bind("<Button-1>", app.select_handle)
app.bind("<ButtonRelease-1>", app.deselect_handle)
app.bind("<Button-3>", app.remove_handle)
app.bind("<B1-Motion>", app.move_handle)
app.run()