boostcampaitech5/level3_cv_finalproject-cv-07

Where is the pretrained model?

Closed this issue · 4 comments

I wanna use the pretrained model to have a test on my exist video.
Where can i get the pretrained model

Thank you for your interest in our project :)

Also, I checked the email you sent me.
According to your email, it is confirmed that the following error occurs.

Traceback (most recent call last):
 File "~/re_id/tools/train.py", line 219, in <module>
  model.load_state_dict(torch.load(os.path.join("../model_weights", "mobilenetv3_best.pth")))

...

RuntimeError: Error(s) in loading state_dict for MobileNetV3:
 Missing key(s) in state_dict: "mobilenetv3.conv_stem.weight", ...

It seems that the error occurred because you used a multi-GPU.
If you used multi-GPU, you can refer to Solution A
If not, refer to Solution B
Nevertheless, if the problem is not solved, please leave an email address and I will send you the pth file.

Solution A

  1. Modify model.state_dict() in line 287, 291 to model.module.state_dict()

Solution B

  1. Review that the pth file name is correct
  2. Review if the pth file was terminated while it was being saved. If so, wait until the pth file is fully saved.

Hi, TwinKay.
Although I don't know whether it is running with GPU or CPU, my computer only has an nvidia gtx 1060 GPU. So my environment here is more like B's situation.
According to your suggestion, I downloaded a pth file from the link below:
https://github.com/Randl/MobileNetV3-pytorch/blob/master/results/mobilenetv3large-v1/model_best0-ec869f9b.pth)

But the error still occurs when running as follows:
Traceback (most recent call last):
File "D:\proj\koreaTrack\AI-Basketball-Field-Goal-Tracker\re_id\tools\train.py", line 219, in
model.load_state_dict(torch.load(os.path.join("../model_weights", "mobilenetv3_best.pth")))
File "C:\Users\me\AppData\Local\Programs\Python\Python37\lib\site-packages\torch\nn\modules\module.py", line 1672, in load_state_dict
self.class.name, "\n\t".join(error_msgs)))
RuntimeError: Error(s) in loading state_dict for MobileNetV3:
Missing key(s) in state_dict: "mobilenetv3.conv_stem.weight", "mobilenetv3.bn1.weight", "mobilenetv3.bn1.bias", "mobilenetv3.bn1.running_mean", "mobilenetv3.bn1.running_var", "mobilenetv3.blocks.0.0.conv_dw.weight", "mobilenetv3.blocks.0.0.bn1.weight", "mobilenetv3.blocks.0.0.bn1.bias", "mobilenetv3.blocks.0.0.bn1.running_mean", "mobilenetv3.blocks.0.0.bn1.running_var", "mobilenetv3.blocks.0.0.conv_pw.weight", "mobilenetv3.blocks.0.0.bn2.weight", "mobilenetv3.blocks.0.0.bn2.bias", "mobilenetv3.blocks.0.0.bn2.running_mean", "mobilenetv3.blocks.0.0.bn2.running_var", "mobilenetv3.blocks.1.0.conv_pw.weight", "mobilenetv3.blocks.1.0.bn1.weight", "mobilenetv3.blocks.1.0.bn1.bias", "mobilenetv3.blocks.1.0.bn1.running_mean", "mobilenetv3.blocks.1.0.bn1.running_var", "mobilenetv3.blocks.1.0.conv_dw.weight", "mobilenetv3.blocks.1.0.bn2.weight", "mobilenetv3.blocks.1.0.bn2.bias", "mobilenetv3.blocks.1.0.bn2.running_mean", "mobilenetv3.blocks.1.0.bn2.running_var", "mobilenetv3.blocks.1.0.conv_pwl.weight", "mobilenetv3.blocks.1.0.bn3.weight", "mobilenetv3.blocks.1.0.bn3.bias", "mobilenetv3.blocks.1.0.bn3.running_mean", "mobilenetv3.blocks.1.0.bn3.running_var", "mobilenetv3.blocks.1.1.conv_pw.weight", "mobilenetv3.blocks.1.1.bn1.weight", "mobilenetv3.blocks.1.1.bn1.bias", "mobilenetv3.blocks.1.1.bn1.running_mean", "mobilenetv3.blocks.1.1.bn1.running_var", "mobilenetv3.blocks.1.1.conv_dw.weight", "mobilenetv3.blocks.1.1.bn2.weight", "mobilenetv3.blocks.1.1.bn2.bias", "mobilenetv3.blocks.1.1.bn2.running_mean", "mobilenetv3.blocks.1.1.bn2.running_var", "mobilenetv3.blocks.1.1.conv_pwl.weight", "mobilenetv3.blocks.1.1.bn3.weight", "mobilenetv3.blocks.1.1.bn3.bias", "mobilenetv3.blocks.1.1.bn3.running_mean", "mobilenetv3.blocks.1.1.bn3.running_var", "mobilenetv3.blocks.2.0.conv_pw.weight", "mobilenetv3.blocks.2.0.bn1.weight", "mobilenetv3.blocks.2.0.bn1.bias", "mobilenetv3.blocks.2.0.bn1.running_mean", "mobilenetv3.blocks.2.0.bn1.running_var", "mobilenetv3.blocks.2.0.conv_dw.weight", "mobilenetv3.blocks.2.0.bn2.weight", "mobilenetv3.blocks.2.0.bn2.bias", "mobilenetv3.blocks.2.0.bn2.running_mean", "mobilenetv3.blocks.2.0.bn2.running_var", "mobilenetv3.blocks.2.0.se.conv_reduce.weight", "mobilenetv3.blocks.2.0.se.conv_reduce.bias", "mobilenetv3.blocks.2.0.se.conv_expand.weight", "mobilenetv3.blocks.2.0.se.conv_expand.bias", "mobilenetv3.blocks.2.0.conv_pwl.weight", "mobilenetv3.blocks.2.0.bn3.weight", "mobilenetv3.blocks.2.0.bn3.bias", "mobilenetv3.blocks.2.0.bn3.running_mean", "mobilenetv3.blocks.2.0.bn3.running_var", "mobilenetv3.blocks.2.1.conv_pw.weight", "mobilenetv3.blocks.2.1.bn1.weight", "mobilenetv3.blocks.2.1.bn1.bias", "mobilenetv3.blocks.2.1.bn1.running_mean", "mobilenetv3.blocks.2.1.bn1.running_var", "mobilenetv3.blocks.2.1.conv_dw.weight", "mobilenetv3.blocks.2.1.bn2.weight", "mobilenetv3.blocks.2.1.bn2.bias", "mobilenetv3.blocks.2.1.bn2.running_mean", "mobilenetv3.blocks.2.1.bn2.running_var", "mobilenetv3.blocks.2.1.se.conv_reduce.weight", "mobilenetv3.blocks.2.1.se.conv_reduce.bias", "mobilenetv3.blocks.2.1.se.conv_expand.weight", "mobilenetv3.blocks.2.1.se.conv_expand.bias", "mobilenetv3.blocks.2.1.conv_pwl.weight", "mobilenetv3.blocks.2.1.bn3.weight", "mobilenetv3.blocks.2.1.bn3.bias", "mobilenetv3.blocks.2.1.bn3.running_mean", "mobilenetv3.blocks.2.1.bn3.running_var", "mobilenetv3.blocks.2.2.conv_pw.weight", "mobilenetv3.blocks.2.2.bn1.weight", "mobilenetv3.blocks.2.2.bn1.bias", "mobilenetv3.blocks.2.2.bn1.running_mean", "mobilenetv3.blocks.2.2.bn1.running_var", "mobilenetv3.blocks.2.2.conv_dw.weight", "mobilenetv3.blocks.2.2.bn2.weight", "mobilenetv3.blocks.2.2.bn2.bias", "mobilenetv3.blocks.2.2.bn2.running_mean", "mobilenetv3.blocks.2.2.bn2.running_var", "mobilenetv3.blocks.2.2.se.conv_reduce.weight", "mobilenetv3.blocks.2.2.se.conv_reduce.bias", "mobilenetv3.blocks.2.2.se.conv_expand.weight", "mobilenetv3.blocks.2.2.se.conv_expand.bias", "mobilenetv3.blocks.2.2.conv_pwl.weight", "mobilenetv3.blocks.2.2.bn3.weight", "mobilenetv3.blocks.2.2.bn3.bias", "mobilenetv3.blocks.2.2.bn3.running_mean", "mobilenetv3.blocks.2.2.bn3.running_var", "mobilenetv3.blocks.3.0.conv_pw.weight", "mobilenetv3.blocks.3.0.bn1.weight", "mobilenetv3.blocks.3.0.bn1.bias", "mobilenetv3.blocks.3.0.bn1.running_mean", "mobilenetv3.blocks.3.0.bn1.running_var", "mobilenetv3.blocks.3.0.conv_dw.weight", "mobilenetv3.blocks.3.0.bn2.weight", "mobilenetv3.blocks.3.0.bn2.bias", "mobilenetv3.blocks.3.0.bn2.running_mean", "mobilenetv3.blocks.3.0.bn2.running_var", "mobilenetv3.blocks.3.0.conv_pwl.weight", "mobilenetv3.blocks.3.0.bn3.weight", "mobilenetv3.blocks.3.0.bn3.bias", "mobilenetv3.blocks.3.0.bn3.running_mean", "mobilenetv3.blocks.3.0.bn3.running_var", "mobilenetv3.blocks.3.1.conv_pw.weight", "mobilenetv3.blocks.3.1.bn1.weight", "mobilenetv3.blocks.3.1.bn1.bias", "mobilenetv3.blocks.3.1.bn1.running_mean", "mobilenetv3.blocks.3.1.bn1.running_var", "mobilenetv3.blocks.3.1.conv_dw.weight", "mobilenetv3.blocks.3.1.bn2.weight", "mobilenetv3.blocks.3.1.bn2.bias", "mobilenetv3.blocks.3.1.bn2.running_mean", "mobilenetv3.blocks.3.1.bn2.running_var", "mobilenetv3.blocks.3.1.conv_pwl.weight", "mobilenetv3.blocks.3.1.bn3.weight", "mobilenetv3.blocks.3.1.bn3.bias", "mobilenetv3.blocks.3.1.bn3.running_mean", "mobilenetv3.blocks.3.1.bn3.running_var", "mobilenetv3.blocks.3.2.conv_pw.weight", "mobilenetv3.blocks.3.2.bn1.weight", "mobilenetv3.blocks.3.2.bn1.bias", "mobilenetv3.blocks.3.2.bn1.running_mean", "mobilenetv3.blocks.3.2.bn1.running_var", "mobilenetv3.blocks.3.2.conv_dw.weight", "mobilenetv3.blocks.3.2.bn2.weight", "mobilenetv3.blocks.3.2.bn2.bias", "mobilenetv3.blocks.3.2.bn2.running_mean", "mobilenetv3.blocks.3.2.bn2.running_var", "mobilenetv3.blocks.3.2.conv_pwl.weight", "mobilenetv3.blocks.3.2.bn3.weight", "mobilenetv3.blocks.3.2.bn3.bias", "mobilenetv3.blocks.3.2.bn3.running_mean", "mobilenetv3.blocks.3.2.bn3.running_var", "mobilenetv3.blocks.3.3.conv_pw.weight", "mobilenetv3.blocks.3.3.bn1.weight", "mobilenetv3.blocks.3.3.bn1.bias", "mobilenetv3.blocks.3.3.bn1.running_mean", "mobilenetv3.blocks.3.3.bn1.running_var", "mobilenetv3.blocks.3.3.conv_dw.weight", "mobilenetv3.blocks.3.3.bn2.weight", "mobilenetv3.blocks.3.3.bn2.bias", "mobilenetv3.blocks.3.3.bn2.running_mean", "mobilenetv3.blocks.3.3.bn2.running_var", "mobilenetv3.blocks.3.3.conv_pwl.weight", "mobilenetv3.blocks.3.3.bn3.weight", "mobilenetv3.blocks.3.3.bn3.bias", "mobilenetv3.blocks.3.3.bn3.running_mean", "mobilenetv3.blocks.3.3.bn3.running_var", "mobilenetv3.blocks.4.0.conv_pw.weight", "mobilenetv3.blocks.4.0.bn1.weight", "mobilenetv3.blocks.4.0.bn1.bias", "mobilenetv3.blocks.4.0.bn1.running_mean", "mobilenetv3.blocks.4.0.bn1.running_var", "mobilenetv3.blocks.4.0.conv_dw.weight", "mobilenetv3.blocks.4.0.bn2.weight", "mobilenetv3.blocks.4.0.bn2.bias", "mobilenetv3.blocks.4.0.bn2.running_mean", "mobilenetv3.blocks.4.0.bn2.running_var", "mobilenetv3.blocks.4.0.se.conv_reduce.weight", "mobilenetv3.blocks.4.0.se.conv_reduce.bias", "mobilenetv3.blocks.4.0.se.conv_expand.weight", "mobilenetv3.blocks.4.0.se.conv_expand.bias", "mobilenetv3.blocks.4.0.conv_pwl.weight", "mobilenetv3.blocks.4.0.bn3.weight", "mobilenetv3.blocks.4.0.bn3.bias", "mobilenetv3.blocks.4.0.bn3.running_mean", "mobilenetv3.blocks.4.0.bn3.running_var", "mobilenetv3.blocks.4.1.conv_pw.weight", "mobilenetv3.blocks.4.1.bn1.weight", "mobilenetv3.blocks.4.1.bn1.bias", "mobilenetv3.blocks.4.1.bn1.running_mean", "mobilenetv3.blocks.4.1.bn1.running_var", "mobilenetv3.blocks.4.1.conv_dw.weight", "mobilenetv3.blocks.4.1.bn2.weight", "mobilenetv3.blocks.4.1.bn2.bias", "mobilenetv3.blocks.4.1.bn2.running_mean", "mobilenetv3.blocks.4.1.bn2.running_var", "mobilenetv3.blocks.4.1.se.conv_reduce.weight", "mobilenetv3.blocks.4.1.se.conv_reduce.bias", "mobilenetv3.blocks.4.1.se.conv_expand.weight", "mobilenetv3.blocks.4.1.se.conv_expand.bias", "mobilenetv3.blocks.4.1.conv_pwl.weight", "mobilenetv3.blocks.4.1.bn3.weight", "mobilenetv3.blocks.4.1.bn3.bias", "mobilenetv3.blocks.4.1.bn3.running_mean", "mobilenetv3.blocks.4.1.bn3.running_var", "mobilenetv3.blocks.5.0.conv_pw.weight", "mobilenetv3.blocks.5.0.bn1.weight", "mobilenetv3.blocks.5.0.bn1.bias", "mobilenetv3.blocks.5.0.bn1.running_mean", "mobilenetv3.blocks.5.0.bn1.running_var", "mobilenetv3.blocks.5.0.conv_dw.weight", "mobilenetv3.blocks.5.0.bn2.weight", "mobilenetv3.blocks.5.0.bn2.bias", "mobilenetv3.blocks.5.0.bn2.running_mean", "mobilenetv3.blocks.5.0.bn2.running_var", "mobilenetv3.blocks.5.0.se.conv_reduce.weight", "mobilenetv3.blocks.5.0.se.conv_reduce.bias", "mobilenetv3.blocks.5.0.se.conv_expand.weight", "mobilenetv3.blocks.5.0.se.conv_expand.bias", "mobilenetv3.blocks.5.0.conv_pwl.weight", "mobilenetv3.blocks.5.0.bn3.weight", "mobilenetv3.blocks.5.0.bn3.bias", "mobilenetv3.blocks.5.0.bn3.running_mean", "mobilenetv3.blocks.5.0.bn3.running_var", "mobilenetv3.blocks.5.1.conv_pw.weight", "mobilenetv3.blocks.5.1.bn1.weight", "mobilenetv3.blocks.5.1.bn1.bias", "mobilenetv3.blocks.5.1.bn1.running_mean", "mobilenetv3.blocks.5.1.bn1.running_var", "mobilenetv3.blocks.5.1.conv_dw.weight", "mobilenetv3.blocks.5.1.bn2.weight", "mobilenetv3.blocks.5.1.bn2.bias", "mobilenetv3.blocks.5.1.bn2.running_mean", "mobilenetv3.blocks.5.1.bn2.running_var", "mobilenetv3.blocks.5.1.se.conv_reduce.weight", "mobilenetv3.blocks.5.1.se.conv_reduce.bias", "mobilenetv3.blocks.5.1.se.conv_expand.weight", "mobilenetv3.blocks.5.1.se.conv_expand.bias", "mobilenetv3.blocks.5.1.conv_pwl.weight", "mobilenetv3.blocks.5.1.bn3.weight", "mobilenetv3.blocks.5.1.bn3.bias", "mobilenetv3.blocks.5.1.bn3.running_mean", "mobilenetv3.blocks.5.1.bn3.running_var", "mobilenetv3.blocks.5.2.conv_pw.weight", "mobilenetv3.blocks.5.2.bn1.weight", "mobilenetv3.blocks.5.2.bn1.bias", "mobilenetv3.blocks.5.2.bn1.running_mean", "mobilenetv3.blocks.5.2.bn1.running_var", "mobilenetv3.blocks.5.2.conv_dw.weight", "mobilenetv3.blocks.5.2.bn2.weight", "mobilenetv3.blocks.5.2.bn2.bias", "mobilenetv3.blocks.5.2.bn2.running_mean", "mobilenetv3.blocks.5.2.bn2.running_var", "mobilenetv3.blocks.5.2.se.conv_reduce.weight", "mobilenetv3.blocks.5.2.se.conv_reduce.bias", "mobilenetv3.blocks.5.2.se.conv_expand.weight", "mobilenetv3.blocks.5.2.se.conv_expand.bias", "mobilenetv3.blocks.5.2.conv_pwl.weight", "mobilenetv3.blocks.5.2.bn3.weight", "mobilenetv3.blocks.5.2.bn3.bias", "mobilenetv3.blocks.5.2.bn3.running_mean", "mobilenetv3.blocks.5.2.bn3.running_var", "mobilenetv3.blocks.6.0.conv.weight", "mobilenetv3.blocks.6.0.bn1.weight", "mobilenetv3.blocks.6.0.bn1.bias", "mobilenetv3.blocks.6.0.bn1.running_mean", "mobilenetv3.blocks.6.0.bn1.running_var", "mobilenetv3.conv_head.weight", "mobilenetv3.conv_head.bias", "mobilenetv3.classifier.weight", "mobilenetv3.classifier.bias".
Unexpected key(s) in state_dict: "epoch", "state_dict", "best_prec1", "optimizer".

So please help me figure out what's going wrong.

Of course, I very much hope that you can provide me with the pre-trained model. I hope to quickly use your pre-trained model to perform inference on my basketball videos to see the effect. Thank you.

Hello!
Sorry for the inconvience your having with the issue.

Can you try to remove model.load_state_dict(torch.load(os.path.join("../model_weights", "mobilenetv3_best.pth"))) at line 219 in train.py? and check if it works?

Moreover, I suggest you to train the model with your dataset first to have better results.

Hope this helps to address the issue.

Hmtir commented

Thank you for your interest in our project :)

Also, I checked the email you sent me. According to your email, it is confirmed that the following error occurs.

Traceback (most recent call last):
 File "~/re_id/tools/train.py", line 219, in <module>
  model.load_state_dict(torch.load(os.path.join("../model_weights", "mobilenetv3_best.pth")))

...

RuntimeError: Error(s) in loading state_dict for MobileNetV3:
 Missing key(s) in state_dict: "mobilenetv3.conv_stem.weight", ...

It seems that the error occurred because you used a multi-GPU. If you used multi-GPU, you can refer to Solution A If not, refer to Solution B Nevertheless, if the problem is not solved, please leave an email address and I will send you the pth file.

Solution A

  1. Modify model.state_dict() in line 287, 291 to model.module.state_dict()

Solution B

  1. Review that the pth file name is correct
  2. Review if the pth file was terminated while it was being saved. If so, wait until the pth file is fully saved.

Here is an extra solution:

Solution C (for someone who have no GPU):
add a parameter to torch.load(....., map_location=torch.device("cpu"))
But without GPU it doesn't work well therfore the best solution is to remove this line to not using any pre-trained model.