[toc]
Demo codes for AI models implemented with PaddlePaddle.
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
You can choose the following version of PaddlePaddle to start installation:
python -m pip install paddlepaddle -i https://mirror.baidu.com/pypi/simple
- 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
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.
git clone --recurse-submodules https://github.com/thinkall/paddle2-demo
pip install -r requirements.txt
python hub_mask.py
- Mask Detection with PaddleHub
python hub_line.py
- Line Draft Extraction with PaddleHub
python ocr-visual.py
python gradio-demo.py # for online service
- PaddleHub OCR VS i2OCR Free French OCR
- PaddleHub OCR VS i2OCR Free French OCR
ln -sf $PWD/data/ocr ./PaddleOCR/train_data
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
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
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
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