keras-vis icon indicating copy to clipboard operation
keras-vis copied to clipboard

Is the README demo working?

Open Fchaubard opened this issue 7 years ago • 4 comments

The intro demo in your readme doesn't work.

  1. There is no module named modifications.. you have to do: from vis.input_modifiers import Jitter
  2. VGG16 is not imported the way you say: from keras.applications.vgg16 import VGG16 works
  3. imageio is not installed in the requirements
  4. even then, after fixing these, you still can not run it.. you get this issue:

No handlers could be found for logger "vis.utils.utils"

TypeError Traceback (most recent call last) in () 23 ] 24 opt = Optimizer(model.input, losses) ---> 25 opt.minimize(max_iter=500, verbose=True, callbacks=[GifGenerator('opt_progress')])

/python2.7/site-packages/vis/optimizer.pyc in minimize(self, seed_input, max_iter, input_modifiers, grad_modifier, callbacks, verbose) 156 # Trigger callbacks 157 for c in callbacks: --> 158 c.callback(i, named_losses, overall_loss, grads, wrt_value) 159 160 # Gradient descent update.

/python2.7/site-packages/vis/callbacks.pyc in callback(self, i, named_losses, overall_loss, grads, wrt_value) 60 def callback(self, i, named_losses, overall_loss, grads, wrt_value): 61 img = utils.deprocess_input(wrt_value[0]) ---> 62 img = utils.draw_text(img, "Step {}".format(i + 1)) 63 self.writer.append_data(img) 64

/python2.7/site-packages/vis/utils/utils.pyc in draw_text(img, text, position, font, font_size, color) 294 295 # Don't mutate original image --> 296 img = Image.fromarray(img) 297 draw = ImageDraw.Draw(img) 298 draw.text(position, text, fill=color, font=font)

/python2.7/site-packages/PIL/Image.pyc in fromarray(obj, mode) 2196 except KeyError: 2197 # print(typekey) -> 2198 raise TypeError("Cannot handle this data type") 2199 else: 2200 rawmode = mode

TypeError: Cannot handle this data type

  • [x] Check that you are up-to-date with the master branch of keras-vis. You can update with: pip install git+git://github.com/raghakot/keras-vis.git --upgrade --no-deps

  • [x] If running on TensorFlow, check that you are up-to-date with the latest version. The installation instructions can be found here.

  • [x] If running on Theano, check that you are up-to-date with the master branch of Theano. You can update with: pip install git+git://github.com/Theano/Theano.git --upgrade --no-deps

  • [x] Provide a link to a GitHub Gist of a Python script that can reproduce your issue (or just copy the script here if it is short).

Fchaubard avatar Oct 01 '17 15:10 Fchaubard

I have to fix the Readme. For now, the notebook examples are more reliable and correct. I will definitely fix it this weekend.

raghakot avatar Oct 05 '17 18:10 raghakot

@raghakot Nice visualizations! Just curious if you were able to fix the broken parts and get everything working?

ProgramItUp avatar Oct 19 '17 10:10 ProgramItUp

replace 'img = Image.fromarray(img)' with 'img = Image.fromarray(img.astype('uint8'))' to solve your error

kbagga avatar May 30 '18 05:05 kbagga

@raghakot This probably deserves it's own section, as this completely breaks the GifGenerator. As when adding text the PIL types don't like up (1,1,3) with any float types. Definitely frustrating trying to adopt some keras-vis to existing projects, a lot less hassle just doing K.function manually tbh.

awilliamson avatar Jul 31 '18 13:07 awilliamson