(history, motion_uploaded, data_stored, method)
| 221 | |
| 222 | |
| 223 | def bot(history, motion_uploaded, data_stored, method): |
| 224 | |
| 225 | motion_length, motion_token_string = motion_uploaded[ |
| 226 | "motion_lengths"], motion_uploaded["motion_token_string"] |
| 227 | |
| 228 | input = data_stored[-1]['user_input'] |
| 229 | prompt = model.lm.placeholder_fulfill(input, motion_length, |
| 230 | motion_token_string, "") |
| 231 | data_stored[-1]['model_input'] = prompt |
| 232 | batch = { |
| 233 | "length": [motion_length], |
| 234 | "text": [prompt], |
| 235 | } |
| 236 | |
| 237 | outputs = model(batch, task="t2m") |
| 238 | out_feats = outputs["feats"][0] |
| 239 | out_lengths = outputs["length"][0] |
| 240 | out_joints = outputs["joints"][:out_lengths].detach().cpu().numpy() |
| 241 | out_texts = outputs["texts"][0] |
| 242 | output_mp4_path, video_fname, output_npy_path, joints_fname = render_motion( |
| 243 | out_joints, |
| 244 | out_feats.to('cpu').numpy(), method) |
| 245 | |
| 246 | motion_uploaded = { |
| 247 | "feats": None, |
| 248 | "joints": None, |
| 249 | "motion_video": None, |
| 250 | "motion_lengths": 0, |
| 251 | "motion_token": None, |
| 252 | "motion_token_string": '', |
| 253 | "motion_token_length": 0, |
| 254 | } |
| 255 | |
| 256 | data_stored[-1]['model_output'] = { |
| 257 | "feats": out_feats, |
| 258 | "joints": out_joints, |
| 259 | "length": out_lengths, |
| 260 | "texts": out_texts, |
| 261 | "motion_video": output_mp4_path, |
| 262 | "motion_video_fname": video_fname, |
| 263 | "motion_joints": output_npy_path, |
| 264 | "motion_joints_fname": joints_fname, |
| 265 | } |
| 266 | |
| 267 | if '<Motion_Placeholder>' == out_texts: |
| 268 | response = [ |
| 269 | Video_Components.format(video_path=output_mp4_path, |
| 270 | video_fname=video_fname, |
| 271 | motion_path=output_npy_path, |
| 272 | motion_fname=joints_fname) |
| 273 | ] |
| 274 | elif '<Motion_Placeholder>' in out_texts: |
| 275 | response = [ |
| 276 | Text_Components.format( |
| 277 | msg=out_texts.split("<Motion_Placeholder>")[0]), |
| 278 | Video_Components.format(video_path=output_mp4_path, |
| 279 | video_fname=video_fname, |
| 280 | motion_path=output_npy_path, |
nothing calls this directly
no test coverage detected