forked from Melody-Zhou/tensorRT_Pro-YOLOv8
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
712782d
commit 65e7480
Showing
44 changed files
with
13,857 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import onnx | ||
import onnx_graphsurgeon as gs | ||
|
||
# 加载 ONNX 模型 | ||
input_model_path = "workspace/ppocr_det.sim.onnx" | ||
output_model_path = "workspace/ppocr_det.sim.plugin.onnx" | ||
graph = gs.import_onnx(onnx.load(input_model_path)) | ||
|
||
# 遍历图中的所有节点 | ||
for node in graph.nodes: | ||
if node.op == "HardSwish": | ||
node.op = "Plugin" | ||
# 添加自定义属性 | ||
node.attrs["name"] = "HSwish" | ||
node.attrs["info"] = "This is custom HardSwish node" | ||
|
||
# 删除无用的节点和张量 | ||
graph.cleanup() | ||
|
||
# 导出修改后的模型 | ||
onnx.save(gs.export_onnx(graph), output_model_path) |
Oops, something went wrong.