nnUNet icon indicating copy to clipboard operation
nnUNet copied to clipboard

Error using nnUNetTrainerV2_Loss_Dice, nnUNetTrainerV2_focalLoss, and nnUNetTrainerV2_Adam_lr_3en4

Open avnishks opened this issue 3 years ago • 2 comments

Hi,

I have successfully ran the nnUnet on my own MRI dataset by following the following steps:

  1. run data conversion script on own data
  2. run (only the first ime) nnUNet_plan_and_preprocess --verify_dataset_integrity -t XXX
  3. run nnUNet_plan_and_preprocess -t XXX
  4. run nnUNet_train 3d_fullres nnUNetTrainerV2 XXX 'all'

This was all fine. Now I am trying to use the the other trainers you have provided for different loss functions (nnunet.training.network_training.nnUNet_variants.loss_function.nnUNetTrainerV2_Loss_Dice) and Adam optimizers etc. For this, I am using similar steps as listed above except change the trainer name in step 4: nnUNet_train 3d_fullres nnUNetTrainerV2_Loss_Dice XXX 'all'

But I keep running into this error: TypeError: Callable[[arg, ...], result]: each arg must be a type. Got Ellipsis.

I get the same error is I use nnUNetTrainerV2_focalLoss or nnUNetTrainerV2_Adam_lr_3en4. I was wondering if anyone has encountered this before? Attaching my terminal output below for reference.

Traceback (most recent call last):
  File "/autofs/vast/freesurfer/test/nnunet/nnUnet_venv/bin/nnUNet_train", line 33, in <module>
    sys.exit(load_entry_point('nnunet', 'console_scripts', 'nnUNet_train')())
  File "/autofs/vast/freesurfer/test/nnunet/nnUNet/nnunet/run/run_training.py", line 137, in main
    trainer_class = get_default_configuration(network, task, network_trainer, plans_identifier)
  File "/autofs/vast/freesurfer/test/nnunet/nnUNet/nnunet/run/default_configuration.py", line 60, in get_default_configuration
    current_module=base_module)
  File "/autofs/vast/freesurfer/test/nnunet/nnUNet/nnunet/training/model_restore.py", line 37, in recursive_find_python_class
    tr = recursive_find_python_class([join(folder[0], modname)], trainer_name, current_module=next_current_module)
  File "/autofs/vast/freesurfer/test/nnunet/nnUNet/nnunet/training/model_restore.py", line 37, in recursive_find_python_class
    tr = recursive_find_python_class([join(folder[0], modname)], trainer_name, current_module=next_current_module)
  File "/autofs/vast/freesurfer/test/nnunet/nnUNet/nnunet/training/model_restore.py", line 28, in recursive_find_python_class
    m = importlib.import_module(current_module + "." + modname)
  File "/usr/pubsw/packages/python/anaconda3.6/lib/python3.6/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 994, in _gcd_import
  File "<frozen importlib._bootstrap>", line 971, in _find_and_load
  File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 678, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/autofs/vast/freesurfer/test/nnunet/nnUNet/nnunet/training/network_training/nnUNet_variants/data_augmentation/nnUNetTrainerV2_DA5.py", line 22, in <module>
    from batchgenerators.transforms.local_transforms import BrightnessGradientAdditiveTransform, LocalGammaTransform
  File "/autofs/vast/freesurfer/test/nnunet/nnUnet_venv/lib/python3.6/site-packages/batchgenerators/transforms/local_transforms.py", line 21, in <module>
    from batchgenerators.utilities.custom_types import ScalarType, sample_scalar
  File "/autofs/vast/freesurfer/test/nnunet/nnUnet_venv/lib/python3.6/site-packages/batchgenerators/utilities/custom_types.py", line 19, in <module>
    ScalarType = Union[Union[int, float], Tuple[float, float], Callable[[Any, ...], Union[float, int]]]
  File "/usr/pubsw/packages/python/anaconda3.6/lib/python3.6/typing.py", line 1340, in __getitem__
    return self.__getitem_inner__(parameters)
  File "/usr/pubsw/packages/python/anaconda3.6/lib/python3.6/typing.py", line 682, in inner
    return func(*args, **kwds)
  File "/usr/pubsw/packages/python/anaconda3.6/lib/python3.6/typing.py", line 1350, in __getitem_inner__
    args = tuple(_type_check(arg, msg) for arg in args)
  File "/usr/pubsw/packages/python/anaconda3.6/lib/python3.6/typing.py", line 1350, in <genexpr>
    args = tuple(_type_check(arg, msg) for arg in args)
  File "/usr/pubsw/packages/python/anaconda3.6/lib/python3.6/typing.py", line 374, in _type_check
    raise TypeError(msg + " Got %.100r." % (arg,))
TypeError: Callable[[arg, ...], result]: each arg must be a type. Got Ellipsis.

avnishks avatar May 19 '22 08:05 avnishks

I also got the same problem. Have you been able to resolve it, already?

Nanex101195 avatar Jun 20 '22 04:06 Nanex101195

I think your python version is too old. Try 3.8 or 3.9

FabianIsensee avatar Aug 23 '22 08:08 FabianIsensee