MCPcopy Create free account
hub / github.com/MotrixLab/MotionDiffuse / evaluate_fid

Function evaluate_fid

text2motion/tools/evaluation.py:87–110  ·  view source on GitHub ↗
(groundtruth_loader, activation_dict, file)

Source from the content-addressed store, hash-verified

85
86
87def evaluate_fid(groundtruth_loader, activation_dict, file):
88 eval_dict = OrderedDict({})
89 gt_motion_embeddings = []
90 print('========== Evaluating FID ==========')
91 with torch.no_grad():
92 for idx, batch in enumerate(groundtruth_loader):
93 _, _, _, sent_lens, motions, m_lens, _ = batch
94 motion_embeddings = eval_wrapper.get_motion_embeddings(
95 motions=motions,
96 m_lens=m_lens
97 )
98 gt_motion_embeddings.append(motion_embeddings.cpu().numpy())
99 gt_motion_embeddings = np.concatenate(gt_motion_embeddings, axis=0)
100 gt_mu, gt_cov = calculate_activation_statistics(gt_motion_embeddings)
101
102 # print(gt_mu)
103 for model_name, motion_embeddings in activation_dict.items():
104 mu, cov = calculate_activation_statistics(motion_embeddings)
105 # print(mu)
106 fid = calculate_frechet_distance(gt_mu, gt_cov, mu, cov)
107 print(f'---> [{model_name}] FID: {fid:.4f}')
108 print(f'---> [{model_name}] FID: {fid:.4f}', file=file, flush=True)
109 eval_dict[model_name] = fid
110 return eval_dict
111
112
113def evaluate_diversity(activation_dict, file):

Callers 1

evaluationFunction · 0.85

Calls 3

get_motion_embeddingsMethod · 0.80

Tested by

no test coverage detected