raghakot / keras-vis

Neural network visualization toolkit for keras
https://raghakot.github.io/keras-vis
MIT License
2.98k stars 664 forks source link

Is the README demo working? #77

Open Fchaubard opened 6 years ago

Fchaubard commented 6 years ago

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](https://www.tensorflow.org/get_started/os_setup). - [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).
raghakot commented 6 years ago

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

ProgramItUp commented 6 years ago

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

kbagga commented 6 years ago

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

awilliamson commented 6 years ago

@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.