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

# Quick Start

W
wangguanzhong 已提交
5
This tutorial fine-tunes a tiny dataset by pretrained detection model for users to get a model and learn PaddleDetection quickly. The model can be trained in around 20min with good performance.
6 7


Q
qingqing01 已提交
8
- **Note: before started, need to set PYTHONPATH and specifiy the GPU device as follows in Linux platform. For Windows users, also need to set PYTHONPATH correctly.**
9 10

```bash
K
Kaipeng Deng 已提交
11
export PYTHONPATH=$PYTHONPATH:.
Q
qingqing01 已提交
12
export CUDA_VISIBLE_DEVICES=0
13 14
```

Q
qingqing01 已提交
15 16 17
## Data Preparation

Dataset refers to [Kaggle](https://www.kaggle.com/mbkinaci/fruit-images-for-object-detection), which contains 240 images in train dataset and 60 images in test dataset. Data categories are apple, orange and banana. Download [here](https://dataset.bj.bcebos.com/PaddleDetection_demo/fruit-detection.tar) and uncompress the dataset after download, script for data preparation is located at [download_fruit.py](../dataset/fruit/download_fruit.py). Command is as follows:
18 19

```bash
Q
qingqing01 已提交
20
python dataset/fruit/download_fruit.py
W
wangguanzhong 已提交
21 22 23 24 25
```

Training:

```bash
26 27 28
python -u tools/train.py -c configs/yolov3_mobilenet_v1_fruit.yml \
                        --use_tb=True \
                        --tb_log_dir=tb_fruit_dir/scalar \
Q
qingqing01 已提交
29
                        --eval
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
```

Use `yolov3_mobilenet_v1` to fine-tune the model from COCO dataset. Meanwhile, loss and mAP can be observed on tensorboard.  

```bash
tensorboard --logdir tb_fruit_dir/scalar/ --host <host_IP> --port <port_num>
```

Result on tensorboard is shown below:

<div align="center">
  <img src="../demo/tensorboard_fruit.jpg" />
</div>

Model can be downloaded [here](https://paddlemodels.bj.bcebos.com/object_detection/yolov3_mobilenet_v1_fruit.tar)

Evaluation:

```bash
python -u tools/eval.py -c configs/yolov3_mobilenet_v1_fruit.yml
```

Inference:

```bash
W
wangguanzhong 已提交
55 56
python -u tools/infer.py -c configs/yolov3_mobilenet_v1_fruit.yml \
                         -o weights=https://paddlemodels.bj.bcebos.com/object_detection/yolov3_mobilenet_v1_fruit.tar \
57
                         --infer_img=demo/orange_71.jpg
58 59 60 61 62 63 64 65 66 67
```

Inference images are shown below:

<p align="center">
  <img src="../demo/orange_71.jpg" height=400 width=400 hspace='10'/>
  <img src="../demo/orange_71_detection.jpg" height=400 width=400 hspace='10'/>
</p>

For detailed infomation of training and evalution, please refer to [GETTING_STARTED.md](GETTING_STARTED.md).