Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

请问这个您的yolo.py可以用旷视训练好的yolox_s的直接做预测推理吗? #152

Open
Maxwell2016LeChouchou opened this issue Oct 5, 2023 · 1 comment

Comments

@Maxwell2016LeChouchou
Copy link

Maxwell2016LeChouchou commented Oct 5, 2023

请问这个您的yolo.py和predict.py可以用旷视训练好的yolox_s的直接做预测推理吗?
我看您的predict.py有可视化heatmap,就想用我在旷视训练好的yolox_s(自己标注的训练集)在您的代码上直接做heatmap可视化。
但是报一大堆backbone的错误,主要是这些:

(open-mmlab) C:\Maxwell_W\detection\yolox-pytorch>python predict.py img/clean_AI_00822.png
Traceback (most recent call last):
  File "predict.py", line 14, in <module>
    yolo = YOLO()
  File "C:\Maxwell_W\detection\yolox-pytorch\yolo.py", line 85, in __init__
    self.generate()
  File "C:\Maxwell_W\detection\yolox-pytorch\yolo.py", line 95, in generate
    self.net.load_state_dict(torch.load(self.model_path, map_location=device))
  File "C:\Users\potentialmotors\miniconda3\envs\open-mmlab\lib\site-packages\torch\nn\modules\module.py", line 1671, in load_state_dict
    raise RuntimeError('Error(s) in loading state_dict for {}:\n\t{}'.format(
RuntimeError: Error(s) in loading state_dict for YoloBody:
        Missing key(s) in state_dict: "backbone.backbone.stem.conv.conv.weight", "[backbone.backbone.stem.conv.bn](http://backbone.backbone.stem.conv.bn/).weight", "[backbone.backbone.stem.conv.bn](http://backbone.backbone.stem.conv.bn/).bias", "backbone.backbone.stem.conv.bn.running_mean",
"""""""
这里报一大堆的backbone nn的错误 
"""""""
        Unexpected key(s) in state_dict: "start_epoch", "model", "optimizer", "best_ap", "curr_ap".
@illrayy
Copy link

illrayy commented Jan 5, 2024

模型的权重是通过字典加载的:

pretrained_dict = torch.load(model_path, map_location = device)
pretrained_dict = {k: v for k, v in pretrained_dict.items() if np.shape(model_dict[k]) == np.shape(v)}

官方仓库训练的模型和这个仓库的key不同,你可以对一下两个权重的shape,看看这个仓库的key是什么样的,然后自己改一下官方的key

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants