axon-research/c3d-keras

Have you tried the newly released C3D v1.1?

Closed this issue · 1 comments

Hi @chuckcho
I have successfully converted C3D v1.0 model to keras(with theano backend) follow https://gist.github.com/albertomontesg/d8b21a179c1e6cca0480ebdf292c34d2

For C3D v1.1,
First, I extracted caffe weights to h5 file following the codes which were used to convert ResNet50 to keras
https://github.com/MoyanZitto/keras-scripts/blob/master/utils/caffe_converter.py (tensorflow backend, I am also using tf backend now).
Second, load weight using

def load_weights(model, weights_path):
    """
    This function load the pretrained weights to the model
    """
    f = h5py.File(weights_path, 'r')
    for layer in model.layers:
        if layer.name[:3] == 'res':
            layer.set_weights([f[layer.name]['weights'][:].transpose((2,3,4,1,0)), f[layer.name]['bias'][:]])
        elif layer.name[:2] == 'bn':
            scale_name = 'scale'+layer.name[2:]
            weights = []
            weights.append(f[scale_name]['weights'][:])
            weights.append(f[scale_name]['bias'][:])
            weights.append(f[layer.name]['weights'][:])
            weights.append(f[layer.name]['bias'][:])
            layer.set_weights(weights)
    model.get_layer('conv1').set_weights([f['conv1']['weights'][:].transpose((2,3,4,1,0)), f['conv1']['bias'][:]])
    model.get_layer('fc8-new').set_weights([f['fc8-new']['weights'][:].T, f['fc8-new']['bias'][:]])
    return model
model = get_resC3D_k2()#keras model architecture
model = load_weights(model, 'c3d_resnet50-1.h5')

But keras model using the converted weights always output one class whatever the input is.
Can you give me some suggestions?

Sorry -- didn't have a chance to dig into this. I didn't have a chance to play with C3D v1.1. And, this issue appears not too relevant for this repo. So, closing.