(log_file)
| 151 | |
| 152 | |
| 153 | def evaluation(log_file): |
| 154 | with open(log_file, 'w') as f: |
| 155 | all_metrics = OrderedDict({'Matching Score': OrderedDict({}), |
| 156 | 'R_precision': OrderedDict({}), |
| 157 | 'FID': OrderedDict({}), |
| 158 | 'Diversity': OrderedDict({}), |
| 159 | 'MultiModality': OrderedDict({})}) |
| 160 | for replication in range(replication_times): |
| 161 | motion_loaders = {} |
| 162 | mm_motion_loaders = {} |
| 163 | motion_loaders['ground truth'] = gt_loader |
| 164 | for motion_loader_name, motion_loader_getter in eval_motion_loaders.items(): |
| 165 | motion_loader, mm_motion_loader = motion_loader_getter() |
| 166 | motion_loaders[motion_loader_name] = motion_loader |
| 167 | mm_motion_loaders[motion_loader_name] = mm_motion_loader |
| 168 | |
| 169 | print(f'==================== Replication {replication} ====================') |
| 170 | print(f'==================== Replication {replication} ====================', file=f, flush=True) |
| 171 | print(f'Time: {datetime.now()}') |
| 172 | print(f'Time: {datetime.now()}', file=f, flush=True) |
| 173 | mat_score_dict, R_precision_dict, acti_dict = evaluate_matching_score(motion_loaders, f) |
| 174 | |
| 175 | print(f'Time: {datetime.now()}') |
| 176 | print(f'Time: {datetime.now()}', file=f, flush=True) |
| 177 | fid_score_dict = evaluate_fid(gt_loader, acti_dict, f) |
| 178 | |
| 179 | print(f'Time: {datetime.now()}') |
| 180 | print(f'Time: {datetime.now()}', file=f, flush=True) |
| 181 | div_score_dict = evaluate_diversity(acti_dict, f) |
| 182 | |
| 183 | print(f'Time: {datetime.now()}') |
| 184 | print(f'Time: {datetime.now()}', file=f, flush=True) |
| 185 | mm_score_dict = evaluate_multimodality(mm_motion_loaders, f) |
| 186 | |
| 187 | print(f'!!! DONE !!!') |
| 188 | print(f'!!! DONE !!!', file=f, flush=True) |
| 189 | |
| 190 | for key, item in mat_score_dict.items(): |
| 191 | if key not in all_metrics['Matching Score']: |
| 192 | all_metrics['Matching Score'][key] = [item] |
| 193 | else: |
| 194 | all_metrics['Matching Score'][key] += [item] |
| 195 | |
| 196 | for key, item in R_precision_dict.items(): |
| 197 | if key not in all_metrics['R_precision']: |
| 198 | all_metrics['R_precision'][key] = [item] |
| 199 | else: |
| 200 | all_metrics['R_precision'][key] += [item] |
| 201 | |
| 202 | for key, item in fid_score_dict.items(): |
| 203 | if key not in all_metrics['FID']: |
| 204 | all_metrics['FID'][key] = [item] |
| 205 | else: |
| 206 | all_metrics['FID'][key] += [item] |
| 207 | |
| 208 | for key, item in div_score_dict.items(): |
| 209 | if key not in all_metrics['Diversity']: |
| 210 | all_metrics['Diversity'][key] = [item] |
no test coverage detected