Comments (17)
Hi!
Thanks for reporting me all this! The memory error isn't surprising as the vgg16 is around 400MB already but models like onception are more around 100MB. I will look at the other models you mentioned this weekend and see why it didn't work out.
from heatmaps.
Looking forward to hear back from you.
from heatmaps.
Hi!
I just pushed a fix for the resnet. I tested it with tensorflow but it should also work with Theano. I'm going to look into the other networks. Please keep me updated if you find any issue.
from heatmaps.
I pushed the fix for densenet and inception. Mobilenet isn't working yet.
from heatmaps.
Hi!
Thanks you so much. I just reinstalled the package and ResNet50 worked well with Theano. This however was not the case with Tensorflow as I receive the following error:
Model type detected: local pooling - flatten
Traceback (most recent call last):
File "demo.py", line 39, in <module>
new_model = to_heatmap(model)
File "/home/abdu/anaconda2/envs/tensorflowGpu/heatmaps/heatmap/heatmap.py", line 234, in to_heatmap
x = middle_model(img_input)
File "/home/abdu/anaconda2/envs/tensorflowGpu/lib/python2.7/site-packages/keras/engine/topology.py", line 617, in __call__
output = self.call(inputs, **kwargs)
File "/home/abdu/anaconda2/envs/tensorflowGpu/lib/python2.7/site-packages/keras/engine/topology.py", line 2078, in call
output_tensors, _, _ = self.run_internal_graph(inputs, masks)
File "/home/abdu/anaconda2/envs/tensorflowGpu/lib/python2.7/site-packages/keras/engine/topology.py", line 2229, in run_internal_graph
output_tensors = _to_list(layer.call(computed_tensor, **kwargs))
File "/home/abdu/anaconda2/envs/tensorflowGpu/lib/python2.7/site-packages/keras/layers/normalization.py", line 185, in call
self.momentum),
File "/home/abdu/anaconda2/envs/tensorflowGpu/lib/python2.7/site-packages/keras/backend/tensorflow_backend.py", line 1001, in moving_average_update
x, value, momentum, zero_debias=True)
File "/home/abdu/anaconda2/envs/tensorflowGpu/lib/python2.7/site-packages/tensorflow/python/training/moving_averages.py", line 70, in assign_moving_average
update_delta = _zero_debias(variable, value, decay)
File "/home/abdu/anaconda2/envs/tensorflowGpu/lib/python2.7/site-packages/tensorflow/python/training/moving_averages.py", line 180, in _zero_debias
"biased", initializer=biased_initializer, trainable=False)
File "/home/abdu/anaconda2/envs/tensorflowGpu/lib/python2.7/site-packages/tensorflow/python/ops/variable_scope.py", line 1065, in get_variable
use_resource=use_resource, custom_getter=custom_getter)
File "/home/abdu/anaconda2/envs/tensorflowGpu/lib/python2.7/site-packages/tensorflow/python/ops/variable_scope.py", line 962, in get_variable
use_resource=use_resource, custom_getter=custom_getter)
File "/home/abdu/anaconda2/envs/tensorflowGpu/lib/python2.7/site-packages/tensorflow/python/ops/variable_scope.py", line 367, in get_variable
validate_shape=validate_shape, use_resource=use_resource)
File "/home/abdu/anaconda2/envs/tensorflowGpu/lib/python2.7/site-packages/tensorflow/python/ops/variable_scope.py", line 352, in _true_getter
use_resource=use_resource)
File "/home/abdu/anaconda2/envs/tensorflowGpu/lib/python2.7/site-packages/tensorflow/python/ops/variable_scope.py", line 664, in _get_single_variable
name, "".join(traceback.format_list(tb))))
ValueError: Variable bn_conv1/moving_mean/biased already exists, disallowed. Did you mean to set reuse=True in VarScope? Originally defined at:
File "/home/abdu/anaconda2/envs/tensorflowGpu/lib/python2.7/site-packages/keras/backend/tensorflow_backend.py", line 1001, in moving_average_update
x, value, momentum, zero_debias=True)
File "/home/abdu/anaconda2/envs/tensorflowGpu/lib/python2.7/site-packages/keras/layers/normalization.py", line 185, in call
self.momentum),
File "/home/abdu/anaconda2/envs/tensorflowGpu/lib/python2.7/site-packages/keras/engine/topology.py", line 617, in __call__
output = self.call(inputs, **kwargs)
You should know that I am using tensorflow gpu. I will go a head and test the rest.
Thanks
from heatmaps.
Thanks for that. You can run the tests/test.py
to check what is working on your end and what is not. I use tensorflow cpu for testing but I don't think it has any influence. Anyway, I don't think I can fix a bug that I can't reproduce sadly. Keep me updated. Maybe I'll understand how to fix it.
from heatmaps.
Okay. I just finished testing denenet and inception using theano backend and they both work poorly on demo.py with the dog class. See comparison below:
DenseNet121
This is worrying because the class is definitely being recognized as a dog. Here is the output from DenseNet
Using Theano backend.
('Predicted:', [(u'n02113023', u'Pembroke', 0.51888126), (u'n02109961', u'Eskimo_dog', 0.18552731), (u'n02110185', u'Siberian_husky', 0.12073633)])
I will test tensorflow and let you know how it ended.
from heatmaps.
I just had this error, you need to change the preprocessing.
from heatmaps.
For example, if you want to try with inception resnet, you need to change the preprocessing like this:
import matplotlib.pyplot as plt
import numpy as np
from keras.applications.inception_resnet_v2 import preprocess_input
from keras.applications import *
from keras.preprocessing import image
from keras import backend as K
from heatmap import synset_to_dfs_ids
from heatmap import to_heatmap
def display_heatmap(new_model, img_path, ids, preprocessing=None):
# The quality is reduced.
# If you have more than 8GB of RAM, you can try to increase it.
img = image.load_img(img_path, target_size=(800, 1280))
x = image.img_to_array(img)
x = np.expand_dims(x, axis=0)
if preprocessing is not None:
x = preprocess_input(x)
out = new_model.predict(x)
heatmap = out[0] # Removing batch axis.
if K.image_data_format() == 'channels_first':
heatmap = heatmap[ids]
if heatmap.ndim == 3:
heatmap = np.sum(heatmap, axis=0)
else:
heatmap = heatmap[:, :, ids]
if heatmap.ndim == 3:
heatmap = np.sum(heatmap, axis=2)
plt.imshow(heatmap, interpolation="none")
plt.show()
model = InceptionResNetV2()
new_model = to_heatmap(model)
s = "n02084071" # Imagenet code for "dog"
ids = synset_to_dfs_ids(s)
display_heatmap(new_model, "./dog.jpg", ids, preprocess_input)
You just have to import the preprocessing from the module from which the model comes from.
from heatmaps.
In regard to tensorflow, all except VGG16 broke down with the same error as before. My guess is that my environment in a weird state. I will test a different environment and see if things changes. Really surprise that classifying work however.
from heatmaps.
I just pushed the fix for mobilenets. All was tested under tensorflow cpu - python 3.6. But since keras is very good at hiding the backends, I'm pretty sure it should work for Theano and tensorflow-gpu too.
from heatmaps.
Indeed it's possible that there is there is a problem in your environnement. Maybe update tensorflow? It's just a wild guess.
from heatmaps.
can you give me the output of a pip freeze
?
from heatmaps.
First thing first, I really appreciate your help. Just finished testing all models on tensorflow cpu environment and everything worked well. Also, changing the preprocessing fixed the issue of the poor heatmap. As for the tensorflow gpu environment, below is the output of pip freeze:
(tensorflowGpu) abdu@abdu-Default-string:~/anaconda2/envs/tensorflowGpu$ pip freeze
attrs==17.4.0
backports-abc==0.5
backports.functools-lru-cache==1.5
backports.ssl-match-hostname==3.5.0.1
backports.weakref==1.0rc1
bleach==1.5.0
certifi==2016.2.28
cycler==0.10.0
funcsigs==1.0.2
functools32==3.2.3.post2
h5py==2.7.1
html5lib==0.9999999
Keras==2.1.3
-e git+https://github.com/gabrieldemarmiesse/heatmaps.git@415b6cc19d8d71aaf647bb3a36b903f4f6bbda06#egg=Keras_to_heatmaps
Markdown==2.2.0
matplotlib==2.1.1
mock==2.0.0
numpy==1.14.0
pbr==3.1.1
Pillow==5.0.0
pluggy==0.6.0
protobuf==3.5.1
py==1.5.2
pycairo==1.10.0
pyparsing==2.2.0
pytest==3.4.1
python-dateutil==2.6.1
pytz==2017.3
PyYAML==3.12
scipy==1.0.0
singledispatch==3.4.0.3
six==1.11.0
subprocess32==3.2.7
tensorflow-gpu==1.2.0
tornado==4.5.3
Werkzeug==0.14.1
I will try to reinstall tensorflow gpu and let you know how did it go.
from heatmaps.
Tensorflow is right now at version 1.6. Yours is at 1.2. Maybe this is the issue.
from heatmaps.
That is probably why. This will take forever to fix as I need to update all dependency. I will let you know how it turned out when I fix everything. Thanks for the help.
from heatmaps.
I'm glad to help, and thanks for reporting the bugs!
from heatmaps.
Related Issues (15)
- regarding using a dataset of different domain HOT 6
- AttributeError: 'Model' object has no attribute 'name' HOT 5
- Error using own Model with non-quadratic images HOT 3
- Unexpected Type Error while using a custom model HOT 5
- can it be used to grey-level imageset network? HOT 2
- to_heatmap function error HOT 2
- KeyError: 'Strides' With Custom Model HOT 1
- Example not working: NameError: name 'preprocess_input' is not defined HOT 5
- regarding re-train the VGG19 model HOT 5
- Update to Keras 2 HOT 4
- Usign the code on your own model HOT 32
- sigmoid outputs? HOT 2
- Issues with target size HOT 5
- why must you replace softmax by softmax4D HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from heatmaps.