提交 30f90d6a 编写于 作者: W wangguanzhong 提交者: GitHub

fix doc related to CPU (#3048)

上级 0520640d
......@@ -28,7 +28,7 @@ python tools/train.py -c configs/faster_rcnn_r50_1x.yml
```bash
export CPU_NUM=8
export PYTHONPATH=$PYTHONPATH:.
python tools/train.py -c configs/faster_rcnn_r50_1x.yml
python tools/train.py -c configs/faster_rcnn_r50_1x.yml -o use_gpu=false
```
##### Optional arguments
......@@ -80,10 +80,9 @@ python -u tools/train.py -c configs/faster_rcnn_r50_1x.yml \
```bash
export CUDA_VISIBLE_DEVICES=0
# run on GPU with:
export PYTHONPATH=$PYTHONPATH:.
# or run on CPU with:
# export CPU_NUM=1
export CUDA_VISIBLE_DEVICES=0
python tools/eval.py -c configs/faster_rcnn_r50_1x.yml
```
......@@ -98,10 +97,9 @@ python tools/eval.py -c configs/faster_rcnn_r50_1x.yml
- configuration options && assign Dataset path
```bash
export CUDA_VISIBLE_DEVICES=0
# run on GPU with:
export PYTHONPATH=$PYTHONPATH:.
# or run on CPU with:
# export CPU_NUM=1
export CUDA_VISIBLE_DEVICES=0
python -u tools/eval.py -c configs/faster_rcnn_r50_1x.yml \
-o weights=output/faster_rcnn_r50_1x/model_final \
-d dataset/coco
......@@ -109,13 +107,12 @@ python -u tools/eval.py -c configs/faster_rcnn_r50_1x.yml \
- Evaluation with json
```bash
export CUDA_VISIBLE_DEVICES=0
# run on GPU with:
export PYTHONPATH=$PYTHONPATH:.
# or run on CPU with:
# export CPU_NUM=1
export CUDA_VISIBLE_DEVICES=0
python tools/eval.py -c configs/faster_rcnn_r50_1x.yml \
--json_eval \
-f evaluation/
--json_eval \
-f evaluation/
```
The json file must be named bbox.json or mask.json, placed in the `evaluation/` directory. Or without the `-f` parameter, default is the current directory.
......@@ -133,20 +130,18 @@ moment, but it is a planned feature
- Run inference on a single image:
```bash
export CUDA_VISIBLE_DEVICES=0
# run on GPU with:
export PYTHONPATH=$PYTHONPATH:.
# or run on CPU with:
# export CPU_NUM=1
export CUDA_VISIBLE_DEVICES=0
python tools/infer.py -c configs/faster_rcnn_r50_1x.yml --infer_img=demo/000000570688.jpg
```
- Multi-image inference:
```bash
export CUDA_VISIBLE_DEVICES=0
# run on GPU with:
export PYTHONPATH=$PYTHONPATH:.
# or run on CPU with:
# export CPU_NUM=1
export CUDA_VISIBLE_DEVICES=0
python tools/infer.py -c configs/faster_rcnn_r50_1x.yml --infer_dir=demo
```
......@@ -160,26 +155,24 @@ python tools/infer.py -c configs/faster_rcnn_r50_1x.yml --infer_dir=demo
- Output specified directory && Set up threshold
```bash
export CUDA_VISIBLE_DEVICES=0
# run on GPU with:
export PYTHONPATH=$PYTHONPATH:.
# or run on CPU with:
# export CPU_NUM=1
export CUDA_VISIBLE_DEVICES=0
python tools/infer.py -c configs/faster_rcnn_r50_1x.yml \
--infer_img=demo/000000570688.jpg \
--output_dir=infer_output/ \
--draw_threshold=0.5
```
The visualization files are saved in `output` by default, to specify a different
path, simply add a `--output_dir=` flag.
path, simply add a `--output_dir=` flag.
`--draw_threshold` is an optional argument. Default is 0.5. Different thresholds will produce different results depending on the calculation of [NMS](https://ieeexplore.ieee.org/document/1699659)
- Save inference model
```bash
# run on GPU with:
export CUDA_VISIBLE_DEVICES=0
export PYTHONPATH=$PYTHONPATH:.
# or run on CPU with:
# export CPU_NUM=1
python tools/infer.py -c configs/faster_rcnn_r50_1x.yml \
--infer_img=demo/000000570688.jpg \
--save_inference_model
......@@ -192,12 +185,12 @@ Save inference model by set `--save_inference_model`, which can be loaded by Pad
**Q:** Why do I get `NaN` loss values during single GPU training? </br>
**A:** The default learning rate is tuned to multi-GPU training (8x GPUs), it must
be adapted for single GPU training accordingly (e.g., divide by 8).
The calculation rules are as follows,they are equivalent: </br>
be adapted for single GPU training accordingly (e.g., divide by 8).
The calculation rules are as follows,they are equivalent: </br>
| GPU number | Learning rate | Max_iters | Milestones |
| :---------: | :------------: | :-------: | :--------------: |
| GPU number | Learning rate | Max_iters | Milestones |
| :---------: | :------------: | :-------: | :--------------: |
| 2 | 0.0025 | 720000 | [480000, 640000] |
| 4 | 0.005 | 360000 | [240000, 320000] |
| 8 | 0.01 | 180000 | [120000, 160000] |
......
......@@ -29,7 +29,7 @@ python tools/train.py -c configs/faster_rcnn_r50_1x.yml
```bash
export CPU_NUM=8
export PYTHONPATH=$PYTHONPATH:.
python tools/train.py -c configs/faster_rcnn_r50_1x.yml
python tools/train.py -c configs/faster_rcnn_r50_1x.yml -o use_gpu=false
```
##### 可选参数
......@@ -51,7 +51,7 @@ python -u tools/train.py -c configs/faster_rcnn_r50_1x.yml --eval
可通过设置`--eval`在训练epoch中交替执行评估, 评估在每个snapshot_iter时开始。可在配置文件的`snapshot_iter`处修改。
如果验证集很大,测试将会比较耗时,影响训练速度,建议减少评估次数,或训练完再进行评估。
- 设置配置文件参数 && 指定数据集路径
- 设置配置文件参数 && 指定数据集路径
```bash
export CUDA_VISIBLE_DEVICES=0,1,2,3,4,5,6,7
export PYTHONPATH=$PYTHONPATH:.
......@@ -75,10 +75,9 @@ python -u tools/train.py -c configs/faster_rcnn_r50_1x.yml \
```bash
# GPU评估
export CUDA_VISIBLE_DEVICES=0
export PYTHONPATH=$PYTHONPATH:.
# 若使用CPU,则执行
# export CPU_NUM=1
python tools/eval.py -c configs/faster_rcnn_r50_1x.yml
```
......@@ -91,12 +90,11 @@ python tools/eval.py -c configs/faster_rcnn_r50_1x.yml
#### 例子
- 设置配置文件参数 && 指定数据集路径
- 设置配置文件参数 && 指定数据集路径
```bash
# GPU评估
export CUDA_VISIBLE_DEVICES=0
export PYTHONPATH=$PYTHONPATH:.
# or run on CPU with:
# export CPU_NUM=1
python -u tools/eval.py -c configs/faster_rcnn_r50_1x.yml \
-o weights=output/faster_rcnn_r50_1x/model_final \
-d dataset/coco
......@@ -104,13 +102,12 @@ python -u tools/eval.py -c configs/faster_rcnn_r50_1x.yml \
- 通过json文件评估
```bash
# GPU评估
export CUDA_VISIBLE_DEVICES=0
export PYTHONPATH=$PYTHONPATH:.
# or run on CPU with:
# export CPU_NUM=1
python tools/eval.py -c configs/faster_rcnn_r50_1x.yml \
--json_eval \
-f evaluation/
--json_eval \
-f evaluation/
```
json文件必须命名为bbox.json或者mask.json,放在`evaluation/`目录下,或者不加`-f`参数,默认为当前目录。
......@@ -127,20 +124,18 @@ json文件必须命名为bbox.json或者mask.json,放在`evaluation/`目录下
- 单图片推断
```bash
# GPU推断
export CUDA_VISIBLE_DEVICES=0
export PYTHONPATH=$PYTHONPATH:.
# 若使用CPU,则执行
# export CPU_NUM=1
python tools/infer.py -c configs/faster_rcnn_r50_1x.yml --infer_img=demo/000000570688.jpg
```
- 多图片推断
```bash
# GPU推断
export CUDA_VISIBLE_DEVICES=0
export PYTHONPATH=$PYTHONPATH:.
# 若使用CPU,则执行
# export CPU_NUM=1
python tools/infer.py -c configs/faster_rcnn_r50_1x.yml --infer_dir=demo
```
......@@ -154,10 +149,9 @@ python tools/infer.py -c configs/faster_rcnn_r50_1x.yml --infer_dir=demo
- 设置输出路径 && 设置推断阈值
```bash
# GPU推断
export CUDA_VISIBLE_DEVICES=0
export PYTHONPATH=$PYTHONPATH:.
# or run on CPU with:
# export CPU_NUM=1
python tools/infer.py -c configs/faster_rcnn_r50_1x.yml \
--infer_img=demo/000000570688.jpg \
--output_dir=infer_output/ \
......@@ -165,16 +159,15 @@ python tools/infer.py -c configs/faster_rcnn_r50_1x.yml \
```
可视化文件默认保存在`output`中,可通过`--output_dir=`指定不同的输出路径。
可视化文件默认保存在`output`中,可通过`--output_dir=`指定不同的输出路径。
`--draw_threshold` 是个可选参数. 根据 [NMS](https://ieeexplore.ieee.org/document/1699659) 的计算,不同阈值会产生不同的结果。
- 保存推断模型
```bash
# GPU推断
export CUDA_VISIBLE_DEVICES=0
export PYTHONPATH=$PYTHONPATH:.
# or run on CPU with:
# export CPU_NUM=1
python tools/infer.py -c configs/faster_rcnn_r50_1x.yml --infer_img=demo/000000570688.jpg \
--save_inference_model
```
......@@ -185,12 +178,12 @@ python tools/infer.py -c configs/faster_rcnn_r50_1x.yml --infer_img=demo/0000005
## FAQ
**Q:** 为什么我使用单GPU训练loss会出`NaN`? </br>
**A:** 默认学习率是适配多GPU训练(8x GPU),若使用单GPU训练,须对应调整学习率(例如,除以8)。
计算规则表如下所示,它们是等价的: </br>
**A:** 默认学习率是适配多GPU训练(8x GPU),若使用单GPU训练,须对应调整学习率(例如,除以8)。
计算规则表如下所示,它们是等价的: </br>
| GPU数 | 学习率 | 最大轮数 | 变化节点 |
| :---------: | :------------: | :-------: | :--------------: |
| GPU数 | 学习率 | 最大轮数 | 变化节点 |
| :---------: | :------------: | :-------: | :--------------: |
| 2 | 0.0025 | 720000 | [480000, 640000] |
| 4 | 0.005 | 360000 | [240000, 320000] |
| 8 | 0.01 | 180000 | [120000, 160000] |
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册