princeton-vl / pytorch_stacked_hourglass

Pytorch implementation of the ECCV 2016 paper "Stacked Hourglass Networks for Human Pose Estimation"
BSD 3-Clause "New" or "Revised" License
465 stars 94 forks source link

When I try to load your pretrain model, there is an error?! #26

Closed MINZLATAN closed 3 years ago

MINZLATAN commented 3 years ago

image

when I try to load your pretrain model, there is an error it is saying, 'Missing key(s) in state_dict : ......'
Do you know the solutions?

Thanks

NiranthS commented 3 years ago

Hello @Min12212121212 , where are you trying to load the state_dict? Are you using the 'continue_exp' in train.py or did you make your own script to load it. Also, can you share a picture of the full error showing which keys are causing the problem.

MINZLATAN commented 3 years ago

yes, I made my own script using your pretrained model (8HG) to show the pose estimation of single images.... something like this... image

so i tried to load your pretrained model but there was an error occurred. image

I think this is a simple issues. but i'm not familiar with using pytorch codes yet. so I can't find the solutions.....:(( anyway thank u so much and hope i can solve this problems asap....:)

MINZLATAN commented 3 years ago

and I have one more question, i implemented your 'test.py'. but i got the results like this.... image image image

I think this is the reason due to I didn't load your pretrained model(8HG) before I implement this 'test.py' ?! so If i want to see the PCK 0.5 results of your pretrained model. where should i load your pretrained model on your 'test.py' script or any other ways? cuz i couldn't find the right places for load your pretrained model on your 'test.py' script to see the PCK 0.5 results.

Thank you in advance....:))))

NiranthS commented 3 years ago

You can use a script like this to load weights:

my_model_state_dict = model.state_dict() 
count = 0
pretrained_weights = torch.load('checkpoint.pt' )
pretrained_weights_items = list(pretrained_weights.items())
for key,value in my_model_state_dict.items():
    layer_name, weights = pretrained_weights_items[count]
    my_model_state_dict[key] = weights
    print(count)
    print(layer_name)
    count += 1
model.load_state_dict(my_model_state_dict)

If you load stact_dict inside reload() function of train.py, then it works directly.

NiranthS commented 3 years ago

You can simply add an argument while running test.py to load a model.

python test.py -c pretrained_model

Here the pretrained_model folder should contain the checkpoint.pt file

MINZLATAN commented 3 years ago

Thanks for your answers and I tried to implement your 'train.py' and it is showed like this.... I think it is working....but is that an error which is shown as a '0%| | blah blah ~~' before the 'start train pose' and ' start valid pose' ?? image I can see the checkpoint is saved after every epoch is ended. and I can find the checkpoint file too. But not sure I'm doing right way or the problem is happening.

Thank u so much.

NiranthS commented 3 years ago

I am not sure why this is happening, maybe the authors of the repo can help.

NiranthS commented 3 years ago

Did you calculate the PCKh score of your custom trained model? If yes, what score are you getting?

MINZLATAN commented 3 years ago

not yet, cuz I don't finish the training yet. Just want to know can I ignore that words and keep training my model or not....

Thank u so much always...:)))

NiranthS commented 3 years ago

no problem. Do close the issue if your issue is solved

MINZLATAN commented 3 years ago

Thanks for your useful answers, so far...:))) But can you give me some advices for this? I want to load the pretrained model which is linked in this repo and visualizing the heatmaps and pose estimation of single images. image like this...

image and I tried the script that you mentioned but still can't sure what is the right way to define the model.

can you give me some advices for this or do you have any demo files which I can visualizing the heatmaps and pose estimations of single images using this pretrained model??

Thank you so much always....:))))

NiranthS commented 3 years ago

I did not understand what you meant by defining the model?

MINZLATAN commented 3 years ago

Simply, like do you know how to visualize the heatmaps and pose estimation of single images from this repo with using the pretrained model ??

Thank u so much....:))))

NiranthS commented 3 years ago

Were you able to make a script for visualization @MINZLATAN ?

crockwell commented 3 years ago

closing for inactivity