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: too many values to unpack (expected 2) #31

Open
WangXH258 opened this issue Apr 26, 2021 · 3 comments
Open

ValueError: too many values to unpack (expected 2) #31

WangXH258 opened this issue Apr 26, 2021 · 3 comments

Comments

@WangXH258
Copy link

当自己尝试使用resnet50或者moblienetv2时都会报如下错误:
Traceback (most recent call last): File "train.py", line 147, in <module> images, labels = next(batch_iterator) File "/home/xuhaowang/anaconda3/lib/python3.7/site-packages/torch/utils/data/dataloader.py", line 363, in __next__ data = self._next_data() File "/home/xuhaowang/anaconda3/lib/python3.7/site-packages/torch/utils/data/dataloader.py", line 403, in _next_data data = self._dataset_fetcher.fetch(index) # may raise StopIteration File "/home/xuhaowang/anaconda3/lib/python3.7/site-packages/torch/utils/data/_utils/fetch.py", line 44, in fetch data = [self.dataset[idx] for idx in possibly_batched_index] File "/home/xuhaowang/anaconda3/lib/python3.7/site-packages/torch/utils/data/_utils/fetch.py", line 44, in <listcomp> data = [self.dataset[idx] for idx in possibly_batched_index] File "/data/xuhaow/wordload/pytorch_classification-master/data/dataset.py", line 49, in __getitem__ img_path, label = self.imgs[index] ValueError: too many values to unpack (expected 2)
请问这种情况有人遇到过么,该如何解决

@xuan97916
Copy link

图片的文件名不能带有空格,去掉空格后问题解决

@bestfzy
Copy link

bestfzy commented Mar 29, 2022

图片的文件名不能带有空格,去掉空格后问题解决

您好,除了除去空格,还能有别的解决方法吗

@HUMINTING
Copy link

这个说明你的图片地址里面有空格,可以把图片地址空格去掉,或者在preprocess.py文件中的写入和self.imgs = list(map(lambda line: line.strip().split(" "), f))中换一个分隔符。

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