getting_started_en.md 2.4 KB
Newer Older
S
refine  
shippingwang 已提交
1
# Getting Started
S
shippingwang 已提交
2
---
S
refine  
shippingwang 已提交
3
Please refer to [Installation](install.md) to setup environment at first, and prepare ImageNet1K data by following the instruction mentioned in the [data](data.md)
S
shippingwang 已提交
4

S
refine  
shippingwang 已提交
5
## Setup
S
shippingwang 已提交
6

S
refine  
shippingwang 已提交
7
**Setup PYTHONPATH:**
S
shippingwang 已提交
8 9 10 11 12

```bash
export PYTHONPATH=path_to_PaddleClas:$PYTHONPATH
```

S
refine  
shippingwang 已提交
13
## Training and validating
S
shippingwang 已提交
14

S
refine  
shippingwang 已提交
15
PaddleClas support `tools/train.py` and `tools/eval.py` to start training and validating.
S
shippingwang 已提交
16

S
refine  
shippingwang 已提交
17
### Training
S
shippingwang 已提交
18 19

```bash
S
refine  
shippingwang 已提交
20 21
# PaddleClas use paddle.distributed.launch to start multi-cards and multiprocess training.
# Set FLAGS_selected_gpus to indicate GPU cards
S
shippingwang 已提交
22 23 24 25 26 27 28

python -m paddle.distributed.launch \
    --selected_gpus="0,1,2,3" \
    tools/train.py \
        -c ./configs/ResNet/ResNet50_vd.yaml
```

S
refine  
shippingwang 已提交
29
- log:
S
shippingwang 已提交
30 31 32 33 34

```
epoch:0    train    step:13    loss:7.9561    top1:0.0156    top5:0.1094    lr:0.100000    elapse:0.193
```

S
refine  
shippingwang 已提交
35
add -o params to update configuration
S
shippingwang 已提交
36 37 38 39 40 41 42

```bash
python -m paddle.distributed.launch \
    --selected_gpus="0,1,2,3" \
    tools/train.py \
        -c ./configs/ResNet/ResNet50_vd.yaml \
        -o use_mix=1 \
S
refine  
shippingwang 已提交
43
    --vdl_dir=./scalar/
S
shippingwang 已提交
44 45 46

```

S
refine  
shippingwang 已提交
47
- log:
S
shippingwang 已提交
48 49 50 51 52

```
epoch:0    train    step:522    loss:1.6330    lr:0.100000    elapse:0.210
```

S
refine  
shippingwang 已提交
53
or modify configuration directly to config fileds, please refer to [config](config.md) for more details.
S
shippingwang 已提交
54

S
refine  
shippingwang 已提交
55
use visuldl to visulize training loss in the real time
S
shippingwang 已提交
56 57 58 59 60 61 62

```bash
visualdl --logdir ./scalar --host <host_IP> --port <port_num>

```


S
refine  
shippingwang 已提交
63
### finetune
S
shippingwang 已提交
64

S
refine  
shippingwang 已提交
65
* please refer to [Trial](./quick_start.md) for more details.
S
shippingwang 已提交
66

littletomatodonkey's avatar
littletomatodonkey 已提交
67
### validation
S
shippingwang 已提交
68 69 70 71 72 73 74

```bash
python tools/eval.py \
    -c ./configs/eval.yaml \
    -o ARCHITECTURE.name="ResNet50_vd" \
    -o pretrained_model=path_to_pretrained_models

S
refine  
shippingwang 已提交
75 76
modify `configs/eval.yaml filed: `ARCHITECTURE.name` and filed: `pretrained_model` to config valid model or add -o params to update config directly.

S
shippingwang 已提交
77

S
refine  
shippingwang 已提交
78
**NOTE: ** when loading the pretrained model, should ignore the suffix ```.pdparams```
S
shippingwang 已提交
79

S
refine  
shippingwang 已提交
80 81 82 83 84
## Predict

PaddlePaddle supprot three predict interfaces
Use predicator interface to predict
First, export inference model
S
shippingwang 已提交
85 86 87

```bash
python tools/export_model.py \
S
refine  
shippingwang 已提交
88 89 90
    --model=model_name \
    --pretrained_model=pretrained_model_dir \
    --output_path=save_inference_dir
S
shippingwang 已提交
91 92

```
S
refine  
shippingwang 已提交
93 94
Second, start predicator enginee:

S
shippingwang 已提交
95 96
```bash
python tools/infer/predict.py \
S
refine  
shippingwang 已提交
97 98 99
    -m model_path \
    -p params_path \
    -i image path \
S
shippingwang 已提交
100 101 102
    --use_gpu=1 \
    --use_tensorrt=True
```
S
refine  
shippingwang 已提交
103
please refer to [inference](../extension/paddle_inference.md) for more details.