Convert numpy arrays to lists before saving the evaluation metrics as json (#23268)

* convert numpy array to list before writing to json

per_category_iou and per_category_accuracy  are ndarray in the eval_metrics

* code reformatted with make style
This commit is contained in:
Hari
2023-05-11 14:54:23 +02:00
committed by GitHub
parent 436dc779a5
commit 5d02e6bd20

View File

@@ -682,7 +682,9 @@ def main():
if args.push_to_hub:
repo.push_to_hub(commit_message="End of training", auto_lfs_prune=True)
all_results = {f"eval_{k}": v for k, v in eval_metrics.items()}
all_results = {
f"eval_{k}": v.tolist() if isinstance(v, np.ndarray) else v for k, v in eval_metrics.items()
}
with open(os.path.join(args.output_dir, "all_results.json"), "w") as f:
json.dump(all_results, f)