SSD目标检测

SSD目标检测

SSD是继yolo又一神作,对其理论这边就不介绍了,给上链接:
http://blog.csdn.net/u011534057/article/details/52733686

这边只讲代码编译,最近想试一下SSD的速度,看看在CPU端每秒能够检测几张图。原本一直编译C++(CAFFE)版本的,但是C++小白遇到很多问题,在同事的帮助下还是未能解决。后就选择编译TF的SSD,https://github.com/balancap/SSD-Tensorflow
按照网上的教程,测试很简单,这边只是对其作了简单的修改,直观的了解速度:

用jupyter notebook 打开SSD-Tensorflow/notebooks/ssd_notebook.ipynb

将:

gpu_options = tf.GPUOptions(allow_growth=True)
config = tf.ConfigProto(log_device_placement=False, gpu_options=gpu_options)
isess = tf.InteractiveSession(config=config)

注释掉,修改成

isess = tf.InteractiveSession()

(这里测试只用CPU)

最后显示部分也进行了修改,不适用原有的显示方式,而是调用摄像头,代码如下:

def Imshow_img(img, classes, scores, bboxes):
    height = img.shape[0]
    width = img.shape[1]
    for i in range(len(classes)):
        cls_id = int(classes[i])
        if cls_id >= 0:
            score = scores[i]
        ymin = int(bboxes[i, 0] * height)
        xmin = int(bboxes[i, 1] * width)
        ymax = int(bboxes[i, 2] * height)
        xmax = int(bboxes[i, 3] * width)
        cv2.rectangle(img,(xmin, ymin), (xmax, ymax), (55,255,155),5)
        text  = [str(rclasses[i]) +'|'+ str(rscores[i])]
        cv2.putText(img,  text[0], (xmin, ymin-2), cv2.FONT_HERSHEY_TRIPLEX, 1, (255, 0 ,0), thickness = 1, lineType = 1)
import cv2  
import numpy
cap = cv2.VideoCapture(0)
while(1):
    # get a frame
    ret, frame = cap.read()
    rclasses, rscores, rbboxes =  process_image(frame)
    Imshow_img(frame, rclasses, rscores, rbboxes)
    # show a frame
    cv2.imshow("capture", frame)
    if cv2.waitKey(1) & 0xFF == ord('q'):
        break
cap.release()
cv2.destroyAllWindows() 

如果想显示时间,也可以加上测试时间显示。
SSD的目标检测时间目前还是无法在嵌入式端使用,Google最近发布的tensorflow object detection API,将SSD和MobileNet结合,效果应该比SSD+VGG的好,后面会测试一下。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值