样例步骤适用于以下产品。
从以下链接获取ResNet-50网络的权重文件(*.caffemodel)、模型文件(resnet50.prototxt),并以HwHiAiUser(运行用户)将获取的文件上传至开发环境的“vpc_resnet50_imagenet_classification样例目录/caffe_model ”目录下。
切换到“vpc_resnet50_imagenet_classification”目录,执行如下命令。Ascendxxx为使用的昇腾AI处理器型号,请用户自行替换。
atc --model=caffe_model/resnet50.prototxt --weight=caffe_model/resnet50.caffemodel --framework=0 --output=model/resnet50_aipp --soc_version=Ascendxxx --insert_op_conf=caffe_model/aipp.cfg
切换到“vpc_resnet50_imagenet_classification”目录,执行如下命令。Ascendxxx为使用的昇腾AI处理器型号,请用户自行替换。
atc --singleop=op_models/op_list.json --soc_version=Ascendxxx --output=op_models/
关于各参数的详细解释,请参见《ATC工具使用指南》中的参数说明。
python3 ./src/acl_sample.py
Using device id:0 model path:./model/resnet50_aipp.om images path:./data [Sample] init resource stage: [Sample] init resource stage success [Model] The class Model initializes resources: [Model] create output dataset: [Model] create output dataset success [Model] The class Model initializes resources successfully. [Sample] width:1024 height:683 [Sample] image:./data/dog1_1024_683.jpg [Dvpp] vpc decode stage: [Dvpp] vpc decode stage success [Dvpp] vpc resize stage: [Dvpp] vpc resize stage success [Model] create model input dataset: [Model] create model input dataset success [Model] execute stage: [Model] execute stage success ======== top5 inference results: ======== label:161 prob: 0.712891 label:162 prob: 0.147095 label:167 prob: 0.051636 label:163 prob: 0.050476 label:166 prob: 0.030136 [SingleOP] single op cast success [SingleOp] get top 1 label success [SingleOP][ArgMaxOp] label of classification result is:161 [Sample] width:1024 height:683 [Sample] image:./data/dog2_1024_683.jpg [Dvpp] vpc decode stage: [Dvpp] vpc decode stage success [Dvpp] vpc resize stage: [Dvpp] vpc resize stage success [Model] create model input dataset: [Model] create model input dataset success [Model] execute stage: [Model] execute stage success ======== top5 inference results: ======== label:267 prob: 0.855469 label:266 prob: 0.049805 label:219 prob: 0.032654 label:265 prob: 0.013405 label:129 prob: 0.011024 [SingleOP] single op cast success [SingleOp] get top 1 label success [SingleOP][ArgMaxOp] label of classification result is:267 [Model] The class Model releases resources successfully. [Dvpp] class Dvpp exit success [SingOp] class SingOp release source success [Sample] class Samle release source success