CoolFace
Apppublic

vumichien/Generate_human_motion

sourceHugging Faceapache-2.0updated 2y agoView on Hugging Face
125likes
render_mesh.py34 linesDownload Raw Back to visualize
1import argparse2import os3from visualize import vis_utils4import shutil5from tqdm import tqdm6 7if __name__ == '__main__':8    parser = argparse.ArgumentParser()9    parser.add_argument("--input_path", type=str, required=True, help='stick figure mp4 file to be rendered.')10    parser.add_argument("--cuda", type=bool, default=True, help='')11    parser.add_argument("--device", type=int, default=0, help='')12    params = parser.parse_args()13 14    assert params.input_path.endswith('.mp4')15    parsed_name = os.path.basename(params.input_path).replace('.mp4', '').replace('sample', '').replace('rep', '')16    sample_i, rep_i = [int(e) for e in parsed_name.split('_')]17    npy_path = os.path.join(os.path.dirname(params.input_path), 'results.npy')18    out_npy_path = params.input_path.replace('.mp4', '_smpl_params.npy')19    assert os.path.exists(npy_path)20    results_dir = params.input_path.replace('.mp4', '_obj')21    if os.path.exists(results_dir):22        shutil.rmtree(results_dir)23    os.makedirs(results_dir)24 25    npy2obj = vis_utils.npy2obj(npy_path, sample_i, rep_i,26                                device=params.device, cuda=params.cuda)27 28    print('Saving obj files to [{}]'.format(os.path.abspath(results_dir)))29    for frame_i in tqdm(range(npy2obj.real_num_frames)):30        npy2obj.save_obj(os.path.join(results_dir, 'frame{:03d}.obj'.format(frame_i)), frame_i)31 32    print('Saving SMPL params to [{}]'.format(os.path.abspath(out_npy_path)))33    npy2obj.save_npy(out_npy_path)34