INSTALL_cn.md 4.8 KB
Newer Older
G
Guanghua Yu 已提交
1
# 安装说明
K
Kaipeng Deng 已提交
2 3

---
W
wangguanzhong 已提交
4
## 目录
K
Kaipeng Deng 已提交
5

G
Guanghua Yu 已提交
6
- [简介](#简介)
7
- [安装PaddlePaddle](#安装PaddlePaddle)
8
- [安装COCO-API](#安装COCO-API)
G
Guanghua Yu 已提交
9
- [PaddleDetection](#PaddleDetection)
K
Kaipeng Deng 已提交
10 11 12 13


## 简介

14
这份文档介绍了如何安装PaddleDetection及其依赖项(包括PaddlePaddle)。
K
Kaipeng Deng 已提交
15

W
wangxinxin08 已提交
16
PaddleDetection的相关信息,请参考[README.md](https://github.com/PaddlePaddle/PaddleDetection/blob/master/README.md).
K
Kaipeng Deng 已提交
17 18


19
## 安装PaddlePaddle
K
Kaipeng Deng 已提交
20

21 22 23 24 25 26 27 28 29 30 31
**环境需求:**

- OS 64位操作系统
- Python2 >= 2.7.15 or Python 3(3.5.1+/3.6/3.7),64位版本
- pip/pip3(9.0.1+),64位版本操作系统是
- CUDA >= 9.0
- cuDNN >= 7.6

如果需要 GPU 多卡训练,请先安装NCCL(Windows暂不支持nccl)。

PaddleDetection 依赖 PaddlePaddle 版本关系:
K
Kaipeng Deng 已提交
32

33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
| PaddleDetection版本 | PaddlePaddle版本  |    备注    |
| :----------------: | :---------------: | :-------: |
|      v0.3          |        >=1.7      |     --    |
|      v0.4          |       >= 1.8.4    |  PP-YOLO依赖1.8.4 |


```
# install paddlepaddle
python -m pip install paddlepaddle -i https://mirror.baidu.com/pypi/simple

# 如果您的机器安装的是CUDA9,请运行以下命令安装
python -m pip install paddlepaddle-gpu==1.8.4.post97 -i https://mirror.baidu.com/pypi/simple

如果您的机器安装的是CUDA10,请运行以下命令安装
python -m pip install paddlepaddle-gpu==1.8.4.post107 -i https://mirror.baidu.com/pypi/simple

如果您的机器是CPU,请运行以下命令安装

python -m pip install paddlepaddle==1.8.4 -i https://mirror.baidu.com/pypi/simple
```
更多的安装方式如conda, docker安装,请参考[安装文档](https://www.paddlepaddle.org.cn/install/quick)中的说明进行操作
K
Kaipeng Deng 已提交
54 55 56 57 58

请确保您的PaddlePaddle安装成功并且版本不低于需求版本。使用以下命令进行验证。

```
# 在您的Python解释器中确认PaddlePaddle安装成功
W
wangguanzhong 已提交
59
>>> import paddle.fluid as fluid
K
Kaipeng Deng 已提交
60 61 62 63 64 65 66
>>> fluid.install_check.run_check()

# 确认PaddlePaddle版本
python -c "import paddle; print(paddle.__version__)"
```


67
## 安装COCO-API
K
Kaipeng Deng 已提交
68

69
`PaddleDetection`在评估时若使用COCO评估标准,则需要安装[COCO-API](https://github.com/cocodataset/cocoapi) ,安装方式如下:
K
Kaipeng Deng 已提交
70

71
    # 安装pycocotools。若使用了虚拟环境,请使用虚拟环境中的pip,或者指定pip绝对路径进行安装
72
    pip install pycocotools
K
Kaipeng Deng 已提交
73

74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92
**如果windows用户按照上面方式安装COCO-API出错,可参考以下方式:**

- 安装 pycocotools-windows
    ```
    # pip install pycocotools-windows
    pip install pycocotools-windows
    ```

    - 如果您遇到ssl问题,请参考[conda issue #8273](https://github.com/conda/conda/issues/8273)  
    - 如果您的网络无法下载安装包:  
        - 设置pip源[pip issue #1736](https://github.com/pypa/pip/issues/1736) 。  
        - 将安装包下载到本地安装。从[pycocotools-windows](https://pypi.org/project/pycocotools-windows/#files) 下载对应安装包,在本地安装:  
        ```
        # 例如安装 pycocotools_windows-2.0.0.2-cp37-cp37m-win_amd64.whl
        pip install pycocotools_windows-2.0.0.2-cp37-cp37m-win_amd64.whl
        ```

-`pycocotools`源码安装
    ```
93 94
    # 若Cython未安装,请安装Cython
    pip install Cython
95

96 97
    # 由于原版cocoapi不支持windows,采用第三方实现版本,该版本仅支持Python3
    pip install git+https://github.com/philferriere/cocoapi.git#subdirectory=PythonAPI
98 99 100 101 102 103
    ```

安装完成后,验证是否安装成功:
```
python -c "import pycocotools"
```
K
Kaipeng Deng 已提交
104 105 106 107 108

## PaddleDetection

**安装Python依赖库:**

109
Python依赖库在[requirements.txt](https://github.com/PaddlePaddle/PaddleDetection/blob/master/requirements.txt) 中给出,可通过如下命令安装:
K
Kaipeng Deng 已提交
110 111 112 113 114

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

115 116 117
**克隆PaddleDetection库:**

您可以通过以下命令克隆PaddleDetection:
K
Kaipeng Deng 已提交
118 119

```
120 121
cd <path/to/clone/PaddleDetection>
git clone https://github.com/PaddlePaddle/PaddleDetection.git
K
Kaipeng Deng 已提交
122
```
123
**提示:**
K
Kaipeng Deng 已提交
124

125
也可以通过 [https://gitee.com/paddlepaddle/PaddleDetection](https://gitee.com/paddlepaddle/PaddleDetection) 克隆。
K
Kaipeng Deng 已提交
126
```
127 128
cd <path/to/clone/PaddleDetection>
git clone https://gitee.com/paddlepaddle/PaddleDetection
K
Kaipeng Deng 已提交
129 130
```

131
**确认测试通过:**
K
Kaipeng Deng 已提交
132 133

```
134
python ppdet/modeling/tests/test_architectures.py
K
Kaipeng Deng 已提交
135 136
```

137
测试通过后会提示如下信息:
K
Kaipeng Deng 已提交
138
```
139 140 141 142
..........
----------------------------------------------------------------------
Ran 12 tests in 2.480s
OK (skipped=2)
K
Kaipeng Deng 已提交
143 144
```

145
**预训练模型预测**
K
Kaipeng Deng 已提交
146

147
使用预训练模型预测图像,快速体验模型预测效果:
K
Kaipeng Deng 已提交
148 149

```
150 151
# use_gpu参数设置是否使用GPU
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_640x640.jpg
K
Kaipeng Deng 已提交
152 153
```

154
会在`output`文件夹下生成一个画有预测结果的同名图像。
K
Kaipeng Deng 已提交
155

156
结果如下图:
157

158
![](../images/000000014439.jpg)