Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix the 'TypeError: slice indices must be integers ..' error #12

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ktolstikhin
Copy link

@ktolstikhin ktolstikhin commented Aug 31, 2017

Hi,

first of all, I'd like to thank you for publishing your work! It's highly appreciated. Please consider my PR which solves a TypeError exception when running your code under Python 3.5.2 on Ubuntu 16.04.2 LTS (x64) using the actual Caffe version (as for 2017). Here is the stack traceback of the error fired when trying to predict tags for an image:

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-52-ae252e72e7e6> in <module>()
----> 1 out = model.estimate_plausible_tags([img], threshold=0.5)

~/project/illustration2vec/i2v/base.py in estimate_plausible_tags(self, images, threshold, threshold_rule)
     93     def estimate_plausible_tags(
     94             self, images, threshold=0.25, threshold_rule='constant'):
---> 95         preds = self.estimate_top_tags(images, n_tag=512)
     96         result = []
     97         if threshold_rule == 'constant':

~/project/illustration2vec/i2v/base.py in estimate_top_tags(self, images, n_tag)
     50 
     51     def estimate_top_tags(self, images, n_tag=10):
---> 52         prob = self._estimate(images)
     53         general_prob = prob[:, :512]
     54         character_prob = prob[:, 512:1024]

~/project/illustration2vec/i2v/base.py in _estimate(self, images)
     40         assert(self.tags is not None)
     41         imgs = [self._convert_image(img) for img in images]
---> 42         prob = self._extract(imgs, layername='prob')
     43         prob = prob.reshape(prob.shape[0], -1)
     44         return prob

~/project/illustration2vec/i2v/caffe_i2v.py in _extract(self, inputs, layername)
     23         ])
---> 24         input_ = input_[:, crop[0]:crop[2], crop[1]:crop[3], :]
     25         # Classify
     26         caffe_in = np.zeros(

TypeError: slice indices must be integers or None or have an __index__ method

This small fix solves the problem :)

Again, thank you very much for this repo! I wish you nothing but success in your future work!

Cheers,
Konstantin.

@liechtym
Copy link

Thanks for this fix!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants