(motion_uploaded, method)
| 136 | |
| 137 | |
| 138 | def load_motion(motion_uploaded, method): |
| 139 | file = motion_uploaded['file'] |
| 140 | |
| 141 | feats = torch.tensor(np.load(file), device=model.device) |
| 142 | if len(feats.shape) == 2: |
| 143 | feats = feats[None] |
| 144 | # feats = model.datamodule.normalize(feats) |
| 145 | |
| 146 | # Motion tokens |
| 147 | motion_lengths = feats.shape[0] |
| 148 | motion_token, _ = model.vae.encode(feats) |
| 149 | |
| 150 | motion_token_string = model.lm.motion_token_to_string( |
| 151 | motion_token, [motion_token.shape[1]])[0] |
| 152 | motion_token_length = motion_token.shape[1] |
| 153 | |
| 154 | # Motion rendered |
| 155 | joints = model.datamodule.feats2joints(feats.cpu()).cpu().numpy() |
| 156 | output_mp4_path, video_fname, output_npy_path, joints_fname = render_motion( |
| 157 | joints, |
| 158 | feats.to('cpu').numpy(), method) |
| 159 | |
| 160 | motion_uploaded.update({ |
| 161 | "feats": feats, |
| 162 | "joints": joints, |
| 163 | "motion_video": output_mp4_path, |
| 164 | "motion_video_fname": video_fname, |
| 165 | "motion_joints": output_npy_path, |
| 166 | "motion_joints_fname": joints_fname, |
| 167 | "motion_lengths": motion_lengths, |
| 168 | "motion_token": motion_token, |
| 169 | "motion_token_string": motion_token_string, |
| 170 | "motion_token_length": motion_token_length, |
| 171 | }) |
| 172 | |
| 173 | return motion_uploaded |
| 174 | |
| 175 | |
| 176 | def add_text(history, text, motion_uploaded, data_stored, method): |
no test coverage detected