Skip to content

Commit

Permalink
Convert numpy arrays to lists before saving the evaluation metrics as…
Browse files Browse the repository at this point in the history
… 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
  • Loading branch information
harisankar95 authored May 11, 2023
1 parent 436dc77 commit 5d02e6b
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -682,7 +682,9 @@ def preprocess_val(example_batch):
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)

Expand Down

0 comments on commit 5d02e6b

Please sign in to comment.