MCPcopy
hub / github.com/OpenMotionLab/MotionGPT / render_cli

Function render_cli

render.py:41–148  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

39
40
41def render_cli() -> None:
42 # parse options
43 cfg = parse_args(phase="render") # parse config file
44 cfg.FOLDER = cfg.RENDER.FOLDER
45
46 if cfg.RENDER.INPUT_MODE.lower() == "npy":
47 output_dir = Path(os.path.dirname(cfg.RENDER.NPY))
48 paths = [cfg.RENDER.NPY]
49 elif cfg.RENDER.INPUT_MODE.lower() == "dir":
50 output_dir = Path(cfg.RENDER.DIR)
51 paths = []
52 file_list = natsort.natsorted(os.listdir(cfg.RENDER.DIR))
53 begin_id = random.randrange(0, len(file_list))
54 file_list = file_list[begin_id:] + file_list[:begin_id]
55
56 # render mesh npy first
57 for item in file_list:
58 if item.endswith("_mesh.npy"):
59 paths.append(os.path.join(cfg.RENDER.DIR, item))
60
61 # then render joint npy
62 for item in file_list:
63 if item.endswith(".npy") and not item.endswith("_mesh.npy"):
64 paths.append(os.path.join(cfg.RENDER.DIR, item))
65
66 print(f"begin to render for {paths[0]}")
67
68 import numpy as np
69
70 from mGPT.render.blender import render
71 from mGPT.render.video import Video
72
73 init = True
74 for path in paths:
75 # check existed mp4 or under rendering
76 if cfg.RENDER.MODE == "video":
77 if os.path.exists(path.replace(".npy", ".mp4")) or os.path.exists(
78 path.replace(".npy", "_frames")):
79 print(f"npy is rendered or under rendering {path}")
80 continue
81 else:
82 # check existed png
83 if os.path.exists(path.replace(".npy", ".png")):
84 print(f"npy is rendered or under rendering {path}")
85 continue
86
87 if cfg.RENDER.MODE == "video":
88 frames_folder = os.path.join(
89 output_dir,
90 path.replace(".npy", "_frames").split('/')[-1])
91 os.makedirs(frames_folder, exist_ok=True)
92 else:
93 frames_folder = os.path.join(
94 output_dir,
95 path.replace(".npy", ".png").split('/')[-1])
96
97 try:
98 data = np.load(path)

Callers 1

render.pyFile · 0.85

Calls 4

saveMethod · 0.95
parse_argsFunction · 0.90
renderFunction · 0.90
VideoClass · 0.90

Tested by

no test coverage detected