lxztju / pytorch_classification

利用pytorch实现图像分类的一个完整的代码,训练,预测,TTA,模型融合,模型部署,cnn提取特征,svm或者随机森林等进行分类,模型蒸馏,一个完整的代码
MIT License
1.38k stars 339 forks source link

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

Open WangXH258 opened 3 years ago

WangXH258 commented 3 years ago

当自己尝试使用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 commented 3 years ago

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

bestfzy commented 2 years ago

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

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

HUMINTING commented 1 year ago

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