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

Function generate_by_video_sequences

mGPT/render/visualize.py:687–733  ·  view source on GitHub ↗
(visualization, label_to_action_name, params,
                                nats, nspa, tmp_path)

Source from the content-addressed store, hash-verified

685
686
687def generate_by_video_sequences(visualization, label_to_action_name, params,
688 nats, nspa, tmp_path):
689 # shape : (17, 3, 4, 480, 640, 3)
690 # (nframes, row, column, h, w, 3)
691 fps = params["fps"]
692 if "output_vetices" in visualization:
693 outputkey = "output_vetices"
694 params["pose_rep"] = "vertices"
695 elif "output_xyz" in visualization:
696 outputkey = "output_xyz"
697 params["pose_rep"] = "xyz"
698 else:
699 outputkey = "poses"
700
701 keep = [outputkey, 'lengths', "y"]
702 visu = {key: visualization[key].data.cpu().numpy() for key in keep}
703 lenmax = visu['lengths'].max()
704
705 timesize = lenmax + 5
706
707 # import multiprocessing
708
709 def pool_job_with_desc(pool, iterator, desc, max_, save_path_format):
710 for data in iterator:
711 plot_3d_motion_dico(data)
712 # with tqdm(total=max_, desc=desc.format("Render")) as pbar:
713 # for _ in pool.imap_unordered(plot_3d_motion_dico, iterator):
714 # pbar.update()
715 array = np.stack([[
716 load_anim(save_path_format.format(i, j), timesize)
717 for j in range(nats)
718 ] for i in tqdm(range(nspa), desc=desc.format("Load"))])
719 return array.transpose(2, 0, 1, 3, 4, 5)
720
721 pool = None
722 # with multiprocessing.Pool() as pool:
723 # Real samples
724 save_path_format = os.path.join(tmp_path, "real_{}_{}.gif")
725 iterator = ((visu[outputkey][i, j], visu['lengths'][i, j],
726 save_path_format.format(i, j), params, {
727 "title": f"real: {label_to_action_name(visu['y'][i, j])}",
728 "interval": 1000 / fps
729 }) for j in range(nats) for i in range(nspa))
730 visu["frames"] = pool_job_with_desc(pool, iterator, "{} the real samples",
731 nats, save_path_format)
732 frames = stack_images_sequence(visu["frames"])
733 return frames
734
735
736def stack_images_sequence(visu):

Callers 1

viz_datasetFunction · 0.85

Calls 2

pool_job_with_descFunction · 0.85
stack_images_sequenceFunction · 0.85

Tested by

no test coverage detected