QUICK_STARTED.md 2.9 KB
Newer Older
1 2 3
English | [简体中文](QUICK_STARTED_cn.md)

# Quick Start
qq_30618961's avatar
qq_30618961 已提交
4
In order to enable users to quickly produce models in a short time and master the use of PaddleDetection, this tutorial uses a pre-trained detection model to finetune small datasets. A good model can be produced in a short period of time. In actual business, it is recommended that users select a suitable model configuration file for adaptation according to their needs.
C
cnn 已提交
5
- **Set GPU**
6
```bash
W
wangguanzhong 已提交
7
export CUDA_VISIBLE_DEVICES=0
8 9
```

C
cnn 已提交
10 11 12 13
## Quick Start
```
# predict an image using PP-YOLO
python tools/infer.py -c configs/ppyolo/ppyolo.yml -o use_gpu=true weights=https://paddlemodels.bj.bcebos.com/object_detection/ppyolo.pdparams --infer_img=demo/000000014439.jpg
W
wangguanzhong 已提交
14
```
C
cnn 已提交
15
the result:
W
wangguanzhong 已提交
16

C
cnn 已提交
17
![](../images/000000014439.jpg)
W
wangguanzhong 已提交
18

19

C
cnn 已提交
20 21 22
## Prepare Dataset
The Dataset is [Kaggle dataset](https://www.kaggle.com/andrewmvd/road-sign-detection) ,Contains 877 images, 4 data categories: crosswalk, speedlimit, stop, trafficlight.
The dataset is divided into training set(contains 701 images) and test set(contains 176 images),[download link](https://paddlemodels.bj.bcebos.com/object_detection/roadsign_voc.tar).
23

C
cnn 已提交
24 25 26 27
```
#
python dataset/roadsign_voc/download_roadsign_voc.py
```
28

C
cnn 已提交
29 30
## Train、Eval、Infer
### 1、Train
31
```
C
cnn 已提交
32 33 34 35
# It will takes about 5 minutes on GPU
# -c set configt file
# -o overwrite the settings in the configuration file
# --eval Evaluate while training, and a model named best_model.pdmodel with the most evaluation results will be automatically saved
36 37


C
cnn 已提交
38
python tools/train.py -c configs/yolov3_mobilenet_v1_roadsign.yml --eval -o use_gpu=true
39 40
```

C
cnn 已提交
41 42
If you want to observe the loss change curve in real time through VisualDL, add --use_vdl=true to the training command, and set the log save path through --vdl_log_dir.
**Note: VisualDL need Python>=3.5**
43

C
cnn 已提交
44 45 46 47
Please install [VisualDL](https://github.com/PaddlePaddle/VisualDL) first
```
python -m pip install visualdl -i https://mirror.baidu.com/pypi/simple
```
48

C
cnn 已提交
49 50 51 52 53 54 55 56 57 58
```
python -u tools/train.py -c configs/yolov3_mobilenet_v1_roadsign.yml \
                        --use_vdl=true \
                        --vdl_log_dir=vdl_dir/scalar \
                        --eval
```
View the change curve in real time through the visualdl command:
```
visualdl --logdir vdl_dir/scalar/ --host <host_IP> --port <port_num>
```
59

C
cnn 已提交
60 61 62 63 64
### 2、Eval
```
# Eval using best_model by default
# -c set config file
# -o overwrite the settings in the configuration file
65

C
cnn 已提交
66
CUDA_VISIBLE_DEVICES=0 python tools/eval.py -c configs/yolov3_mobilenet_v1_roadsign.yml -o use_gpu=true
67 68 69
```


C
cnn 已提交
70
### 3、Infer
71
```
C
cnn 已提交
72 73 74 75
# -c set config file
# -o overwrite the settings in the configuration file
# --infer_img image path
# After the prediction is over, an image of the same name with the prediction result will be generated in the output folder
76

C
cnn 已提交
77 78
python tools/infer.py -c configs/yolov3_mobilenet_v1_roadsign.yml -o use_gpu=true --infer_img=demo/road554.png
```
79

C
cnn 已提交
80
The result is as shown below:
81

C
cnn 已提交
82
![](../images/road554.png)