Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/opencv/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 3.x 蟒蛇3-';ValueError:没有足够的值来解包(预期为2,得到0)';_Python 3.x_Opencv_Image Processing_Jupyter Notebook_Anaconda - Fatal编程技术网

Python 3.x 蟒蛇3-';ValueError:没有足够的值来解包(预期为2,得到0)';

Python 3.x 蟒蛇3-';ValueError:没有足够的值来解包(预期为2,得到0)';,python-3.x,opencv,image-processing,jupyter-notebook,anaconda,Python 3.x,Opencv,Image Processing,Jupyter Notebook,Anaconda,我正在用Python 3和OpenCV在Windows上的Jupyter笔记本上编程。 我将遵循本教程: 但我得到了这个错误: ValueError:没有足够的值来解包(应为2,得到0) 发件人: --->15地址,标签=zip(*c) 这段代码应该列出我的图片并给它们贴上标签,但它不起作用。代码如下: from random import shuffle import glob shuffle_data = True # shuffle the addresses before saving

我正在用Python 3和OpenCV在Windows上的Jupyter笔记本上编程。 我将遵循本教程:

但我得到了这个错误:

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)):]```

这表明
c
为空。仔细检查你的数据。我猜你的图像文件夹路径是错误的,因此
addrs
是空的。嗯,在我的
Train
文件夹中有两个文件夹:
Cat
Dog
,其中有很多图像,我再次检查,只是为了确定。对,您的图像位于
../Train/Cat
../Train/Dog
中,但您在脚本中设置的路径是
../Train
,它不包含任何
*.jpg
文件。如果您想要所有子目录中的所有JPEG,那么要在脚本中设置的正确路径应该是
cat\u dog\u train\u path='my path/PetImages/train/*/*.jpg'
就是这样!非常感谢。