Python3-'ValueError:没有足够的值可解包(预期2,得到0)'

时间:2019-10-30 18:11:33

标签: python-3.x opencv image-processing jupyter-notebook anaconda

我正在Windows的Jupyter Notebook上使用Python 3和OpenCV进行编程。 我正在关注本教程:http://machinelearninguru.com/deep_learning/data_preparation/hdf5/hdf5.html

但是我得到这个错误:

  

ValueError:没有足够的值可解包(预期2,得到0)

发件人:

  

---> 15个地址,标签= zip(* c)

此代码应列出我的图像并为它们添加标签,但它将无法正常工作。这是代码:

from random import shuffle
import glob
shuffle_data = True  # shuffle the addresses before saving
hdf5_path = 'my path/PetImages/dataset.hdf5'  # address to where you want to save the hdf5 file
cat_dog_train_path = 'my path/PetImages/Train/*.jpg'
addrs = glob.glob(cat_dog_train_path)
labels = [0 if 'cat' in addr else 1 for addr in addrs]  # 0 = Cat, 1 = Dog
# to shuffle data
if shuffle_data:
    c = list(zip(addrs, labels))
    shuffle(c)
    addrs, labels = zip(*c)

# Divide the hata into 60% train, 20% validation, and 20% test
train_addrs = addrs[0:int(0.6*len(addrs))]
train_labels = labels[0:int(0.6*len(labels))]
val_addrs = addrs[int(0.6*len(addrs)):int(0.8*len(addrs))]
val_labels = labels[int(0.6*len(addrs)):int(0.8*len(addrs))]
test_addrs = addrs[int(0.8*len(addrs)):]
test_labels = labels[int(0.8*len(labels)):]```

0 个答案:

没有答案