GitXplorerGitXplorer
t

paddle2-demo

public
0 stars
0 forks
0 issues

Commits

List of commits on branch master.
Verified
54f04e2f76611a55679a2b88a8770db631824ab8

README_slides.md

tthinkall committed 4 years ago
Verified
0e9d9d724201cae9465794ea994dce4053fac4af

Delete README_slides.html

tthinkall committed 4 years ago
Unverified
33184662688b19a3c7f091ce3570f425a4f09a7d

feat: finish slides and readme

tthinkall committed 4 years ago
Unverified
da6e6a08ae06ce968ded8ba91fc2ce50a6ed821d

feat: finish slides

tthinkall committed 4 years ago
Unverified
dd06f16ae9981bd950c01fd5f3baf4d6fec59bf8

feat: add all in one gradio demo

tthinkall committed 4 years ago
Unverified
71088aee3f18897ed80c735b987e76e63d7433de

feat: add gradio demo

tthinkall committed 4 years ago

README

The README file for this repository.

A Quick Guide on How to Launch AI with Paddle tools

[toc]

Demo codes for AI models implemented with PaddlePaddle.

Preparation

Paddle Installation

Installation Guide

Choose CPU/GPU

Install CPU Version of PaddlePaddle if no NVIDIA® GPU.

Install GPU Version with below conditions:

CUDA toolkit 10.1/10.2 with cuDNN v7.6.5+

CUDA toolkit 11.2 with cuDNN v8.1.1

Hardware devices with GPU computing power over 3.0

Installation Step

You can choose the following version of PaddlePaddle to start installation:

CPU Versoion of PaddlePaddle

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

GPU Version of PaddlePaddle

  • PaddlePaddle for CUDA 10.1
python -m pip install paddlepaddle-gpu==2.1.0.post101 -f https://paddlepaddle.org.cn/whl/mkl/stable.html
  • PaddlePaddle for CUDA 10.2
python -m pip install paddlepaddle-gpu -i https://mirror.baidu.com/pypi/simple
  • PaddlePaddle for CUDA 11.2
python -m pip install paddlepaddle-gpu==2.1.0.post112 -f https://paddlepaddle.org.cn/whl/mkl/stable.html

Verify installation

After the installation is complete, you can use python to enter the Python interpreter and then use import paddle and paddle.utils.run_check().

>>> import paddle
>>> paddle.utils.run_check()
Running verify PaddlePaddle program ... 
.
.
.
PaddlePaddle is installed successfully! Let's start deep learning with PaddlePaddle now.

Download Demo Code

git clone --recurse-submodules https://github.com/thinkall/paddle2-demo

Install requirements

pip install -r requirements.txt

PaddleHub

Mask Detection

python hub_mask.py
  • Mask Detection with PaddleHub

Line Draft

python hub_line.py
  • Line Draft Extraction with PaddleHub

PaddleOCR Pretrained Model

python ocr-visual.py
python gradio-demo.py  # for online service

bg fit bg fit

PaddleOCR Model Training

Prepare dataset

ln -sf $PWD/data/ocr ./PaddleOCR/train_data

download pretrained model

cd PaddleOCR/

if [ ! -d "./pretrain_models/rec_mv3_none_bilstm_ctc_v2.0_train" ];then
  # Download MobileNetV3 pretrained model
  wget -P ./pretrain_models/ https://paddleocr.bj.bcebos.com/dygraph_v2.0/ch/ch_ppocr_mobile_v2.0_rec_pre.tar
  # unzip model parameters files
  cd pretrain_models
  tar -xf ch_ppocr_mobile_v2.0_rec_pre.tar && rm -rf ch_ppocr_mobile_v2.0_rec_pre.tar
fi

Train

cd PaddleOCR/

# GPU training support single GPU and multi-GPUs, choose card with --gpus
# Train our data, save logs to train.log in "{save_model_dir}"
python3 -m paddle.distributed.launch --gpus '0,1,2,3'  tools/train.py -c ../configs/rec_street_ch_train.yml

# no GPU, set use_gpu to false in the config file
python3 tools/train.py -c ../configs/rec_street_ch_train.yml

Evaluation

cd PaddleOCR/

# GPU
python3 -m paddle.distributed.launch --gpus '0' tools/eval.py -c ../configs/rec_street_ch_train.yml \
-o Global.checkpoints=./output/rec_chinese_lite_v2.0/latest

# no GPU
python3 tools/eval.py -c ../configs/rec_street_ch_train.yml -o Global.checkpoints=./output/rec_chinese_lite_v2.0/latest

Predict

python3 tools/infer_rec.py -c ../configs/rec_street_ch_train.yml \
-o Global.pretrained_model=./output/rec_chinese_lite_v2.0/latest \
Global.load_static_weights=false Global.infer_img=python3 tools/infer_rec.py \
-c ../configs/rec_street_ch_train.yml \
-o Global.pretrained_model=./output/rec_chinese_lite_v2.0/latest \
Global.load_static_weights=false Global.infer_img=train_data/ocr-sample-images/Train_000000.jpg