# SSD: Single Shot MultiBox Detector in TensorFlow
SSD is an unified framework for object detection with a single network. It has been originally introduced in this research [article](http://arxiv.org/abs/1512.02325).
This repository contains a TensorFlow re-implementation of the original [Caffe code](https://github.com/weiliu89/caffe/tree/ssd). At present, it only implements VGG-based SSD networks (with 300 and 512 inputs), but the architecture of the project is modular, and should make easy the implementation and training of other SSD variants (ResNet or Inception based for instance). Present TF checkpoints have been directly converted from SSD Caffe models.
The organisation is inspired by the TF-Slim models repository containing the implementation of popular architectures (ResNet, Inception and VGG). Hence, it is separated in three main parts:
* datasets: interface to popular datasets (Pascal VOC, COCO, ...) and scripts to convert the former to TF-Records;
* networks: definition of SSD networks, and common encoding and decoding methods (we refer to the paper on this precise topic);
* pre-processing: pre-processing and data augmentation routines, inspired by original VGG and Inception implementations.
## SSD minimal example
The [SSD Notebook](notebooks/ssd_notebook.ipynb) contains a minimal example of the SSD TensorFlow pipeline. Shortly, the detection is made of two main steps: running the SSD network on the image and post-processing the output using common algorithms (top-k filtering and Non-Maximum Suppression algorithm).
Here are two examples of successful detection outputs:
![](pictures/ex1.png "SSD anchors")
![](pictures/ex2.png "SSD anchors")
To run the notebook you first have to unzip the checkpoint files in ./checkpoint
```bash
unzip ssd_300_vgg.ckpt.zip
```
and then start a jupyter notebook with
```bash
jupyter notebook notebooks/ssd_notebook.ipynb
```
## Datasets
The current version only supports Pascal VOC datasets (2007 and 2012). In order to be used for training a SSD model, the former need to be converted to TF-Records using the `tf_convert_data.py` script:
```bash
DATASET_DIR=./VOC2007/test/
OUTPUT_DIR=./tfrecords
python tf_convert_data.py \
--dataset_name=pascalvoc \
--dataset_dir=${DATASET_DIR} \
--output_name=voc_2007_train \
--output_dir=${OUTPUT_DIR}
```
Note the previous command generated a collection of TF-Records instead of a single file in order to ease shuffling during training.
## Evaluation on Pascal VOC 2007
The present TensorFlow implementation of SSD models have the following performances:
| Model | Training data | Testing data | mAP | FPS |
|--------|:---------:|:------:|:------:|:------:|
| [SSD-300 VGG-based](https://drive.google.com/open?id=0B0qPCUZ-3YwWZlJaRTRRQWRFYXM) | VOC07+12 trainval | VOC07 test | 0.778 | - |
| [SSD-300 VGG-based](https://drive.google.com/file/d/0B0qPCUZ-3YwWUXh4UHJrd1RDM3c/view?usp=sharing) | VOC07+12+COCO trainval | VOC07 test | 0.817 | - |
| [SSD-512 VGG-based](https://drive.google.com/open?id=0B0qPCUZ-3YwWT1RCLVZNN3RTVEU) | VOC07+12+COCO trainval | VOC07 test | 0.837 | - |
We are working hard at reproducing the same performance as the original [Caffe implementation](https://github.com/weiliu89/caffe/tree/ssd)!
After downloading and extracting the previous checkpoints, the evaluation metrics should be reproducible by running the following command:
```bash
EVAL_DIR=./logs/
CHECKPOINT_PATH=./checkpoints/VGG_VOC0712_SSD_300x300_ft_iter_120000.ckpt
python eval_ssd_network.py \
--eval_dir=${EVAL_DIR} \
--dataset_dir=${DATASET_DIR} \
--dataset_name=pascalvoc_2007 \
--dataset_split_name=test \
--model_name=ssd_300_vgg \
--checkpoint_path=${CHECKPOINT_PATH} \
--batch_size=1
```
The evaluation script provides estimates on the recall-precision curve and compute the mAP metrics following the Pascal VOC 2007 and 2012 guidelines.
In addition, if one wants to experiment/test a different Caffe SSD checkpoint, the former can be converted to TensorFlow checkpoints as following:
```sh
CAFFE_MODEL=./ckpts/SSD_300x300_ft_VOC0712/VGG_VOC0712_SSD_300x300_ft_iter_120000.caffemodel
python caffe_to_tensorflow.py \
--model_name=ssd_300_vgg \
--num_classes=21 \
--caffemodel_path=${CAFFE_MODEL}
```
## Training
The script `train_ssd_network.py` is in charged of training the network. Similarly to TF-Slim models, one can pass numerous options to the training process (dataset, optimiser, hyper-parameters, model, ...). In particular, it is possible to provide a checkpoint file which can be use as starting point in order to fine-tune a network.
### Fine-tuning existing SSD checkpoints
The easiest way to fine the SSD model is to use as pre-trained SSD network (VGG-300 or VGG-512). For instance, one can fine a model starting from the former as following:
```bash
DATASET_DIR=./tfrecords
TRAIN_DIR=./logs/
CHECKPOINT_PATH=./checkpoints/ssd_300_vgg.ckpt
python train_ssd_network.py \
--train_dir=${TRAIN_DIR} \
--dataset_dir=${DATASET_DIR} \
--dataset_name=pascalvoc_2012 \
--dataset_split_name=train \
--model_name=ssd_300_vgg \
--checkpoint_path=${CHECKPOINT_PATH} \
--save_summaries_secs=60 \
--save_interval_secs=600 \
--weight_decay=0.0005 \
--optimizer=adam \
--learning_rate=0.001 \
--batch_size=32
```
Note that in addition to the training script flags, one may also want to experiment with data augmentation parameters (random cropping, resolution, ...) in `ssd_vgg_preprocessing.py` or/and network parameters (feature layers, anchors boxes, ...) in `ssd_vgg_300/512.py`
Furthermore, the training script can be combined with the evaluation routine in order to monitor the performance of saved checkpoints on a validation dataset. For that purpose, one can pass to training and validation scripts a GPU memory upper limit such that both can run in parallel on the same device. If some GPU memory is available for the evaluation script, the former can be run in parallel as follows:
```bash
EVAL_DIR=${TRAIN_DIR}/eval
python eval_ssd_network.py \
--eval_dir=${EVAL_DIR} \
--dataset_dir=${DATASET_DIR} \
--dataset_name=pascalvoc_2007 \
--dataset_split_name=test \
--model_name=ssd_300_vgg \
--checkpoint_path=${TRAIN_DIR} \
--wait_for_checkpoints=True \
--batch_size=1 \
--max_num_batches=500
```
### Fine-tuning a network trained on ImageNet
One can also try to build a new SSD model based on standard architecture (VGG, ResNet, Inception, ...) and set up on top of it the `multibox` layers (with specific anchors, ratios, ...). For that purpose, you can fine-tune a network by only loading the weights of the original architecture, and initialize randomly the rest of network. For instance, in the case of the [VGG-16 architecture](http://download.tensorflow.org/models/vgg_16_2016_08_28.tar.gz), one can train a new model as following:
```bash
DATASET_DIR=./tfrecords
TRAIN_DIR=./log/
CHECKPOINT_PATH=./checkpoints/vgg_16.ckpt
python train_ssd_network.py \
--train_dir=${TRAIN_DIR} \
--dataset_dir=${DATASET_DIR} \
--dataset_name=pascalvoc_2007 \
--dataset_split_name=train \
--model_name=ssd_300_vgg \
--checkpoint_path=${CHECKPOINT_PATH} \
--checkpoint_model_scope=vgg_16 \
--checkpoint_exclude_scopes=ssd_300_vgg/conv6,ssd_300_vgg/conv7,ssd_300_vgg/block8,ssd_300_vgg/block9,ssd_300_vgg/block10,ssd_300_vgg/block11,ssd_300_vgg/block4_box,ssd_300_vgg/block7_box,ssd_300_vgg/block8_box,ssd_300_vgg/block9_box,ssd_300_vgg/block10_box,ssd_300_vgg/block11_box \
--trainable_scopes=ssd_300_vgg/conv6,ssd_300_vgg/conv7,ssd_300_vgg/block8,ssd_300_vgg/block9,ssd_300_vgg/block10,ssd_300_vgg/block11,ssd_300_vgg/block4_box,ssd_300_vgg/block7_box,ssd_300_vgg/block8_box,ssd_300_vgg/block9_box,ssd_300_vgg/block10_box,ssd_300_vgg/block11_box \
--save_summaries_secs=60 \
--save_interval_secs=600 \
--weight_decay=0.0005 \
--optimizer=adam \
--learning_rate=0.001 \
没有合适的资源?快使用搜索试试~ 我知道了~
TensorFlow 中的单次多框检测器.zip
共66个文件
py:43个
jpg:13个
txt:2个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 5 浏览量
2024-11-26
10:13:33
上传
评论
收藏 96.61MB ZIP 举报
温馨提示
SSDTensorFlow 中的单次多框检测器SSD 是一个使用单一网络进行对象检测的统一框架。它最初在本研究论文中介绍过。此存储库包含原始Caffe 代码的 TensorFlow 重新实现。目前,它仅实现基于 VGG 的 SSD 网络(具有 300 和 512 个输入),但该项目的架构是模块化的,应该可以轻松实现和训练其他 SSD 变体(例如基于 ResNet 或 Inception)。目前的 TF 检查点已直接从 SSD Caffe 模型转换而来。该组织受到 TF-Slim 模型库的启发,其中包含流行架构(ResNet、Inception 和 VGG)的实现。因此,它分为三个主要部分数据集流行数据集(Pascal VOC、COCO 等)的接口以及将前者转换为 TF-Records 的脚本网络SSD 网络的定义,以及常见的编码和解码方法(我们参考关于这个精确主题的论文)预处理预处理和数据增强程序,受到原始 VGG 和 Inception 实现的启发。SSD 最小示例SSD Notebook包含 SSD TensorFlow 管道的最小示例。简而言之,检测由两
资源推荐
资源详情
资源评论
收起资源包目录
TensorFlow 中的单次多框检测器.zip (66个子文件)
caffe_to_tensorflow.py 2KB
pictures
ex2.png 410KB
ex1.png 398KB
标签.txt 54B
deployment
__init__.py 1B
model_deploy.py 26KB
train_ssd_network.py 18KB
COMMANDS.md 12KB
inspect_checkpoint.py 5KB
demo
person.jpg 111KB
horses.jpg 130KB
000002.jpg 111KB
dog.jpg 160KB
000003.jpg 120KB
eagle.jpg 139KB
000001.jpg 77KB
000008.jpg 81KB
000010.jpg 104KB
000004.jpg 100KB
street.jpg 437KB
000006.jpg 78KB
000022.jpg 100KB
nets
__init__.py 1B
ssd_vgg_512.py 25KB
inception.py 1KB
nets_factory.py 3KB
xception.py 12KB
ssd_vgg_300.py 31KB
custom_layers.py 6KB
np_methods.py 9KB
caffe_scope.py 3KB
vgg.py 10KB
ssd_common.py 17KB
inception_v3.py 27KB
inception_resnet_v2.py 12KB
datasets
__init__.py 1B
pascalvoc_common.py 5KB
pascalvoc_2007.py 3KB
cifar10.py 3KB
pascalvoc_2012.py 3KB
dataset_factory.py 2KB
dataset_utils.py 5KB
pascalvoc_to_tfrecords.py 8KB
imagenet.py 7KB
资源内容.txt 1KB
eval_ssd_network.py 16KB
checkpoints
ssd_300_vgg.ckpt.zip 93.19MB
.gitignore 444B
tf_convert_data.py 2KB
preprocessing
__init__.py 1B
inception_preprocessing.py 14KB
preprocessing_factory.py 2KB
tf_image.py 12KB
vgg_preprocessing.py 14KB
ssd_vgg_preprocessing.py 17KB
README.md 9KB
tf_extended
__init__.py 966B
math.py 3KB
bboxes.py 21KB
tensors.py 4KB
metrics.py 17KB
image.py 0B
notebooks
ssd_tests.ipynb 509KB
visualization.py 5KB
ssd_notebook.ipynb 603KB
tf_utils.py 10KB
共 66 条
- 1
资源评论
徐浪老师
- 粉丝: 8203
- 资源: 9366
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 《Linux操作系统应用》考试试卷及答案.doc
- 《办公自动化》课程考核说明、考纲及部分选择题..doc
- 《VB语言程序设计基础》课程教学大纲..doc
- 《电子商务基础》试卷2010及答案.doc
- 《Web程序设计》课后题答案.doc
- 《互联网金融风险专项整治工作实施方案》专业解读.doc
- 【plc资料】2012年国家人保部可编程序(PLC)设计师职业资格培训考试-全国两大城市北京深圳.doc
- 《微计算机技术》形成性考核册参考答案.doc
- java物联网智能家居软硬件系统源码数据库 MySQL源码类型 WebForm
- 用于寻找多网卡主机方便内网跨网段渗透避免瞎打找不到核心网.zip
- 00计算机应用基础形成性考核册.doc
- 0电子商务法律与法规形成性考核册答案.doc
- 1.互联网项目管理情境训练营.doc
- 3.2.3-2-课程考试-考核方式改革方案样例-可编程控制器..doc
- 1-通信自动化专业管理规定.doc
- 1谈谈计算机怎样解几何题.doc
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功