yjh0410 / YOWOv2

The second generation of YOWO action detector.
MIT License
187 stars 31 forks source link

Missing key(s) in state_dict: #22

Closed shahzebelexoft closed 11 months ago

shahzebelexoft commented 11 months ago

When I run demo.py. I get the following error:

Traceback (most recent call last):
  File "demo.py", line 260, in <module>
    model = load_weight(model=model, path_to_ckpt=args.weight)
  File "F:\Projects\action-recognition\New_folder\YOWOv2\utils\misc.py", line 161, in load_weight
    model.load_state_dict(checkpoint_state_dict)
  File "C:\Users\UMAIR COMPUTER\anaconda3\envs\actions_env\lib\site-packages\torch\nn\modules\module.py", line 1224, in load_state_dict
    self.__class__.__name__, "\n\t".join(error_msgs)))
RuntimeError: Error(s) in loading state_dict for YOWO:
        Missing key(s) in state_dict: "cls_preds.0.weight", "cls_preds.0.bias", "cls_preds.1.weight", "cls_preds.1.bias", "cls_preds.2.weight", "cls_preds.2.bias".
lei195827 commented 11 months ago

老哥我也遇到这个问题,你解决了吗? "Hey bro, I've also encountered this issue. Have you solved it?"

lei195827 commented 11 months ago

我好像知道原因了,作者ucf和ava两个数据集的权重不一样,你下载下面那个权重应该就能运行了

shahzebelexoft commented 11 months ago

I am training the model on custom data. I have structured my custom data in the same manner as the UCF dataset and also have trained the model. However, upon attempting to load the weights of the model using the eval.py or demo.py, I encountered some shape mismatches in the keys.

yjh0410 commented 11 months ago

@shahzebelexoft Please check the parameter num_classes carefully. It is possible that when you run demo.py, the setting of num_classes is inconsistent with the channel number of cls_pred of your trained model.