richzhang / colorization

Automatic colorization using deep neural networks. "Colorful Image Colorization." In ECCV, 2016.
http://richzhang.github.io/colorization/
BSD 2-Clause "Simplified" License
3.35k stars 928 forks source link

possible SciKit Learn version issue #26

Closed AruniRC closed 6 years ago

AruniRC commented 7 years ago

When training the network from scratch using ./train/train_model.sh 0, the following error happens at the "Solving LtoAB" step of the training:

caffe_traininglayers.py", line 331, in encode_points_mtx_nd
    (dists,inds) = self.nbrs.kneighbors(pts_flt)

....

  File "sklearn/neighbors/binary_tree.pxi", line 1309, in sklearn.neighbors.ball_tree.BinaryTree.query (sklearn/neighbors/ball_tree.c:11514)
  File "sklearn/neighbors/binary_tree.pxi", line 587, in sklearn.neighbors.ball_tree.NeighborsHeap.__init__ (sklearn/neighbors/ball_tree.c:5582)
TypeError: 'float' object cannot be interpreted as an index

The data pts_flt is a float32 numpy ndarray. Could this be due to a version problem in sklearn itself (I am using 0.18.1)? Please let me know what version of scikit is used for this codebase and I'll match that and try training again.

thanks, Aruni

AruniRC commented 7 years ago

Issue solved:

In colorization/resources/caffe_traininglayers.py, the original line was

self.nbrs = nn.NearestNeighbors(n_neighbors=NN, algorithm='ball_tree').fit(self.cc)

This would cause n_neighbors to be 10.0 and not 10, which leads to the indexing error. I believe later versions of numpy and sklearn have become more strict about not allowing index variables to be integer-valued float dtypes. n_neighbors=NN shold read n_neighbors=self.NN.

That line should be changed to:

self.nbrs = nn.NearestNeighbors(n_neighbors=self.NN, algorithm='ball_tree').fit(self.cc)

Hope this helps anyone else with this issue.

crazyzsy commented 7 years ago

Thank you ,I solved.

youyingyin commented 6 years ago

@AruniRC oh man you save me!thank you so much!