leeyeehoo / CSRNet-pytorch

CSRNet: Dilated Convolutional Neural Networks for Understanding the Highly Congested Scenes
642 stars 259 forks source link

Valuerror encountered in running make_dataset #16

Closed Leungfranklin closed 5 years ago

Leungfranklin commented 5 years ago

When I run the make_dataset, I encounter the error "ValueError: not enough values to unpack (expected 2, got 0)" as below

ValueError Traceback (most recent call last)

in () 8 if int(gt[i][1]) 10 k = gaussian_filter_density(k) 11 with h5py.File(img_path.replace('.jpg','.h5').replace('images','ground_truth'), 'w') as hf: 12 hf['density'] = k in gaussian_filter_density(gt) 10 leafsize = 2048 11 # build kdtree ---> 12 tree = scipy.spatial.KDTree(pts.copy(), leafsize=leafsize) 13 # query kdtree 14 distances, locations = tree.query(pts, k=4) ~/anaconda3/lib/python3.6/site-packages/scipy/spatial/kdtree.py in __init__(self, data, leafsize) 233 def __init__(self, data, leafsize=10): 234 self.data = np.asarray(data) --> 235 self.n, self.m = np.shape(self.data) 236 self.leafsize = int(leafsize) 237 if self.leafsize < 1: ValueError: not enough values to unpack (expected 2, got 0)
MSoulPlayer commented 5 years ago

@Leungfranklin When using python 3.6, 'zip()'returns a zip object and in python 2.7 'zip()' returns a list, so this line should be replaced. pts = np.array(zip(np.nonzero(gt)[1], np.nonzero(gt)[0])) to pts = np.array(list(zip(np.nonzero(gt)[1], np.nonzero(gt)[0])))

Leungfranklin commented 5 years ago

@MSoulPlayer Thanks, the issue has been resolved.