MCPcopy Index your code
hub / github.com/GuyTevet/motion-diffusion-model / evaluate

Method evaluate

train/training_loop.py:252–289  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

250 self.evaluate()
251
252 def evaluate(self):
253 if not self.args.eval_during_training:
254 return
255 start_eval = time.time()
256 if self.eval_wrapper is not None:
257 print('Running evaluation loop: [Should take about 90 min]')
258 log_file = os.path.join(self.save_dir, f'eval_humanml_{(self.total_step()):09d}.log')
259 diversity_times = 300
260 mm_num_times = 0 # mm is super slow hence we won't run it during training
261 eval_dict = eval_humanml.evaluation(
262 self.eval_wrapper, self.eval_gt_data, self.eval_data, log_file,
263 replication_times=self.args.eval_rep_times, diversity_times=diversity_times, mm_num_times=mm_num_times, run_mm=False)
264 print(eval_dict)
265 for k, v in eval_dict.items():
266 if k.startswith('R_precision'):
267 for i in range(len(v)):
268 self.train_platform.report_scalar(name=f'top{i + 1}_' + k, value=v[i],
269 iteration=self.total_step(),
270 group_name='Eval')
271 else:
272 self.train_platform.report_scalar(name=k, value=v, iteration=self.total_step(),
273 group_name='Eval')
274
275 elif self.dataset in ['humanact12', 'uestc']:
276 eval_args = SimpleNamespace(num_seeds=self.args.eval_rep_times, num_samples=self.args.eval_num_samples,
277 batch_size=self.args.eval_batch_size, device=self.device, guidance_param = 1,
278 dataset=self.dataset, unconstrained=self.args.unconstrained,
279 model_path=os.path.join(self.save_dir, self.ckpt_file_name()))
280 eval_dict = eval_humanact12_uestc.evaluate(eval_args, model=self.model, diffusion=self.diffusion, data=self.data.dataset)
281 print(f'Evaluation results on {self.dataset}: {sorted(eval_dict["feats"].items())}')
282 for k, v in eval_dict["feats"].items():
283 if 'unconstrained' not in k:
284 self.train_platform.report_scalar(name=k, value=np.array(v).astype(float).mean(), iteration=self.step, group_name='Eval')
285 else:
286 self.train_platform.report_scalar(name=k, value=np.array(v).astype(float).mean(), iteration=self.step, group_name='Eval Unconstrained')
287
288 end_eval = time.time()
289 print(f'Evaluation time: {round(end_eval-start_eval)/60}min')
290
291
292 def run_step(self, batch, cond):

Callers 1

run_loopMethod · 0.95

Calls 3

total_stepMethod · 0.95
ckpt_file_nameMethod · 0.95
report_scalarMethod · 0.45

Tested by

no test coverage detected