Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ValueError: setting an array element with a sequence. The requested array has an inhomogeneous shape after 1 dimensions. The detected shape was (6,) + inhomogeneous part. #589

Open
jingchengQF opened this issue May 16, 2023 · 4 comments

Comments

@jingchengQF
Copy link

(yolo) E:\download\anaconda\envs\ssd.pytorch-master>python train.py
E:\download\anaconda\envs\ssd.pytorch-master\ssd.py:34: UserWarning: volatile was removed and now has no effect. Use with torch.no_grad(): instead.
self.priors = Variable(self.priorbox.forward(), volatile=True)
Loading base network...
Initializing weights...
E:\download\anaconda\envs\ssd.pytorch-master\train.py:218: UserWarning: nn.init.xavier_uniform is now deprecated in favor of nn.init.xavier_uniform_.
init.xavier_uniform(param)
Loading the dataset...
Training SSD on: VOC0712
Using the specified args:
Namespace(dataset='VOC', dataset_root='E:/download/anaconda/envs/ssd.pytorch-master/data/VOCdevkit/', basenet='vgg16_reducedfc.pth', batch_size=32, resume=None, start_iter=0, num_workers=4, cuda=True, lr=0.001, momentum=0.9, weight_decay=0.0005, gamma=0.1, visdom=False, save_folder='weights/')
Traceback (most recent call last):
File "E:\download\anaconda\envs\ssd.pytorch-master\train.py", line 259, in
train()
File "E:\download\anaconda\envs\ssd.pytorch-master\train.py", line 169, in train
images, targets = next(batch_iterator)
File "E:\download\anaconda\envs\yolo\lib\site-packages\torch\utils\data\dataloader.py", line 633, in next
data = self._next_data()
File "E:\download\anaconda\envs\yolo\lib\site-packages\torch\utils\data\dataloader.py", line 1345, in _next_data
return self._process_data(data)
File "E:\download\anaconda\envs\yolo\lib\site-packages\torch\utils\data\dataloader.py", line 1371, in _process_data
data.reraise()
File "E:\download\anaconda\envs\yolo\lib\site-packages\torch_utils.py", line 644, in reraise
raise exception
ValueError: Caught ValueError in DataLoader worker process 0.
Original Traceback (most recent call last):
File "E:\download\anaconda\envs\yolo\lib\site-packages\torch\utils\data_utils\worker.py", line 308, in _worker_loop
data = fetcher.fetch(index)
File "E:\download\anaconda\envs\yolo\lib\site-packages\torch\utils\data_utils\fetch.py", line 51, in fetch
data = [self.dataset[idx] for idx in possibly_batched_index]
File "E:\download\anaconda\envs\yolo\lib\site-packages\torch\utils\data_utils\fetch.py", line 51, in
data = [self.dataset[idx] for idx in possibly_batched_index]
File "E:\download\anaconda\envs\ssd.pytorch-master\data\voc0712.py", line 115, in getitem
im, gt, h, w = self.pull_item(index)
File "E:\download\anaconda\envs\ssd.pytorch-master\data\voc0712.py", line 134, in pull_item
img, boxes, labels = self.transform(img, target[:, :4], target[:, 4])
File "E:\download\anaconda\envs\ssd.pytorch-master\utils\augmentations.py", line 417, in call
return self.augment(img, boxes, labels)
File "E:\download\anaconda\envs\ssd.pytorch-master\utils\augmentations.py", line 52, in call
img, boxes, labels = t(img, boxes, labels)
File "E:\download\anaconda\envs\ssd.pytorch-master\utils\augmentations.py", line 238, in call
mode = random.choice(self.sample_options)
File "mtrand.pyx", line 920, in numpy.random.mtrand.RandomState.choice
ValueError: setting an array element with a sequence. The requested array has an inhomogeneous shape after 1 dimensions. The detected shape was (6,) + inhomogeneous part.

for all the code ,I change three place
one and two is the way of file
COCO_ROOT = osp.join('E:/download/anaconda/envs/ssd.pytorch-master/data/coco/') in coco.py
VOC_ROOT = osp.join("E:/download/anaconda/envs/ssd.pytorch-master/data/VOCdevkit/") in VOC0721.py
three is in train.py for the error (RuntimeError: Expected a 'cuda' device type for generator but found 'cpu')
# data_loader = data.DataLoader(dataset, args.batch_size,
# num_workers=args.num_workers,
# shuffle=True, collate_fn=detection_collate,
# pin_memory=True)
data_loader = data.DataLoader(dataset, args.batch_size,
num_workers=args.num_workers,
shuffle=True, collate_fn=detection_collate,
pin_memory=True, generator=torch.Generator(device='cuda'))
that's all.I think I didn't change any parameter.

@sonukiller
Copy link

Downgrading numpy solved the issue for me
pip install numpy==1.21.6

@yfpeople
Copy link

did you solve this?

@elcolie
Copy link

elcolie commented Aug 31, 2023

@jingchengQF @sonukiller
I am facing the same issue. How did you solve this problem?

@elcolie
Copy link

elcolie commented Aug 31, 2023

Found the solution. #587

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants