尝试直接从官网移植
1.
需要将include/darknet.h文件copy到src
2.
发现老是报错,说代码有问题network net = parse_network_cfg(cfgfile);报错
(network和network*的问题),查看源代码,代码应该无问题。。。。
在windows下使用vs编译源代码,看是否能行:发现vs2015安装有问题,一打开软件就软件卡住了,并且可能会导致vs2013使用也出现问题,bug!!
装了几个版本的vs2015都不行,我已经放弃了!!!
3.
选用该处的代码,对不必要的代码做删减,尝试使用SDx编译,发现不行,如下的语法解释不了:
#define YOLODLL_API __declspec(dllexport)...YOLODLL_API Detector(std::string cfg_filename, std::string weight_filename, int gpu_id = 0);YOLODLL_API ~Detector();

4.
还是选用原始代码,将network net都修改为network *net,然后将net.修改为net->,此类修改(发现源代码中其实也是有部分改了,如yolo.c,有部分没有改)
再将example中的代码和src内的代码都加入源中进行编译
yolo_v2_class.cpp和yolo_v2_class.h,yolo_console_dll.cpp删掉
编译通过,但是运行错误
root@xilinx-zc706-2017_2:/mnt# ./YOLOv2.elf yolo test cfg/tiny-yolo.cfg tiny-yolo.weights data/dog.jpg
layer     filters    size              input                output0 conv     16  3 x 3 / 1   416 x 416 x   3   ->   416 x 416 x  161 max          2 x 2 / 2   416 x 416 x  16   ->   208 x 208 x  162 conv     32  3 x 3 / 1   208 x 208 x  16   ->   208 x 208 x  323 max          2 x 2 / 2   208 x 208 x  32   ->   104 x 104 x  324 conv     64  3 x 3 / 1   104 x 104 x  32   ->   104 x 104 x  645 max          2 x 2 / 2   104 x 104 x  64   ->    52 x  52 x  646 conv    128  3 x 3 / 1    52 x  52 x  64   ->    52 x  52 x 1287 max          2 x 2 / 2    52 x  52 x 128   ->    26 x  26 x 1288 conv    256  3 x 3 / 1    26 x  26 x 128   ->    26 x  26 x 2569 max          2 x 2 / 2    26 x  26 x 256   ->    13 x  13 x 25610 conv    512  3 x 3 / 1    13 x  13 x 256   ->    13 x  13 x 51211 max          2 x 2 / 1    13 x  13 x 512   ->    13 x  13 x 51212 conv   1024  3 x 3 / 1    13 x  13 x 512   ->    13 x  13 x102413 conv    512  3 x 3 / 1    13 x  13 x1024   ->    13 x  13 x 51214 conv    425  1 x 1 / 1    13 x  13 x 512   ->    13 x  13 x 42515 detection
mask_scale: Using default '1.000000'
Loading weights from tiny-yolo.weights...Done!
data/dog.jpg: Predicted in 36.919891 seconds.
Not compiled with OpenCV, saving to predictions.png instead
root@xilinx-zc706-2017_2:/mnt#

5.
研究发现正确的指令应该是:
./darknet detector test cfg/voc.data cfg/tiny-yolo-voc.cfg tiny-yolo-voc.weights data/dog.jpg

或者(二者等效)

./darknet detect cfg/voc.data cfg/tiny-yolo-voc.cfg tiny-yolo-voc.weights data/dog.jpg

才可,与某一开源代码中的运行方法不一致。

换成tiny-yolo.cfg不行,理论上应该将voc.data换为coco.data,但实际换了之后仍然没有检测结果。
以上均应该是cfg文件、weight文件、data文件不匹配造成的。

6.
最后按照这里的源代码移植编译一次,将data.c中的rand_s(&Num)函数修改为Num=rand()编译通过后(rand_s是vs的函数,fpga上编译不通过),终于成功了结果如下:
root@xilinx-zc706-2017_2:/mnt# ./detect.elf detector test cfg/voc.data cfg/tiny-yolo-voc.cfg tiny-yolo-voc.weights data/dog.jpg
layer     filters    size              input                output0 conv     16  3 x 3 / 1   416 x 416 x   3   ->   416 x 416 x  161 max          2 x 2 / 2   416 x 416 x  16   ->   208 x 208 x  162 conv     32  3 x 3 / 1   208 x 208 x  16   ->   208 x 208 x  323 max          2 x 2 / 2   208 x 208 x  32   ->   104 x 104 x  324 conv     64  3 x 3 / 1   104 x 104 x  32   ->   104 x 104 x  645 max          2 x 2 / 2   104 x 104 x  64   ->    52 x  52 x  646 conv    128  3 x 3 / 1    52 x  52 x  64   ->    52 x  52 x 1287 max          2 x 2 / 2    52 x  52 x 128   ->    26 x  26 x 1288 conv    256  3 x 3 / 1    26 x  26 x 128   ->    26 x  26 x 2569 max          2 x 2 / 2    26 x  26 x 256   ->    13 x  13 x 25610 conv    512  3 x 3 / 1    13 x  13 x 256   ->    13 x  13 x 51211 max          2 x 2 / 1    13 x  13 x 512   ->    13 x  13 x 51212 conv   1024  3 x 3 / 1    13 x  13 x 512   ->    13 x  13 x102413 conv   1024  3 x 3 / 1    13 x  13 x1024   ->    13 x  13 x102414 conv    125  1 x 1 / 1    13 x  13 x1024   ->    13 x  13 x 12515 detection
Loading weights from tiny-yolo-voc.weights...Done!
data/dog.jpg: Predicted in 47.318359 seconds.
car: 76%
bicycle: 24%
dog: 79%
Not compiled with OpenCV, saving to predictions.png instead
root@xilinx-zc706-2017_2:/mnt#

data/person.jpg: Predicted in 47.314194 seconds.
person: 69%
sheep: 82%
cow: 52%
Not compiled with OpenCV, saving to predictions.png instead

小结:
使用
root@xilinx-zc706-2017_2:/mnt# ./detect.elf detector test cfg/coco.data cfg/tiny-yolo.cfg tiny-yolo.weights data/dog.jpg
root@xilinx-zc706-2017_2:/mnt# ./detect.elf detect cfg/tiny-yolo.cfg tiny-yolo.weights data/dog.jpg
root@xilinx-zc706-2017_2:/mnt# ./detect.elf yolo est cfg/tiny-yolo.cfg tiny-yolo.weights data/dog.jpg

均能读出cfg文件,加载weights,运行37s,但是检测结果不显示,要么是指令有误,要么是配置文件有误。

使用
root@xilinx-zc706-2017_2:/mnt# ./detect.elf yolo test cfg/tiny-yolo-voc.cfg tiny-yolo-voc.weights data/person.jpg

能读出cfg文件,加载weights,运行47s,但是检测结果不显示。可能原因是没有指明voc.data,导致的问题

使用
root@xilinx-zc706-2017_2:/mnt# ./detect.elf detect cfg/tiny-yolo-voc.cfg tiny-yolo-voc.weights data/person.jpg

能读出cfg文件,加载weights,运行47s,但是检测结果不正确。可能原因是没有指明voc.data,导致的list name错乱,如下:

root@xilinx-zc706-2017_2:/mnt# ./detect.elf detect cfg/tiny-yolo-voc.cfg tiny-yolo-voc.weights data/person.jpg
layer     filters    size              input                output0 conv     16  3 x 3 / 1   416 x 416 x   3   ->   416 x 416 x  161 max          2 x 2 / 2   416 x 416 x  16   ->   208 x 208 x  162 conv     32  3 x 3 / 1   208 x 208 x  16   ->   208 x 208 x  323 max          2 x 2 / 2   208 x 208 x  32   ->   104 x 104 x  324 conv     64  3 x 3 / 1   104 x 104 x  32   ->   104 x 104 x  645 max          2 x 2 / 2   104 x 104 x  64   ->    52 x  52 x  646 conv    128  3 x 3 / 1    52 x  52 x  64   ->    52 x  52 x 1287 max          2 x 2 / 2    52 x  52 x 128   ->    26 x  26 x 1288 conv    256  3 x 3 / 1    26 x  26 x 128   ->    26 x  26 x 2569 max          2 x 2 / 2    26 x  26 x 256   ->    13 x  13 x 25610 conv    512  3 x 3 / 1    13 x  13 x 256   ->    13 x  13 x 51211 max          2 x 2 / 1    13 x  13 x 512   ->    13 x  13 x 51212 conv   1024  3 x 3 / 1    13 x  13 x 512   ->    13 x  13 x102413 conv   1024  3 x 3 / 1    13 x  13 x1024   ->    13 x  13 x102414 conv    125  1 x 1 / 1    13 x  13 x1024   ->    13 x  13 x 12515 detection
Loading weights from tiny-yolo-voc.weights...Done!
data/person.jpg: Predicted in 47.305035 seconds.
bird: 69%
dog: 82%
traffic light: 52%
Not compiled with OpenCV, saving to predictions.png instead

使用完整、正确的方式,检测的结果为:
root@xilinx-zc706-2017_2:/mnt# ./detect.elf detector test cfg/voc.data cfg/tiny-yolo-voc.cfg tiny-yolo-voc.weights data/person.jpg
layer     filters    size              input                output0 conv     16  3 x 3 / 1   416 x 416 x   3   ->   416 x 416 x  161 max          2 x 2 / 2   416 x 416 x  16   ->   208 x 208 x  162 conv     32  3 x 3 / 1   208 x 208 x  16   ->   208 x 208 x  323 max          2 x 2 / 2   208 x 208 x  32   ->   104 x 104 x  324 conv     64  3 x 3 / 1   104 x 104 x  32   ->   104 x 104 x  645 max          2 x 2 / 2   104 x 104 x  64   ->    52 x  52 x  646 conv    128  3 x 3 / 1    52 x  52 x  64   ->    52 x  52 x 1287 max          2 x 2 / 2    52 x  52 x 128   ->    26 x  26 x 1288 conv    256  3 x 3 / 1    26 x  26 x 128   ->    26 x  26 x 2569 max          2 x 2 / 2    26 x  26 x 256   ->    13 x  13 x 25610 conv    512  3 x 3 / 1    13 x  13 x 256   ->    13 x  13 x 51211 max          2 x 2 / 1    13 x  13 x 512   ->    13 x  13 x 51212 conv   1024  3 x 3 / 1    13 x  13 x 512   ->    13 x  13 x102413 conv   1024  3 x 3 / 1    13 x  13 x1024   ->    13 x  13 x102414 conv    125  1 x 1 / 1    13 x  13 x1024   ->    13 x  13 x 12515 detection
Loading weights from tiny-yolo-voc.weights...Done!
data/person.jpg: Predicted in 47.306183 seconds.
person: 69%
sheep: 82%
cow: 52%
Not compiled with OpenCV, saving to predictions.png instead

也可以用来做分类:
root@xilinx-zc706-2017_2:/mnt# ./detect.elf classifier predict cfg/imagenet1k.data cfg/darknet.cfg darknet.weights data/dog.jpg
layer     filters    size              input                output0 conv     16  3 x 3 / 1   224 x 224 x   3   ->   224 x 224 x  161 max          2 x 2 / 2   224 x 224 x  16   ->   112 x 112 x  162 conv     32  3 x 3 / 1   112 x 112 x  16   ->   112 x 112 x  323 max          2 x 2 / 2   112 x 112 x  32   ->    56 x  56 x  324 conv     64  3 x 3 / 1    56 x  56 x  32   ->    56 x  56 x  645 max          2 x 2 / 2    56 x  56 x  64   ->    28 x  28 x  646 conv    128  3 x 3 / 1    28 x  28 x  64   ->    28 x  28 x 1287 max          2 x 2 / 2    28 x  28 x 128   ->    14 x  14 x 1288 conv    256  3 x 3 / 1    14 x  14 x 128   ->    14 x  14 x 2569 max          2 x 2 / 2    14 x  14 x 256   ->     7 x   7 x 25610 conv    512  3 x 3 / 1     7 x   7 x 256   ->     7 x   7 x 51211 max          2 x 2 / 2     7 x   7 x 512   ->     4 x   4 x 51212 conv   1024  3 x 3 / 1     4 x   4 x 512   ->     4 x   4 x102413 conv   1000  1 x 1 / 1     4 x   4 x1024   ->     4 x   4 x100014 avg                        4 x   4 x1000   ->  100015 softmax                                        100016 cost                                           1000
Loading weights from darknet.weights...Done!
298 224
data/dog.jpg: Predicted in 7.463062 seconds.
malamute: 0.222252
Norwegian elkhound: 0.101390
German shepherd: 0.089522
keeshond: 0.068499
Eskimo dog: 0.067451

转载于:https://www.cnblogs.com/Osler/p/8780614.html

YOLO算法的ZYNQ移植尝试(SDx方法、ARM部分)相关推荐

  1. 卷积神经网络三:目标检测和yolo算法

    1 目标定位 对象检测,它是计算机视觉领域中一个新兴的应用方向,相比前两年,它的性能越来越好.在构建对象检测之前,我们先了解一下对象定位,首先我们看看它的定义. 图片分类任务我们已经熟悉了,就是算法遍 ...

  2. 自动驾驶-车辆检测(YOLO算法)

    学习目标: ​ 1.在汽车检测数据集上应用目标检测 ​ 2.处理边界框 运行以下单元下载有有助于实现车辆检测的包和依赖项. import argparse import os import matpl ...

  3. 3.9 YOLO算法-深度学习第四课《卷积神经网络》-Stanford吴恩达教授

    ←上一篇 ↓↑ 下一篇→ 3.8 Anchor Boxes 回到目录 3.10 候选区域 YOLO 算法 (Putting it together: YOLO algorithm) 你们已经学到对象检 ...

  4. 目标检测 /yolo算法原理的详解

    前言 谈到计算机视觉时,我们都会联想到图像分类,图像分类是计算机视觉最基本的任务之一,在图像分类的基础上,我们还有更复杂的任务,比如目标检测,物体定位,图像分割等,本文主要讲目标检测,目标检测是分类与 ...

  5. yolo算法的优缺点分析_yolo算法介绍

    yolo算法介绍 (2020-06-06 16:49:28) 把Yolo模型搞清楚后不得不再次为人类的智慧感慨,一个巧妙的模型. 要想理解Yolo我们先要搞清楚Yolo到底要解决一个什么问题,解决这个 ...

  6. 深度学习目标检测系列:一文弄懂YOLO算法|附Python源码

    在之前的文章中,介绍了计算机视觉领域中目标检测的相关方法--RCNN系列算法原理,以及Faster RCNN的实现.这些算法面临的一个问题,不是端到端的模型,几个构件拼凑在一起组成整个检测系统,操作起 ...

  7. yolo算法的优缺点分析_YOLO算法详细解析(一)

    目标检测和目标分类 图像识别算法是计算机视觉的基础算法,例如VGG,GoogLeNet,ResNet等,这类算法主要是判断图片中目标的种类. 目标检测算法和图像识别算法类似,但是目标检测算法不仅要识别 ...

  8. 【转载】tcpdump的移植和使用方法

    用简单的话来定义tcpdump,就是:dump the traffic on a network,根据使用者的定义对网络上的数据包进行截获的包分析工具. tcpdump可以将网络中传送的数据包的&qu ...

  9. 目标检测与YOLO算法(用Python实现目标检测)

    最近在听Andrew Ng讲解目标检测的视频,包括目标定位,特征点检测,卷积的滑动窗口的实现,Bounding Box预测,交并比,非极大值抑制,AnchorBoxes,YOLO算法以及候选区域,并通 ...

最新文章

  1. Tomcat:Connection reset by peer: socket write error
  2. c++并行计算库TBB和PPL的基本用法
  3. NLP之TEA:基于SnowNLP实现自然语言处理之对输入文本进行情感分析(分词→词性标注→拼音简繁转换→情感分析→测试)
  4. c语言保存图片image,iOS 保存图片到【自定义相册】
  5. 计算机科学学院陈瑜,浙江大学城市学院计算机与计算科学学院 计算机科学与技术 陈则伦...
  6. 控制台ui_设计下一代控制台UI
  7. windows中启动 java -jar 后台运行程序
  8. 前牙正常覆盖是多少_深覆合和深覆盖两者怎么区分?花两分钟进来了解一下
  9. mount -o nolock
  10. 经典神经网络 -- RetinaNet的Focal_Loss : 设计原理与pytorch实现
  11. hive replace_Hive新增字段(column)后,旧分区无法更新数据问题
  12. 内置的常用层:LayerColor、LayerGradient
  13. PMP课程笔记:第13章 项目相关方管理
  14. oracle临时表经常被锁_linux安装oracle
  15. oracle数据库字符集US7ASCII,在java中处理中文问题
  16. 备战双11,送你一份解压壁纸!
  17. 如何理解工程测量中的各种误差
  18. 20154312 曾林 EXP7 网络欺诈防范
  19. 银河麒麟操作系统离线安装nginx
  20. MySql数据查重、去重的实现

热门文章

  1. 复旦考研计算机技术,复旦大学计算机技术(专业学位)考研难吗
  2. Java招聘数据统计_拉勾网2019年3月20日招聘数据统计
  3. Android开发笔记(六十六)自定义对话框
  4. Android开发笔记(四十)组件通讯工具Intent
  5. Android开发笔记(二十八)利用Application实现内存读写
  6. centos 添加路由命令_详解CentOS 6.4 添加永久静态路由所有方法汇总
  7. 极速安装JumpServer - 官方文档版
  8. [译] 如何学习 CSS
  9. Vue 项目创建并发布
  10. C#进行MapX二次开发之图层操作