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

运行train时报错 #50

Open
ChrisZ-123 opened this issue Dec 28, 2023 · 3 comments
Open

运行train时报错 #50

ChrisZ-123 opened this issue Dec 28, 2023 · 3 comments

Comments

@ChrisZ-123
Copy link

ChrisZ-123 commented Dec 28, 2023

default_dtype() and torch.set_default_device() as alternatives. (Triggered internally at ..\torch\csrc\tensor\python_tensor.cpp:453.)
_C._set_default_tensor_type(t)
Traceback (most recent call last):
File "c:\Users\Lenovo\Desktop\Fatigue-Driven-Detection-Based-on-CNN-master\Train.py", line 111, in
train()
File "c:\Users\Lenovo\Desktop\Fatigue-Driven-Detection-Based-on-CNN-master\Train.py", line 84, in train
for step,(img,target) in enumerate(data_loader):
File "C:\Users\Lenovo\AppData\Roaming\Python\Python310\site-packages\torch\utils\data\dataloader.py", line 630, in next
data = self._next_data()
File "C:\Users\Lenovo\AppData\Roaming\Python\Python310\site-packages\torch\utils\data\dataloader.py", line 674, in _next_data
data = self._dataset_fetcher.fetch(index) # may raise StopIteration
File "C:\Users\Lenovo\AppData\Roaming\Python\Python310\site-packages\torch\utils\data_utils\fetch.py", line 51, in fetch
data = [self.dataset[idx] for idx in possibly_batched_index]
File "C:\Users\Lenovo\AppData\Roaming\Python\Python310\site-packages\torch\utils\data_utils\fetch.py", line 51, in
data = [self.dataset[idx] for idx in possibly_batched_index]
File "c:\Users\Lenovo\Desktop\Fatigue-Driven-Detection-Based-on-CNN-master\voc0712.py", line 111, in getitem
im, gt, h, w = self.pull_item(index)
File "c:\Users\Lenovo\Desktop\Fatigue-Driven-Detection-Based-on-CNN-master\voc0712.py", line 130, in pull_item
img, boxes, labels = self.transform(img, target[:, :4], target[:, 4])
File "c:\Users\Lenovo\Desktop\Fatigue-Driven-Detection-Based-on-CNN-master\augmentations.py", line 416, in call
return self.augment(img, boxes, labels)
File "c:\Users\Lenovo\Desktop\Fatigue-Driven-Detection-Based-on-CNN-master\augmentations.py", line 51, in call
img, boxes, labels = t(img, boxes, labels)
File "c:\Users\Lenovo\Desktop\Fatigue-Driven-Detection-Based-on-CNN-master\augmentations.py", line 237, in call
mode = random.choice(self.sample_options)
File "numpy\random\mtrand.pyx", line 936, 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.

@xiaozhang1017
Copy link

default_dtype() 和 torch.set_default_device() 作为替代方案。 (在 ..\torch\csrc\tensor\python_tensor.cpp:453 内部触发。) _C._set_default_tensor_type(t) 回溯(最近一次调用): 文件“c:\Users\Lenovo\Desktop\Fatigue-Driven-Detection -基于 CNN-master\Train.py”,第 111 行, train() 文件“c:\Users\Lenovo\Desktop\Fatigue-Driven-Detection-Based-on-CNN-master\Train.py” ,第 84 行,在 枚举(data_loader)中的步骤(img,目标)中: 文件“C:\ Users \ Lenovo \ AppData \ Roaming \ Python \ Python310 \ site-packages \ torch \ utils \ data \ dataloader.py ”,第 630 行,下一个 data = self._next_data() 文件“C:\Users\Lenovo\AppData\Roaming\Python\Python310\site-packages\torch\utils\data\dataloader.py”,第 674 行,在_next_data data = self._dataset_fetcher.fetch(index) # 可能会引发 StopIteration File "C:\Users\Lenovo\AppData\Roaming\Python\Python310\site-packages\torch\utils\data_utils\fetch.py​​", line 51,在 fetch data = [self.dataset[idx] for idx in possible_batched_index] 文件“C:\Users\Lenovo\AppData\Roaming\Python\Python310\site-packages\torch\utils\data_utils\fetch.py​​”,第 51 行,在 data = [self.dataset[idx] for idx in possible_batched_index] 文件“c:\Users\Lenovo\Desktop\Fatigue-Driven-Detection-Based-on-CNN-master\voc0712.py”,第 111 行,在getitem im, gt, h, w = self.pull_item(index) 文件“c:\Users\Lenovo\Desktop\Fatigue-Driven-Detection-Based-on-CNN-master\voc0712.py”,第 130 行,在 pull_item 中 img, box, labels = self.transform(img, target[:, :4], target[:, 4]) 文件“c:\Users\Lenovo\Desktop\Fatigue-Driven-Detection-Based-on-CNN- master\augmentations.py”,第 416 行,调用中 返回 self.augment(img,boxes, labels) 文件“c:\Users\Lenovo\Desktop\Fatigue-Driven-Detection-Based-on-CNN-master\augmentations. py”,第 51 行,调用img ,boxes, labels = t(img,boxes,labels) 文件“c:\Users\Lenovo\Desktop\Fatigue-Driven-Detection-Based-on-CNN-master\augmentations.py ”,第 237 行,在调用 模式 = random.choice(self.sample_options) 文件“numpy\random\mtrand.pyx”,第 936 行,在 numpy.random.mtrand.RandomState.choice ValueError:用序列设置数组元素。请求的数组在 1 维之后具有不均匀的形状。检测到的形状为(6,)+不均匀部分。

@ChrisZ-123 我也有这个问题,你是否已经成功解决了?
0%IJ9BILG8IKJ{F{1VIPGO1

@xiaozhang1017
Copy link

default_dtype() 和 torch.set_default_device() 作为替代方案。 (在 ..\torch\csrc\tensor\python_tensor.cpp:453 内部触发。) _C._set_default_tensor_type(t) 回溯(最近一次调用): 文件“c:\Users\Lenovo\Desktop\Fatigue-Driven-Detection -基于 CNN-master\Train.py”,第 111 行, train() 文件“c:\Users\Lenovo\Desktop\Fatigue-Driven-Detection-Based-on-CNN-master\Train.py” ,第 84 行,在 枚举(data_loader)中的步骤(img,目标)中: 文件“C:\ Users \ Lenovo \ AppData \ Roaming \ Python \ Python310 \ site-packages \ torch \ utils \ data \ dataloader.py ”,第 630 行,下一个 data = self._next_data() 文件“C:\Users\Lenovo\AppData\Roaming\Python\Python310\site-packages\torch\utils\data\dataloader.py”,第 674 行,在_next_data data = self._dataset_fetcher.fetch(index) # 可能会引发 StopIteration File "C:\Users\Lenovo\AppData\Roaming\Python\Python310\site-packages\torch\utils\data_utils\fetch.py​​", line 51,在 fetch data = [self.dataset[idx] for idx in possible_batched_index] 文件“C:\Users\Lenovo\AppData\Roaming\Python\Python310\site-packages\torch\utils\data_utils\fetch.py​​”,第 51 行,在 data = [self.dataset[idx] for idx in possible_batched_index] 文件“c:\Users\Lenovo\Desktop\Fatigue-Driven-Detection-Based-on-CNN-master\voc0712.py”,第 111 行,在getitem im, gt, h, w = self.pull_item(index) 文件“c:\Users\Lenovo\Desktop\Fatigue-Driven-Detection-Based-on-CNN-master\voc0712.py”,第 130 行,在 pull_item 中 img, box, labels = self.transform(img, target[:, :4], target[:, 4]) 文件“c:\Users\Lenovo\Desktop\Fatigue-Driven-Detection-Based-on-CNN- master\augmentations.py”,第 416 行,调用中 返回 self.augment(img,boxes, labels) 文件“c:\Users\Lenovo\Desktop\Fatigue-Driven-Detection-Based-on-CNN-master\augmentations. py”,第 51 行,调用img ,boxes, labels = t(img,boxes,labels) 文件“c:\Users\Lenovo\Desktop\Fatigue-Driven-Detection-Based-on-CNN-master\augmentations.py ”,第 237 行,在调用 模式 = random.choice(self.sample_options) 文件“numpy\random\mtrand.pyx”,第 936 行,在 numpy.random.mtrand.RandomState.choice ValueError:用序列设置数组元素。请求的数组在 1 维之后具有不均匀的形状。检测到的形状为(6,)+不均匀部分。

@ChrisZ-123 我也有这个问题,你是否已经成功解决了? 0%IJ9BILG8IKJ{F{1VIPGO1

我发现报错是numpy版本问题。
解决办法:
卸载现有版本numpy,安装numpy 1.21.0(python 3.6)版本或者1.23.5(python 3.11)
pip install numpy==1.21.0或者pip install numpy==1.23.5

@Yunone1
Copy link

Yunone1 commented Apr 30, 2024

D:\Anaconda3\envs\tensorflow-gpu\python.exe D:\mybs\Fatigue-Driven-Detection-Based-on-CNN-master\Train.py
Traceback (most recent call last):
File "D:\mybs\Fatigue-Driven-Detection-Based-on-CNN-master\Train.py", line 111, in
train()
File "D:\mybs\Fatigue-Driven-Detection-Based-on-CNN-master\Train.py", line 61, in train
Config.MEANS))
File "D:\mybs\Fatigue-Driven-Detection-Based-on-CNN-master\voc0712.py", line 107, in init
for line in open(osp.join(rootpath, 'ImageSets', 'Main', name + '.txt')):
FileNotFoundError: [Errno 2] No such file or directory: './dataset/ImageSets\Main\trainval.txt'

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

3 participants