MCPcopy Create free account
hub / github.com/TeleHuman/PBHC / load_data

Method load_data

humanoidverse/utils/motion_lib/motion_lib_base.py:63–96  ·  view source on GitHub ↗
(self, motion_file, min_length=-1, im_eval=False)

Source from the content-addressed store, hash-verified

61 return
62
63 def load_data(self, motion_file, min_length=-1, im_eval=False):
64 if osp.isfile(motion_file):
65 self.mode = MotionlibMode.file
66 self._motion_data_load = joblib.load(motion_file)
67 else:
68 self.mode = MotionlibMode.directory
69 self._motion_data_load = glob.glob(osp.join(motion_file, "*.pkl"))
70 data_list = self._motion_data_load
71 if self.mode == MotionlibMode.file:
72 if min_length != -1:
73 # filtering the data by the length of the motion
74 data_list = {k: v for k, v in list(self._motion_data_load.items()) if len(v["pose_quat_global"]) >= min_length}
75 elif im_eval:
76 # sorting the data by the length of the motion
77 data_list = {
78 item[0]: item[1]
79 for item in sorted(
80 self._motion_data_load.items(),
81 key=lambda entry: len(entry[1]["pose_quat_global"]),
82 reverse=True,
83 )
84 }
85 else:
86 data_list = self._motion_data_load
87 self._motion_data_list = np.array(list(data_list.values()))
88 self._motion_data_keys = np.array(list(data_list.keys()))
89 else:
90 self._motion_data_list = np.array(self._motion_data_load)
91 self._motion_data_keys = np.array(self._motion_data_load)
92
93 self._num_unique_motions = len(self._motion_data_list)
94 if self.mode == MotionlibMode.directory:
95 self._motion_data_load = joblib.load(self._motion_data_load[0]) # set self._motion_data_load to a sample of the data
96 logger.info(f"Loaded {self._num_unique_motions} motions")
97
98 def setup_constants(self, fix_height=FixHeightMode.full_fix, multi_thread=True):
99 self.fix_height = fix_height

Callers 2

__init__Method · 0.95
get_motionlib_dataFunction · 0.45

Calls 1

loadMethod · 0.45

Tested by

no test coverage detected