INSTALL.md 5.8 KB
Newer Older
Q
qingqing01 已提交
1 2
English | [简体中文](INSTALL_cn.md)

3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
# Installation

---
## Table of Contents

- [Introduction](#introduction)
- [PaddlePaddle](#paddlepaddle)
- [Other Dependencies](#other-dependencies)
- [PaddleDetection](#paddle-detection)
- [Datasets](#datasets)


## Introduction

This document covers how to install PaddleDetection, its dependencies
Q
qingqing01 已提交
18
(including PaddlePaddle), together with COCO and Pascal VOC dataset.
19

G
Guanghua Yu 已提交
20
For general information about PaddleDetection, please see [README.md](https://github.com/PaddlePaddle/PaddleDetection/blob/master/).
21 22 23 24


## PaddlePaddle

W
wangguanzhong 已提交
25
Running PaddleDetection requires PaddlePaddle Fluid v.1.6 and later. please follow the instructions in [installation document](http://www.paddlepaddle.org.cn/).
26 27 28 29 30

Please make sure your PaddlePaddle installation was successful and the version
of your PaddlePaddle is not lower than required. Verify with the following commands.

```
K
Kaipeng Deng 已提交
31
# To check PaddlePaddle installation in your Python interpreter
W
wangguanzhong 已提交
32
>>> import paddle.fluid as fluid
K
Kaipeng Deng 已提交
33
>>> fluid.install_check.run_check()
34 35 36 37 38 39 40

# To check PaddlePaddle version
python -c "import paddle; print(paddle.__version__)"
```

### Requirements:

41
- Python2 or Python3 (Only support Python3 for windows)
42 43 44 45 46 47 48 49 50
- CUDA >= 8.0
- cuDNN >= 5.0
- nccl >= 2.1.2


## Other Dependencies

[COCO-API](https://github.com/cocodataset/cocoapi):

K
Kaipeng Deng 已提交
51
COCO-API is needed for running. Installation is as follows:
52 53 54 55 56 57 58 59 60 61

    git clone https://github.com/cocodataset/cocoapi.git
    cd cocoapi/PythonAPI
    # if cython is not installed
    pip install Cython
    # Install into global site-packages
    make install
    # Alternatively, if you do not have permissions or prefer
    # not to install the COCO API into global site-packages
    python setup.py install --user
62 63
    # or with pip
    pip install "git+https://github.com/cocodataset/cocoapi.git#subdirectory=PythonAPI"
64

65 66 67 68 69 70
**Installation of COCO-API in windows:**

    # if cython is not installed
    pip install Cython
    # Because the origin version of cocoapi does not support windows, another version is used which only supports Python3
    pip install git+https://github.com/philferriere/cocoapi.git#subdirectory=PythonAPI
71 72 73 74 75

## PaddleDetection

**Clone Paddle models repository:**

76
You can clone PaddleDetection with the following commands:
77 78

```
79 80
cd <path/to/clone/PaddleDetection>
git clone https://github.com/PaddlePaddle/PaddleDetection.git
81 82 83 84
```

**Install Python dependencies:**

G
Guanghua Yu 已提交
85
Required python packages are specified in [requirements.txt](https://github.com/PaddlePaddle/PaddleDetection/blob/master/requirements.txt), and can be installed with:
86 87 88 89 90

```
pip install -r requirements.txt
```

G
Guanghua Yu 已提交
91
**Specify the current Python path:**
92

G
Guanghua Yu 已提交
93 94 95 96 97
```shell
# In Linux/Mac
export PYTHONPATH=$PYTHONPATH:.
# In windows
set PYTHONPATH=%PYTHONPATH%;.
98
```
G
Guanghua Yu 已提交
99 100 101 102

**Make sure the tests pass:**

```shell
103 104 105 106 107
python ppdet/modeling/tests/test_architectures.py
```

## Datasets

Q
qingqing01 已提交
108
PaddleDetection includes support for [COCO](http://cocodataset.org) and [Pascal VOC](http://host.robots.ox.ac.uk/pascal/VOC/) by default, please follow these instructions to set up the dataset.
109 110 111

**Create symlinks for local datasets:**

Q
qingqing01 已提交
112
Default dataset path in config files is `dataset/coco` and `dataset/voc`, if the
113 114 115 116
datasets are already available on disk, you can simply create symlinks to
their directories:

```
Q
qingqing01 已提交
117 118
ln -sf <path/to/coco> <path/to/paddle_detection>/dataset/coco
ln -sf <path/to/voc> <path/to/paddle_detection>/dataset/voc
119 120
```

K
Kaipeng Deng 已提交
121 122 123 124 125 126 127
For Pascal VOC dataset, you should create file list by:

```
export PYTHONPATH=$PYTHONPATH:.
python dataset/voc/create_list.py
```

128 129 130 131
**Download datasets manually:**

On the other hand, to download the datasets, run the following commands:

Q
qingqing01 已提交
132
- COCO
133 134

```
K
Kaipeng Deng 已提交
135 136
export PYTHONPATH=$PYTHONPATH:.
python dataset/coco/download_coco.py
137 138
```

K
Kaipeng Deng 已提交
139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159
`COCO` dataset with directory structures like this:

  ```
  dataset/coco/
  ├── annotations
  │   ├── instances_train2014.json
  │   ├── instances_train2017.json
  │   ├── instances_val2014.json
  │   ├── instances_val2017.json
  │   |   ...
  ├── train2017
  │   ├── 000000000009.jpg
  │   ├── 000000580008.jpg
  │   |   ...
  ├── val2017
  │   ├── 000000000139.jpg
  │   ├── 000000000285.jpg
  │   |   ...
  |   ...
  ```

Q
qingqing01 已提交
160
- Pascal VOC
161 162

```
K
Kaipeng Deng 已提交
163 164
export PYTHONPATH=$PYTHONPATH:.
python dataset/voc/download_voc.py
K
Kaipeng Deng 已提交
165
python dataset/voc/create_list.py
166 167
```

K
Kaipeng Deng 已提交
168 169 170 171 172 173 174 175 176 177 178 179
`Pascal VOC` dataset with directory structure like this:

  ```
  dataset/voc/
  ├── train.txt
  ├── val.txt
  ├── test.txt
  ├── label_list.txt (optional)
  ├── VOCdevkit/VOC2007
  │   ├── Annotations
  │       ├── 001789.xml
  │       |   ...
W
wangguanzhong 已提交
180
  │   ├── JPEGImages
K
Kaipeng Deng 已提交
181 182 183 184 185 186 187 188
  │       ├── 001789.xml
  │       |   ...
  │   ├── ImageSets
  │       |   ...
  ├── VOCdevkit/VOC2012
  │   ├── Annotations
  │       ├── 003876.xml
  │       |   ...
W
wangguanzhong 已提交
189
  │   ├── JPEGImages
K
Kaipeng Deng 已提交
190 191 192 193 194 195 196 197 198
  │       ├── 003876.xml
  │       |   ...
  │   ├── ImageSets
  │       |   ...
  |   ...
  ```

**NOTE:** If you set `use_default_label=False` in yaml configs, the `label_list.txt`
of Pascal VOC dataset will be read, otherwise, `label_list.txt` is unnecessary and
W
wangguanzhong 已提交
199
the default Pascal VOC label list which defined in
G
Guanghua Yu 已提交
200
[voc\_loader.py](https://github.com/PaddlePaddle/PaddleDetection/blob/master/ppdet/data/source/voc.py) will be used.
K
Kaipeng Deng 已提交
201

202 203 204
**Download datasets automatically:**

If a training session is started but the dataset is not setup properly (e.g,
Q
qingqing01 已提交
205 206
not found in `dataset/coco` or `dataset/voc`), PaddleDetection can automatically
download them from [COCO-2017](http://images.cocodataset.org) and
207 208 209 210 211
[VOC2012](http://host.robots.ox.ac.uk/pascal/VOC), the decompressed datasets
will be cached in `~/.cache/paddle/dataset/` and can be discovered automatically
subsequently.


G
Guanghua Yu 已提交
212
**NOTE:** For further informations on the datasets, please see [READER.md](../advanced_tutorials/READER.md)