HOPE icon indicating copy to clipboard operation
HOPE copied to clipboard

Some weights and baises are missing in the graphunet pre-trained model

Open Almadani92 opened this issue 4 years ago • 10 comments

Hi bardiadoosti,

Thanks for updating the trained model and sharing it again. However, there are some missing weights in the shared model. I run the updated testing code and get the following error:

RuntimeError: Error(s) in loading state_dict for DataParallel: Missing key(s) in state_dict: "module.pool1.fc.weight", "module.pool1.fc.bias", "module.pool2.fc.weight", "module.pool2.fc.bias", "module.pool3.fc.weight", "module.pool3.fc.bias", "module.pool4.fc.weight", "module.pool4.fc.bias", "module.pool5.fc.weight", "module.pool5.fc.bias".

It seems to me that the pooling 1, 2, 3, 4, and 5 layers weights and biases are missing in the updated trained model. Please, let me know if I am wrong.

Thanks.

Almadani92 avatar Sep 27 '20 15:09 Almadani92

@Almadani92 Did you try this code, I replied to you in your comment previously.

if args.pretrained_model != '':
    loaded_model = torch.load(args.pretrained_model)
    resnet = {}
    graphnet = {}
    graphunet = {}
    for key, val in loaded_model.items():
        if 'resnet' in key:
            resnet[key.replace('module.resnet.', '')] = val
        if 'graphnet' in key:
            graphnet[key.replace('module.graphnet.', '')] = val
        if 'graphunet' in key:
            graphunet[key.replace('module.graphunet.', '')] = val
    model.resnet.load_state_dict(resnet)
    model.graphnet.load_state_dict(graphnet)
    model.graphunet.load_state_dict(graphunet)
    losses = np.load(args.pretrained_model[:-4] + '-losses.npy').tolist()
    start = len(losses)
else:
    losses = []
    start = 0

hedjm avatar Sep 27 '20 15:09 hedjm

@Almadani92 Did you try this code, I replied to you in your comment previously.

if args.pretrained_model != '':
    loaded_model = torch.load(args.pretrained_model)
    resnet = {}
    graphnet = {}
    graphunet = {}
    for key, val in loaded_model.items():
        if 'resnet' in key:
            resnet[key.replace('module.resnet.', '')] = val
        if 'graphnet' in key:
            graphnet[key.replace('module.graphnet.', '')] = val
        if 'graphunet' in key:
            graphunet[key.replace('module.graphunet.', '')] = val
    model.resnet.load_state_dict(resnet)
    model.graphnet.load_state_dict(graphnet)
    model.graphunet.load_state_dict(graphunet)
    losses = np.load(args.pretrained_model[:-4] + '-losses.npy').tolist()
    start = len(losses)
else:
    losses = []
    start = 0

Many thanks @hedjm,

Actually, it seems to me that really there are missing weights and biases for all pooling layers in the new pre-trained graphunet model. I run the code, unfortunately it didn't work.

Almadani92 avatar Sep 27 '20 16:09 Almadani92

Oh it seems that I mistakenly trained a wrong model. Please give me a couple of days and I will publish the correct weights.

bardiadoosti avatar Sep 28 '20 03:09 bardiadoosti

Oh it seems that I mistakenly trained a wrong model. Please give me a couple of days and I will publish the correct weights.

Many thanks @bardiadoosti for your efforts. Actually, it would be better if you publish the whole model weight parameters, I mean for the whole HopeNet model, not just for the GraphuNet, if it is possible.

Thanks in advance.

Almadani92 avatar Sep 28 '20 05:09 Almadani92

Dear @bardiadoosti ,

Thanks for posting the GraphUnet pre-trained model. However, could you please let me know how did you calculate the average error noted in the paper. Since I have calculated and found it equal to 20 mm for the test dataset.

Thanks.

Almadani92 avatar Oct 06 '20 15:10 Almadani92

Yes it is correct. To quickly share the weights I just trained for 2K iterations. The full training cycle is 10K.

bardiadoosti avatar Oct 07 '20 03:10 bardiadoosti

Thanks @bardiadoosti ,

I think the training code contains 5K training iterations with learning rate equal to 0.001. did you reduce the learning rate while you were training the new network, such that you have to train for 10K iterations? Also, did you change any other parameters while training the new network?

Thanks in advance.

Almadani92 avatar Oct 08 '20 09:10 Almadani92

Yes it is correct. To quickly share the weights I just trained for 2K iterations. The full training cycle is 10K. Dear @bardiadoosti , Thanks for posting the GraphUnet pre-trained model. However, do the rest model weight parameters remain the same as previous version? I am a little confused about the training strategy. Do you train the model end-to-end or just train the graphunet? Thanks in advance.

payne53 avatar Oct 12 '20 02:10 payne53

Yes it is correct. To quickly share the weights I just trained for 2K iterations. The full training cycle is 10K. Dear @bardiadoosti , Thanks for posting the GraphUnet pre-trained model. However, do the rest model weight parameters remain the same as previous version? I am a little confused about the training strategy. Do you train the model end-to-end or just train the graphunet? Thanks in advance.

Dear @payne53 the author posted the model corresponding to the last part of the whole Hopenet model, such that it contains the graphunet network (as it is shown in figure 3 in the paper). The input he used in the training is the predicted 2d points which can be extracted via the camera projection matrix, so he did not use the rgb images in this training.

However @bardiadoosti , I managed to train the whole Hopenet network using the code provided. I trained it for 10000 epochs. Unfortunately, I got an Average Error of 21.24 mm. Is the provided training code is the one you are using or there are some modifications.

Thanks and regards,

Murad.

Almadani92 avatar Oct 15 '20 12:10 Almadani92

Just wondering if there is any updates on this thread. Thanks

zc-alexfan avatar Mar 28 '21 11:03 zc-alexfan