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

各种主干网络是否有预训练权重应该在哪看 #3138

Closed
1 task done
toouki opened this issue Apr 9, 2023 · 3 comments
Closed
1 task done

各种主干网络是否有预训练权重应该在哪看 #3138

toouki opened this issue Apr 9, 2023 · 3 comments
Assignees
Labels
GoodFirstIssue question Further information is requested

Comments

@toouki
Copy link

toouki commented Apr 9, 2023

问题确认 Search before asking

  • 我已经搜索过问题,但是没有找到解答。I have searched the question and found no related answer.

请提出你的问题 Please ask your question

请问各种主干网络是否有预训练权重应该在哪看?
我只能从config中翻到一些

@toouki toouki added the question Further information is requested label Apr 9, 2023
@github-actions github-actions bot added the triage new issue, waiting to be assigned label Apr 9, 2023
@Stinky-Tofu Stinky-Tofu self-assigned this Apr 10, 2023
@github-actions github-actions bot removed the triage new issue, waiting to be assigned label Apr 10, 2023
@marshall-dteach
Copy link
Contributor

  你好,我来回答一下,各个主干网络的与训练权重大部分都是从现有torch模型保存的模型转化来的,如果有需要可以下载对应的pth模型通过代码转化,我这边提供一个简单版本的模型转化,供你参考(实际过程需要你根据模型的信息调整一些内容)。

##pth -> pdparams
import torch
import numpy as np
import paddle

model_dict = torch.load('pth/eformer_s0_450.pth')['model']
paddle_dict = {}
for key, value in model_dict.items():
    if "running_mean" in key:
        key = key.replace("running_mean", "_mean")
    elif "running_var" in key:
    key = key.replace("running_var", "_variance")
    # if len(value.shape) == 2:
        # paddle_dict[key] = np.transpose(value.detach().cpu().numpy(), ([1, 0]))
    if len(value.shape) == 0:
        print('jump',value, key)
        continue
    else:
        paddle_dict[key] = value.detach().cpu().numpy()
# print(key, value.shape)
print(len(paddle_dict.keys()))
paddle.save(paddle_dict, "pdparams/eformer_s0_450.pdparams")

 $emsp;对应的模型项目链接为:efficientformerV2,可以从图中位置下载模型

image

@shiyutang
Copy link
Collaborator

shiyutang commented Jun 28, 2023

以上回答已经充分解答了问题,如果有新的问题欢迎随时提交issue,或者在此条issue下继续回复~

@shiyutang
Copy link
Collaborator

我们开启了飞桨套件的ISSUE攻关活动,欢迎感兴趣的开发者参加:PaddlePaddle/PaddleOCR#10223

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
GoodFirstIssue question Further information is requested
Projects
None yet
Development

No branches or pull requests

4 participants