Commit ab5a814d authored by liucong's avatar liucong
Browse files

修改input/output代码

parent a8baa52e
...@@ -59,8 +59,20 @@ if __name__ == '__main__': ...@@ -59,8 +59,20 @@ if __name__ == '__main__':
cfg = cfg_re50 cfg = cfg_re50
device = torch.device("cpu" if args.cpu else "cuda") device = torch.device("cpu" if args.cpu else "cuda")
model = migraphx.parse_onnx("./FaceDetector.onnx") model = migraphx.parse_onnx("./FaceDetector.onnx")
# 获取模型输入/输出节点信息
print("inputs:")
inputs = model.get_inputs()
for key,value in inputs.items():
print("{}:{}".format(key,value))
print("outputs:")
outputs = model.get_outputs()
for key,value in outputs.items():
print("{}:{}".format(key,value))
inputName=model.get_parameter_names()[0] inputName=model.get_parameter_names()[0]
inputShape=model.get_parameter_shapes()[inputName].lens() inputShape=inputs[inputName].lens()
print("inputName:{0} \ninputShape:{1}".format(inputName,inputShape)) print("inputName:{0} \ninputShape:{1}".format(inputName,inputShape))
# FP16 # FP16
......
...@@ -71,10 +71,21 @@ ErrorCode DetectorRetinaFace::Initialize(InitializationParameterOfDetector initi ...@@ -71,10 +71,21 @@ ErrorCode DetectorRetinaFace::Initialize(InitializationParameterOfDetector initi
net = migraphx::parse_onnx(modelPath); net = migraphx::parse_onnx(modelPath);
LOG_INFO(stdout,"succeed to load model: %s\n",GetFileName(modelPath).c_str()); LOG_INFO(stdout,"succeed to load model: %s\n",GetFileName(modelPath).c_str());
// 获取模型输入属性 // 获取模型输入/输出节点信息
std::unordered_map<std::string, migraphx::shape> inputMap=net.get_parameter_shapes(); std::cout<<"inputs:"<<std::endl;
inputName=inputMap.begin()->first; std::unordered_map<std::string, migraphx::shape> inputs=net.get_inputs();
inputShape=inputMap.begin()->second; for(auto i:inputs)
{
std::cout<<i.first<<":"<<i.second<<std::endl;
}
std::cout<<"outputs:"<<std::endl;
std::unordered_map<std::string, migraphx::shape> outputs=net.get_outputs();
for(auto i:outputs)
{
std::cout<<i.first<<":"<<i.second<<std::endl;
}
inputName=inputs.begin()->first;
inputShape=inputs.begin()->second;
int N=inputShape.lens()[0]; int N=inputShape.lens()[0];
int C=inputShape.lens()[1]; int C=inputShape.lens()[1];
int H=inputShape.lens()[2]; int H=inputShape.lens()[2];
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment