babbu3682 / MTD-GAN

base code
MIT License
14 stars 3 forks source link

dataloader cannot iterate #4

Open EvelyneCalista opened 3 weeks ago

EvelyneCalista commented 3 weeks ago

Hi @babbu3682 , thank you for amazing work!

I would like to train your model however i got error in the dataloader that it cannot iterate through the data. the error is shown in following. I have make sure that the len(iterable)=108, I am new to MONAI framework, please your help. Thank you.

 train_stats = train_MTD_GAN_Ours(model, data_loader_train, optimizer_G, optimizer_D, device, epoch, args.print_freq, args.batch_size, weight_method_D)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/MTD-main/engine.py", line 33, in train_MTD_GAN_Ours
    for batch_data in metric_logger.log_every(data_loader, print_freq, header):
  File "/MTD-main/utils.py", line 110, in log_every
    for obj in iterable:
  File "/lib/python3.12/site-packages/torch/utils/data/dataloader.py", line 630, in __next__
    data = self._next_data()
           ^^^^^^^^^^^^^^^^^
  File "/lib/python3.12/site-packages/torch/utils/data/dataloader.py", line 1344, in _next_data
    return self._process_data(data)
           ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/lib/python3.12/site-packages/torch/utils/data/dataloader.py", line 1370, in _process_data
    data.reraise()
  File "/lib/python3.12/site-packages/torch/_utils.py", line 706, in reraise
    raise exception
RuntimeError: Caught RuntimeError in DataLoader worker process 0.

Original Traceback (most recent call last):
  File "lib/python3.12/site-packages/monai/transforms/transform.py", line 141, in apply_transform
    return _apply_transform(transform, data, unpack_items, lazy, overrides, log_stats)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "//lib/python3.12/site-packages/monai/transforms/transform.py", line 98, in _apply_transform
    return transform(data, lazy=lazy) if isinstance(transform, LazyTrait) else transform(data)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/lib/python3.12/site-packages/monai/transforms/croppad/dictionary.py", line 168, in __call__
    d[key] = self.padder(d[key], mode=m, lazy=lazy_)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "lib/python3.12/site-packages/monai/transforms/croppad/array.py", line 161, in __call__
    to_pad_ = self.compute_pad_width(spatial_shape)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/lib/python3.12/site-packages/monai/transforms/croppad/array.py", line 231, in compute_pad_width
    spatial_size = fall_back_tuple(self.spatial_size, spatial_shape)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/lib/python3.12/site-packages/monai/utils/misc.py", line 277, in fall_back_tuple
    user = ensure_tuple_rep(user_provided, ndim)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/lib/python3.12/site-packages/monai/utils/misc.py", line 203, in ensure_tuple_rep
    raise ValueError(f"Sequence must have length {dim}, got {len(tup)}.")
ValueError: Sequence must have length 1, got 2.
babbu3682 commented 3 days ago

I apologize for the delayed response.

Regarding the form, I need to obtain full permission from the supervisor due to concerns related to personal information.

Would you be able to contact the corresponding author?

As for the dataloader, it appears that the dimensionality of the input data may not be appropriate. Could you please review it again?

EvelyneCalista commented 1 day ago

Thank you for your response, I have sent the email to corresponding author by 10/16.

About the dataloader, found that AddChanneld(keys=["n_20", "n_100"]),
has been deprecated, as I comment that line the error will occur as above after change that line into below line, the code can be run EnsureChannelFirstd(keys=["n_20", "n_100"], channel_dim="no_channel"),