heuritech / convnets-keras

MIT License
594 stars 185 forks source link

I cannot reproduce your results. #43

Open se210 opened 7 years ago

se210 commented 7 years ago

I have not been able to reproduce your results with the given example code. The heatmap probabilities and label confidence seems way too low. What were the versions and settings of Keras and Theano?

This is what I get on Keras 1.2.2 and Theano 0.9.0 by running the below script:

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

## AlexNet
im = preprocess_image_batch(['examples/dog.jpg'],img_size=(256,256), crop_size=(227,227), color_mode="rgb")

sgd = SGD(lr=0.1, decay=1e-6, momentum=0.9, nesterov=True)

## AlexNet
model = convnet('alexnet',weights_path="weights/alexnet_weights.h5", heatmap=False)

model.compile(optimizer=sgd, loss='mse')

out = model.predict(im)

# Image Classification
pprint_output(out[0])

My keras.json:

{
    "floatx": "float32",
    "image_dim_ordering": "th",
    "backend": "theano",
    "epsilon": 1e-07
}

Output:

10.33 : dingo, warrigal, warragal, Canis dingo
3.79 : cougar, puma, catamount, mountain lion, painter, panther, Felis concolor
3.63 : grey fox, gray fox, Urocyon cinereoargenteus
3.05 : red wolf, maned wolf, Canis rufus, Canis niger
2.98 : kit fox, Vulpes macrotis
2.95 : Eskimo dog, husky
2.65 : Siberian husky
2.64 : coyote, prairie wolf, brush wolf, Canis latrans
2.59 : timber wolf, grey wolf, gray wolf, Canis lupus
2.58 : red fox, Vulpes vulpes

Heatmap: Heatmap

agnesmm commented 7 years ago

Try to set heatmap to True instead of False: model = convnet('alexnet',weights_path="weights/alexnet_weights.h5", heatmap=True)

se210 commented 7 years ago

The heatmap was generated in a separate run where heatmap was set to True.

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