1. 转换模型
参考:https://bbs.huaweicloud.com/forum/thread-45383-1-1.html
1.直接获取checkpoint file资源(将weights转换成了.ckpt文件):
the weights pretrained on coco dataset converted TensorFlow checkpoint file:
https://github.com/wizyoung/YOLOv3_TensorFlow/releases/
2.获取weights资源:
①在链接:https://github.com/wizyoung/YOLOv3_TensorFlow中下图位置获取weights资源。
image.png
②参考其readme.md中weights convertion转换成checkpoint file.
备注:步骤1和2只用选择其一。此模型检测类别为coco 80类,输入模型的图片尺寸为416。
3.将ckpt转换成pb方法:
20200312-170312(eSpace).png
input_path 即为三个.ckpt文件路径;
output_path用户自己定义;
4.将pb转换成om文件方法:
将上一步生成的pb文件,执行以下命令即可转换成om文件:
omg --model ./yolov3_coco80_416_chenqian.pb --framework 3 --output ./yolov3 --insert_op_conf ./aipp_yolov3_picture.cfg --input_shape “Placeholder:1,416,416,3”
其中:
–model 后面为上一步生成的pb文件路径;
–framework 为3 ,表示是tensorflow模型;
–output 后面的路径用户自定义;
–insert_op_conf 后面是模型转换配置文件;
–input_shape后面的”input_data:1,416,416,3”为pb模型输入节点的name和shape。
具体可以参考《Atlas 300 模型转换指导书 01》
相关文件,百度云, 提取码: 58hg
2. 编译
cd $InferObjectDetect
bash ./build.sh A500
3. 执行
- 将out文件,yolov3.om模型文件,测试图片传到Atlas500上
scp -r ./out/ root@*********:test/yolov3_out
-
测试
./ObjectDetection -i ./2_4.jpg -t 1 -m ./yolov3.om -g ./graph.config -s 0 -e 0
-
结果
Euler:~/test/new_out # ./ObjectDetection -i ./2_4.jpg -t 1 -m ./yolov3.om -g ./graph.config -s 0 -e 0
***start device 0, end device 0***
device = 0, graphID = 1 init success
[mainG_MODEL]:g_modelType: 1
[INF] channel 0, frame 0 have 10 object
#0, bbox( 27, 599, 372, 1418) confidence: 0.998998 classId is 0
#1, bbox( 377, 524, 703, 1417) confidence: 0.997539 classId is 0
#2, bbox(2278, 500, 2924, 2310) confidence: 0.995793 classId is 0
#3, bbox(1224, 518, 1643, 1846) confidence: 0.995250 classId is 0
#4, bbox(1613, 535, 2001, 1667) confidence: 0.993507 classId is 0
#5, bbox( 730, 568, 1197, 1861) confidence: 0.923385 classId is 0
#6, bbox(2190, 439, 2443, 1603) confidence: 0.823526 classId is 0
#7, bbox(2709, 784, 2977, 1311) confidence: 0.875400 classId is 26
#8, bbox( 899, 726, 1175, 1243) confidence: 0.842411 classId is 26
#9, bbox(1905, 930, 2113, 1182) confidence: 0.829813 classId is 26
[INFO] graphID:1 is over!
可能问题
问题
前面运行atlas500的目标检测yolov3 demo的时候,一直卡着不动。输出到这里。然后同样的文件,模型在另外一台设备上就没有问题。
现象
Euler:~/test/new_out # ./ObjectDetection -i ./2_4.jpg -t 1 -m ./yolov3.om -g ./graph.config -s 0 -e 0
***start device 0, end device 0***
device = 0, graphID = 1 init success
[mainG_MODEL]:g_modelType: 1
解决方案
这是因为npu和ddk的版本不对。在atlas500上可以用npu-smi info
看版本信息,在linux主机上,去ddk目录下的ddk_info
看版本信息。如果两个版本不对,则统一版本。
- 相关文件下载地址:https://support.huawei.com/enterprise/zh/ai-computing-platform/a500-3000-pid-250702836/software
后续
- 统一之后依然出现同样的问题。需要重新转以下om模型
- 用dog.jpg没有输出,好像是只能检测人,换一张有人的测试图片。