【踩坑】
RuntimeError: Exporting the operator prim_DictConstruct to ONNX opset version 11 is not supported. Please open a bug to request ONNX export support for the missing operator.
问题场景:因为模型是多输出,模型输出本来是字典格式,在pytorch 保存pth转onnx时,出现无法支持字典操作,转模型格式报出错误。
解决:直接把网络输出格式更改。
# 把需要输出的字典 value 转 列表格式
out_values_list = []
out_key_list = ['prob', 'prob_logit', 'prob_map','height_prob','height_prob_logit',
'center_mask', 'visit_mask', 'center_idx', 'offset', 'edge_map',
'seg_map']
for out_s in out_key_list:
out_values_list.append(out[out_s])
print('test forward out keys:',out.keys())
out = tuple(out_values_list)
Reference: