GitXplorerGitXplorer
t

paddle2-demo

public
0 stars
0 forks
0 issues

Commits

List of commits on branch master.
Unverified
a7d91e34d84a192eccac807f7c169690a90e0486

feat: add mask detection

tthinkall committed 4 years ago
Unverified
aa545c254ed371e14c7460c46390b0c7808c14ea

feat: done with ocr part

tthinkall committed 4 years ago
Unverified
8d8baeb75a5ab0d4ab243b45c6e12a8b2ad6fa6e

Merge branch 'master' of github.com:thinkall/paddle2-demo

tthinkall committed 4 years ago
Unverified
73423bfe015d671a6bc916ce164679fa7fe34e82

feat: add ocr training demo

tthinkall committed 4 years ago
Unverified
9ec90f0261d534a7d8c6928ec65220d36733b5db

feat: add PaddleOCR as submodule

tthinkall committed 4 years ago
Unverified
d60178a629bb91f0ac2494fe9ea792ddb0aff3ca

chore: remove PaddleOCR files

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