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

删除子分支后,分支上的节点变成了inputs。 #12

Closed
ganleiboy opened this issue Aug 8, 2022 · 2 comments
Closed

删除子分支后,分支上的节点变成了inputs。 #12

ganleiboy opened this issue Aug 8, 2022 · 2 comments

Comments

@ganleiboy
Copy link

1,原始模型删除子分支,如下图:
screenshot_24

2,保存后打开修剪过的模型,可以看到inputs变多了,如下图:
screenshot_25

3,我是通过如下代码对模型的inputs进行了删除:

import onnx                         

inputpath = "./descriptor.onnx"

# 1,修改模型
model = onnx.load(inputpath)
inputs = model.graph.input
inputs_num = 1  # 原始网络的输入会排在列表的最前面,所以调用pop函数删除冗余输入
for i in range(len(inputs)-inputs_num):
    inputs.pop()
print(inputs)

# 2,检查结构并保存模型(覆盖保存)
onnx.checker.check_model(model)
onnx.save(model, inputpath)
@ZhangGe6
Copy link
Owner

你好,这个问题最近我在用的时候也发现了,正尝试修复,谢谢详细的反馈和提供备选解决方案!

@ZhangGe6
Copy link
Owner

@ganleiboy 你好,我更新了一个版本来尝试解决这个问题,如果方便的话,请使用新版做修改试试,如果仍然存在问题,欢迎继续讨论~

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