SSD: Single Shot MultiBox Detector布置安装与测试[亲测]

SSD是一种使用单一网络进行目标检测的统一框架。本教程详细介绍了如何安装配置环境、准备数据集并训练评估模型。此外还提供了预训练模型下载及模型效果展示。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

原文链接:https://github.com/weiliu89/caffe/tree/ssd

亲测提示:./data/VOC0712/create_data.sh如果出现错误:no caffe.proto,则需要添加Python环境变量。

以下为原文:

 

Introduction

 

SSD is an unified framework for object detection with a single network. You can use the code to train/evaluate a network for object detection task. For more details, please refer to ourarXiv paper and ourslide.

Contents

  1. Installation
  2. Preparation
  3. Train/Eval
  4. Models

Installation

  1. Get the code. We will call the directory that you cloned Caffe into $CAFFE_ROOT

    git clone https://github.com/weiliu89/caffe.git
    cd caffe
    git checkout ssd
  2. Build the code. Please follow Caffe instruction to install all necessary packages and build it.

    # Modify Makefile.config according to your Caffe installation.
    cp Makefile.config.example Makefile.config
    make -j8
    # Make sure to include $CAFFE_ROOT/python to your PYTHONPATH.
    make py
    make test -j8
    # (Optional)
    make runtest -j8

Preparation

  1. Download fully convolutional reduced (atrous) VGGNet. By default, we assume the model is stored in$CAFFE_ROOT/models/VGGNet/

  2. Download VOC2007 and VOC2012 dataset. By default, we assume the data is stored in$HOME/data/

    # Download the data.
    cd $HOME/data
    wget http://host.robots.ox.ac.uk/pascal/VOC/voc2012/VOCtrainval_11-May-2012.tar
    wget http://host.robots.ox.ac.uk/pascal/VOC/voc2007/VOCtrainval_06-Nov-2007.tar
    wget http://host.robots.ox.ac.uk/pascal/VOC/voc2007/VOCtest_06-Nov-2007.tar
    # Extract the data.
    tar -xvf VOCtrainval_11-May-2012.tar
    tar -xvf VOCtrainval_06-Nov-2007.tar
    tar -xvf VOCtest_06-Nov-2007.tar
  3. Create the LMDB file.

    cd $CAFFE_ROOT
    # Create the trainval.txt, test.txt, and test_name_size.txt in data/VOC0712/
    ./data/VOC0712/create_list.sh
    # You can modify the parameters in create_data.sh if needed.
    # It will create lmdb files for trainval and test with encoded original image:
    #   - $HOME/data/VOCdevkit/VOC0712/lmdb/VOC0712_trainval_lmdb
    #   - $HOME/data/VOCdevkit/VOC0712/lmdb/VOC0712_test_lmdb
    # and make soft links at examples/VOC0712/
    ./data/VOC0712/create_data.sh

这里用的脚本实现批处理,可能会出现错误:no module named caffe或者no module named caffe-proto,那是caffe的Python环境变量未配置

sudo gedit  /etc/profile
在最后添加  export PYTHONPATH=$PYTHONPATH:/home/**(您服务器的名字)/caffe/pyhon
保存退出
source ~/.profile
echo $PYTHONPATH #检查环境变量的值

Train/Eval

  1. Train your model and evaluate the model on the fly.

    # It will create model definition files and save snapshot models in:
    #   - $CAFFE_ROOT/models/VGGNet/VOC0712/SSD_300x300/
    # and job file, log file, and the python script in:
    #   - $CAFFE_ROOT/jobs/VGGNet/VOC0712/SSD_300x300/
    # and save temporary evaluation results in:
    #   - $HOME/data/VOCdevkit/results/VOC2007/SSD_300x300/
    # It should reach 77.* mAP at 120k iterations.
    python examples/ssd/ssd_pascal.py

    If you don't have time to train your model, you can download a pre-trained model athere.

  2. Evaluate the most recent snapshot.

    # If you would like to test a model you trained, you can do:
    python examples/ssd/score_ssd_pascal.py
  3. Test your model using a webcam. Note: press esc to stop.

    # If you would like to attach a webcam to a model you trained, you can do:
    python examples/ssd/ssd_pascal_webcam.py

    Here is a demo video of running a SSD500 model trained onMSCOCO dataset.

  4. Check out examples/ssd_detect.ipynb or examples/ssd/ssd_detect.cpp on how to detect objects using a SSD model. Check outexamples/ssd/plot_detections.py on how to plot detection results output by ssd_detect.cpp.

  5. To train on other dataset, please refer to data/OTHERDATASET for more details. We currently add support for COCO and ILSVRC2016. We recommend usingexamples/ssd.ipynb to check whether the new dataset is prepared correctly.

Models

We have provided the latest models that are trained from different datasets. To help reproduce the results inTable 6, most models contain a pretrained.caffemodel file, many .prototxt files, and python scripts.

  1. PASCAL VOC models:

  2. COCO models:

  3. ILSVRC models:

[1]We use examples/convert_model.ipynb to extract a VOC model from a pretrained COCO model.

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值