MIC-DKFZ / nnUNet

Apache License 2.0
6k stars 1.78k forks source link

Error while trying to run evaluate_folder on ground truth data and predictions on test data #2393

Open ranjaniramesh99 opened 4 months ago

ranjaniramesh99 commented 4 months ago

Hi, I was interested to evaluate the dice score on my test data and ground data and was facing an issue about an image size mismatch. What would you recommend I do in this case?

Attaching the detailed error for your reference below: Using <class 'nnunetv2.imageio.simpleitk_reader_writer.SimpleITKIO'> reader/writer multiprocessing.pool.RemoteTraceback: """ Traceback (most recent call last): File "/usr/lib/python3.10/multiprocessing/pool.py", line 125, in worker result = (True, func(*args, **kwds)) File "/usr/lib/python3.10/multiprocessing/pool.py", line 51, in starmapstar return list(itertools.starmap(args[0], args[1])) File "/usr/local/lib/python3.10/dist-packages/nnunetv2/evaluation/evaluate_predictions.py", line 107, in compute_metrics tp, fp, fn, tn = compute_tp_fp_fn_tn(mask_ref, mask_pred, ignore_mask) File "/usr/local/lib/python3.10/dist-packages/nnunetv2/evaluation/evaluate_predictions.py", line 82, in compute_tp_fp_fn_tn tp = np.sum((mask_ref & mask_pred) & use_mask) ValueError: operands could not be broadcast together with shapes (1,85,161,101) (1,83,159,99) """

The above exception was the direct cause of the following exception:

Traceback (most recent call last): File "/usr/local/bin/nnUNetv2_evaluate_folder", line 8, in sys.exit(evaluate_folder_entry_point()) File "/usr/local/lib/python3.10/dist-packages/nnunetv2/evaluation/evaluate_predictions.py", line 232, in evaluate_folder_entry_point compute_metrics_on_folder2(args.gt_folder, args.pred_folder, args.djfile, args.pfile, args.o, args.np, chill=args.chill) File "/usr/local/lib/python3.10/dist-packages/nnunetv2/evaluation/evaluate_predictions.py", line 196, in compute_metrics_on_folder2 compute_metrics_on_folder(folder_ref, folder_pred, output_file, rw, file_ending, File "/usr/local/lib/python3.10/dist-packages/nnunetv2/evaluation/evaluate_predictions.py", line 145, in compute_metrics_on_folder results = pool.starmap( File "/usr/lib/python3.10/multiprocessing/pool.py", line 375, in starmap return self._map_async(func, iterable, starmapstar, chunksize).get() File "/usr/lib/python3.10/multiprocessing/pool.py", line 774, in get raise self._value ValueError: operands could not be broadcast together with shapes (1,85,161,101) (1,83,159,99)

Thanks!

constantinulrich commented 4 months ago

Hey, the mismatch must have happened already during prediction... what is the image size of the original predicted image? Best, Constantin

ranjaniramesh99 commented 4 months ago

Hi, Thanks for your prompt reply! The size was (1,83,159,99). Thanks!

constantinulrich commented 4 months ago

Thats really strange and should not happen. Are you allowed to share your data?

anagrammarian commented 4 months ago

Just to be clear, I ran c3d on the predicted and ground truth and Dice was fine. The headers/size look identical. The error happens when using the evaluator.

constantinulrich commented 4 months ago

So basically when the evaluator loads both the prediction and the GT, it changes shapes? Did you validate that?

anagrammarian commented 4 months ago

We will check that and get back.