当前位置: 首页 > news >正文

下载网站的软件百度搜索app下载

下载网站的软件,百度搜索app下载,用dw做销售网站,南宁免费自助建站模板某些模型最后卷积层之后的算子不适合在推理引擎里面跑,切割掉conv后面的算子,在cpu上实现有比较好的性能. 包含: 1.获取onnx中间节点的shape的示例 2.增加onnx模型输出,设…
某些模型最后卷积层之后的算子不适合在推理引擎里面跑,切割掉conv后面的算子,在cpu上实现有比较好的性能.
包含:
1.获取onnx中间节点的shape的示例
2.增加onnx模型输出,设置名称,type, shape. 示例
3.编辑onnx模型示例切割掉绿色部分示例
import onnx
import sys
import json
from onnx import shape_inference, TensorProtoif len(sys.argv) < 2:print('Usage: ' + sys.argv[0] + '<onnx_filename>')exit(-1)onnx_file = sys.argv[1]# 加载ONNX模型
model = onnx.load(onnx_file)graph = model.graphoutputs = model.graph.output 
if(len(outputs)!=3):print("This isn't ScoreBoxKpt model!")quit()output_list=["output0","output1","output2"]for output in outputs:if output.name in score_box_kpt :print(f"output name: {output.name}")else:print("This isn't a fit model!")quit()def getConvList(endName):stack=[]stack.append(endName)convList=[]while(len(stack)):name=stack.pop()for node in graph.node:if name in node.output :if node.op_type=="Conv":if node.name not in convList :convList.append(node.name)else: for input in node.input:if input not in stack:stack.insert(0, input)return convListConv0=getConvList(output_list[0])
Conv1=getConvList(output_list[1])
Conv2=getConvList(output_list[2])def save2json(save_dict, name):if len(save_dict) == 0:print("this is nothing to save json")return Nonewith open(name, 'w') as fp:#{'a': 'Runoob', 'b': 7}json.dump(save_dict, fp, sort_keys=False, indent=4, separators=(',', ': ')) #default=strsave_dict = {output_list[0]:scoreConv,output_list[1]:boxConv,output_list[2]:kptConv}conv_list=Conv0+Conv1+Conv2#获取onnx中间节点的shape.
output_dim_dic={}
inferred_onnx_model = shape_inference.infer_shapes(model)
inferred_graph = inferred_onnx_model.graph
inferred_value_info = inferred_graph.value_info
for node in graph.node:if node.name in conv_list:for value_info in inferred_value_info:if value_info.name==node.output[0]:output_dim_dic[node.name]=value_info.type.tensor_type;#删除conv 后面的onnx节点
# Find target node index
for name in conv_list:target_node = Nonefor node in graph.node:if node.name == name:target_node=nodebreakoutput_names = []for output in target_node.output:output_names.append(output)set1=set(output_names)del_node = []have_new_del_node = Falsewhile True:have_new_del_node = Falsefor node in graph.node:if node.name in del_node:continueset2=set(node.input)if set1.intersection(set2): output_names+=node.output         set1=set(output_names)del_node.append(node.name)have_new_del_node = Trueif have_new_del_node == False:breakfor node in graph.node:if node.name in del_node:print(f"1remove node {node.name}")model.graph.node.remove(node)have_new_del_node = False
while True:have_new_del_node = Falsefor node1 in graph.node:if node1.name in conv_list :continueset1=set(node1.output)to_delete =Truefor node2 in graph.node:set2=set(node2.input)if set1.intersection(set2): to_delete = Falsebreakif to_delete == True:print(f"2remove node {node1.name}")model.graph.node.remove(node1)have_new_del_node=Trueif have_new_del_node == False :breaksave_output_name=[]
for node in graph.node:if node.name in conv_list:#增加输出层output_info = onnx.helper.ValueInfoProto()node.output[0]=node.nameoutput_info.name = node.output[0]for dim_value in output_dim_dic[node.name].shape.dim:output_info.type.tensor_type.shape.dim.extend([dim_value])output_info.type.tensor_type.elem_type = TensorProto.FLOATprint(output_info)graph.output.extend([output_info])save_output_name.append(node.output[0])outputs = model.graph.output 
# 打印输出节点名称
for output in outputs:if output.name  in save_output_name :continuemodel.graph.output.remove(output)
outputs = model.graph.output 
# 打印输出节点名称
for output in outputs:if output.name  in save_output_name :continuemodel.graph.output.remove(output)
# Save modified ONNX model
onnx.checker.check_model(model)
onnx.save(model, "backbone.onnx")
save2json(save_dict, 'conv_param.json'
http://www.tj-hxxt.cn/news/124612.html

相关文章:

  • 云南网站建设百度官方怎么找需要推广的商家
  • 排名做网站优化网站快照优化公司
  • wordpress 响应式图片百度seo关键词排名优化教程
  • 简单的网站开发最大的推广平台
  • 可以接单做3d网站餐饮营销策划方案
  • 大连网站制作咨询常用的网络营销工具
  • wordpress花园网站附近学电脑培训班
  • 上海网站被查浏览器正能量网站免费
  • 哪家公司建网站最好网络营销策划怎么写
  • 网站建站模板样例网推平台
  • 移动端网站日历怎么做南宁百度推广代理商
  • 网站查询 工信部站长域名查询工具
  • 新乐市做网站一件代发48个货源网站
  • 怎么找到网站的空间服务商新闻头条今天最新消息
  • 大兴网站开发网站建设哪家好优秀网站网页设计分析
  • 工作室logoseo自然搜索优化排名
  • 网站 建设标准优量汇广告平台
  • 中国2020最新军事新闻东莞seo管理
  • 电脑上怎么做网站玄幻小说排行榜百度风云榜
  • 水禾田网站建设公司重庆seo哪个强
  • 色块布局网站首页模板河南网站定制
  • vs2010做的网站最近发生的重大新闻事件
  • 视觉滚动网站seo优化实训总结
  • 免费空间申请哪个好北京seo关键词优化收费
  • 安徽网站搭建百度推广网址是多少
  • 北京网站建设官网百度广告位
  • 网站内容有什么seo关键词优化推广外包
  • CP网站开发制作H5网络推广业务
  • 安慧桥做网站公司企业网络营销策划书
  • 霸州做网站的腾讯nba新闻