heuritech / convnets-keras

MIT License
594 stars 185 forks source link

why can't I reproduce your result? #47

Open justttry opened 6 years ago

justttry commented 6 years ago

I followed the code:

` from keras.optimizers import SGD from convnetskeras.convnets import preprocess_image_batch, convnet from convnetskeras.imagenet_tool import synset_to_dfs_ids

im = preprocess_image_batch(['examples/dog.jpg'], color_mode="bgr")

sgd = SGD(lr=0.1, decay=1e-6, momentum=0.9, nesterov=True) model = convnet('alexnet',weights_path="weights/alexnet_weights.h5", heatmap=True) model.compile(optimizer=sgd, loss='mse')

out = model.predict(im)

s = "n02084071" ids = synset_to_dfs_ids(s) heatmap = out[0,ids].sum(axis=0)

import matplotlib.pyplot as plt plt.imsave("heatmap_dog.png",heatmap) `

and here is my keras.json:

{ "epsilon": 1e-07, "floatx": "float32", "image_data_format": "channels_first", "backend": "tensorflow" }

and the result:

heatmap_dog1

why? my result is size of 73x43, but yours is size of 74x44.

any suggestion?

JorgeRodri commented 6 years ago

I got exatcly the same results, but i dont know how to solve it.

justttry commented 6 years ago

@JorgeRodri try theano. Unfortunatelly, I have dropped this repo.

gabrieldemarmiesse commented 6 years ago

If I may do a bit of publicity for my repo, I used this one as based and improved on it. It's up to date, works with keras 2 and Theano, tensorflow and CNTK. You can also use other CNN like ResNet to get heatmaps.

https://github.com/gabrieldemarmiesse/heatmaps