Tiny SSD目标检测

本文最后更新于:2022年12月11日 晚上

Github: https://github.com/Enderfga/TinySSD_sysu

Tiny SSD: A Tiny Single-shot Detection Deep Convolutional Neural Network for Real-time Embedded Object Detection

This repo contains the code, data and trained models for the paper Tiny SSD: A Tiny Single-shot Detection Deep Convolutional Neural Network for Real-time Embedded Object Detection.

Overview

Tiny SSD is a single-shot detection deep convolutional neural network for real-time embedded object detection. It brings together the efficieny of Fire microarchitecture introduced in SqueezeNet and object detection performance of SSD (Single Shot Object Detector).

Requirements

  • numpy
  • pandas
  • matplotlib
  • opencv-python
  • torch
  • torchvision

How to Install

1
2
conda create -n env python=3.8 -y
conda activate env
1
pip install -r requirements.txt

Description of Files

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
│──main.py                 -> Run models using different models
│──README.md
│──requirements.txt
│──test.py -> Testing Model
│──train.py -> Training Model

├─data
│ │ dataloader.py -> dataloader and transform
│ │ __init__.py
│ │
│ └─detection
│ │ create_train.py -> data preprocessing
│ │
│ ├─background
│ ├─sysu_train
│ │ │ label.csv
│ │ │
│ │ └─images
│ ├─target
│ │ 0.jpg
│ │ 0.png
│ │ 1.png
│ │
│ └─test
1.jpg
2.jpg

├─model
│ │ TinySSD.py -> Definition of the model
│ │ __init__.py
│ │
│ └─checkpoints -> Trained model weights
│ net_100.pkl
└─utils -> utility functions
anchor.py
iou.py
utils.py
__init__.py

Preprocessing

We use /data/detection/background to generate the target detection dataset for our experiments.

Since the generated data is stored in the repository, there is no need to run this step.

Preprocessed Data

1
2
cd data/detection/
python create_train.py

How to Run

Train

1
python main.py --mode=train --batch_size=256 --epochs=100

The checkpoints will be saved in a subfolder of ./model/checkpoints/.

Finetuning from an existing checkpoint

1
python main.py --mode=train --batch_size=256 --epochs=100 --path=[model path]

model path should be a subdirectory in the ./model/checkpoints/ directory, e.g. --path=./model/checkpoints/net_100.pkl

Evaluate

1
python main.py --mode=test --threshold=0.3 --path=./model/checkpoints/net_100.pkl

Results, Outputs, Checkpoints

the ./model/checkpoints/net_100.pkl:class err 1.54e-03, bbox mae 1.90e-03

I used the following methods to improve performance:

  1. HD anti-white detection object to adapt to the test image

  2. Flip and rotate images, etc. to improve generalization performance

  3. soft_nms

  4. smooth_L1

  5. Focal Loss

If we have more classes, we can further improve the model in the following aspects:

  1. When an object is much smaller compared with the image, the model could resize the input image bigger.
  2. There are typically a vast number of negative anchor boxes. To make the class distribution more balanced, we could downsample negative anchor boxes.
  3. In the loss function, assign different weight hyperparameters to the class loss and the offset loss.
  4. Use other methods to evaluate the object detection model, such as those in the single shot multibox detection paper (Liu et al., 2016).

Tiny SSD目标检测
http://enderfga.cn/2022/12/11/ssd/
作者
Enderfga
发布于
2022年12月11日
许可协议