UnboundLocalError: local variable 'e' referenced before assignment
Hello, First thanks for the good job of implementing this segmentation pipeline and to take time to fixe this issue. As described in the documentation, I trained a 2d model on the 5 folds of a segmentation task (task_id=500) without saving the soft_max result. After doing so, I needed to compare the trained models so I reffered to the Model Training section of your documentation and ran the following command : nnUNet_train 2d nnUNetTrainerV2 500 1 -val --npz
And I get this unexpected error after some preprocessing : File "~/segmentation-pipeline/nnUNet/nnunet/training/network_training/nnUNetTrainer.py", line 678, in validate if e is not None: UnboundLocalError: local variable 'e' referenced before assignment
The chunk of code that raises an error from l.665 to l.679 :
for f in subfiles(self.gt_niftis_folder, suffix=".nii.gz"):
success = False
attempts = 0
e = None
while not success and attempts < 10:
try:
shutil.copy(f, gt_nifti_folder)
success = True
except OSError as e:
attempts += 1
sleep(1)
if not success:
print("Could not copy gt nifti file %s into folder %s" % (f, gt_nifti_folder))
if e is not None:
raise e
The solution I propose, knowing I mostly use your package as a blackbox :
for f in subfiles(self.gt_niftis_folder, suffix=".nii.gz"):
success = False
attempts = 0
while not success and attempts < 10:
try:
shutil.copy(f, gt_nifti_folder)
success = True
except OSError:
attempts += 1
sleep(1)
if not success:
print("Could not copy gt nifti file %s into folder %s" % (f, gt_nifti_folder))
raise OSError("Could not copy gt nifti file %s into folder %s" % (f, gt_nifti_folder))