Skip to content

Dataset __len__ bug: ValueError due to ambiguous array comparison during training #190

@thucdangvan020999

Description

@thucdangvan020999

When running the training script, the dataloader crashes because the dataset’s len function performs an invalid comparison between a NumPy array and an integer. This results in the following error:

/home/thucdv/.local/lib/python3.10/site-packages/torchvision/models/_utils.py:208: UserWarning: The parameter 'pretrained' is deprecated since 0.13 and may be removed in the future, please use 'weights' instead.
  warnings.warn(
/home/thucdv/.local/lib/python3.10/site-packages/torchvision/models/_utils.py:223: UserWarning: Arguments other than a weight enum or `None` for 'weights' are deprecated since 0.13 and may be removed in the future. The current behavior is equivalent to passing `weights=VGG19_Weights.IMAGENET1K_V1`. You can also use `weights=VGG19_Weights.DEFAULT` to get the most up-to-date weights.
  warnings.warn(msg)
Traceback (most recent call last):
  File "/home/thucdv/Desktop/server/voice_agent_lip_sync/Ultralight-Digital-Human/train.py", line 142, in <module>
    train(net, args.epochs, args.batchsize, args.lr)
  File "/home/thucdv/Desktop/server/voice_agent_lip_sync/Ultralight-Digital-Human/train.py", line 84, in train
    train_dataloader = DataLoader(dataset, batch_size=16, shuffle=True, drop_last=False, num_workers=4)
  File "/home/thucdv/.local/lib/python3.10/site-packages/torch/utils/data/dataloader.py", line 388, in __init__
    sampler = RandomSampler(dataset, generator=generator)  # type: ignore[arg-type]
  File "/home/thucdv/.local/lib/python3.10/site-packages/torch/utils/data/sampler.py", line 161, in __init__
    if not isinstance(self.num_samples, int) or self.num_samples <= 0:
  File "/home/thucdv/.local/lib/python3.10/site-packages/torch/utils/data/sampler.py", line 170, in num_samples
    return len(self.data_source)
  File "/home/thucdv/Desktop/server/voice_agent_lip_sync/Ultralight-Digital-Human/datasetsss.py", line 34, in __len__
    return self.audio_feats.shape[0] if self.audio_feats[0]<len(self.img_path_list) else len(self.img_path_list)
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()

Command used

python train.py --dataset_dir voice_agent_lip_sync --save_dir ./checkpoint/ --asr hubert

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions