From b35c9845950c768fce5faf05840e740953abc251 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=96=87=E9=A3=8E?= Date: Tue, 8 Nov 2022 14:41:28 +0800 Subject: [PATCH 1/2] Add the models based on PaddlePaddle MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit link #I5Z34W Add the models based on PaddlePaddle Signed-off-by: 张文风 --- .../mobilenetv3/paddlepaddle/README.md | 36 +++++++++++ cv/classification/vgg/paddlepaddle/README.md | 44 +++++++++++++ cv/detection/pp-yoloe/paddlepaddle/README.md | 39 ++++++++++++ cv/detection/ssd/paddlepaddle/README.md | 39 ++++++++++++ cv/ocr/crnn/paddlepaddle/README.md | 40 ++++++++++++ .../dnlnet/paddlepaddle/README.md | 57 +++++++++++++++++ .../unet/paddlepaddle/README.md | 62 +++++++++++++++++++ .../ernie/paddlepaddle/README.md | 29 +++++++++ .../transformer/paddlepaddle/README.md | 26 ++++++++ .../wide_deep/paddlepaddle/README.md | 35 +++++++++++ 10 files changed, 407 insertions(+) create mode 100644 cv/classification/mobilenetv3/paddlepaddle/README.md create mode 100644 cv/classification/vgg/paddlepaddle/README.md create mode 100644 cv/detection/pp-yoloe/paddlepaddle/README.md create mode 100644 cv/detection/ssd/paddlepaddle/README.md create mode 100644 cv/ocr/crnn/paddlepaddle/README.md create mode 100644 cv/semantic_segmentation/dnlnet/paddlepaddle/README.md create mode 100644 cv/semantic_segmentation/unet/paddlepaddle/README.md create mode 100644 nlp/text_correction/ernie/paddlepaddle/README.md create mode 100644 nlp/translation/transformer/paddlepaddle/README.md create mode 100644 recommendation/wide_deep/paddlepaddle/README.md diff --git a/cv/classification/mobilenetv3/paddlepaddle/README.md b/cv/classification/mobilenetv3/paddlepaddle/README.md new file mode 100644 index 000000000..edcc5578f --- /dev/null +++ b/cv/classification/mobilenetv3/paddlepaddle/README.md @@ -0,0 +1,36 @@ +# MobileNetV3 +## Model description +MobileNetV3 is a convolutional neural network that is tuned to mobile phone CPUs through a combination of hardware-aware network architecture search (NAS) complemented by the NetAdapt algorithm, and then subsequently improved through novel architecture advances. Advances include (1) complementary search techniques, (2) new efficient versions of nonlinearities practical for the mobile setting, (3) new efficient network design. + +## Step 1: Installing +``` +git clone https://github.com/PaddlePaddle/PaddleClas.git +``` + +```bash +cd paddleclas +pip3 install -r requirements.txt +``` + +## Step 2: Prepare Datasets +Download [ImageNet](https://www.image-net.org/), the path as /home/datasets/imagenet/, then the imagenet path as follows: +``` +# IMAGENET PATH as follow: +# drwxr-xr-x 1002 root root 24576 Mar 1 15:33 train +# -rw-r--r-- 1 root root 43829433 May 16 07:55 train_list.txt +# drwxr-xr-x 1002 root root 24576 Mar 1 15:41 val +# -rw-r--r-- 1 root root 2144499 May 16 07:56 val_list.txt +``` + +## Step 3: Training +Notice: modify PaddleClas/ppcls/configs/ImageNet/MobileNetV3/MobileNetV3_small_x1_25.yaml file, modify the datasets path as yours. +``` +cd PaddleClas +export FLAGS_cudnn_exhaustive_search=True +export FLAGS_cudnn_batchnorm_spatial_persistent=True +export CUDA_VISIBLE_DEVICES=0,1,2,3 +python3 -u -m paddle.distributed.launch --gpus=0,1,2,3 tools/train.py -c ppcls/configs/ImageNet/MobileNetV3/MobileNetV3_small_x1_25.yaml -o Arch.pretrained=False -o Global.device=gpu +``` + +## Reference +- [PaddleClas](https://github.com/PaddlePaddle/PaddleClas) \ No newline at end of file diff --git a/cv/classification/vgg/paddlepaddle/README.md b/cv/classification/vgg/paddlepaddle/README.md new file mode 100644 index 000000000..1351bd71f --- /dev/null +++ b/cv/classification/vgg/paddlepaddle/README.md @@ -0,0 +1,44 @@ +# VGG16 +## Model description +VGG is a classical convolutional neural network architecture. It was based on an analysis of how to increase the depth of such networks. The network utilises small 3 x 3 filters. Otherwise the network is characterized by its simplicity: the only other components being pooling layers and a fully connected layer. + +## Step 1: Installing +``` +git clone https://github.com/PaddlePaddle/PaddleClas.git +``` + +```bash +cd PaddleClas +pip3 install -r requirements.txt +``` + +## Step 2: Prepare Datasets +Download [ImageNet](https://www.image-net.org/), the path as /home/datasets/imagenet/, then the imagenet path as follows: +``` +# IMAGENET PATH as follow: +# drwxr-xr-x 1002 root root 24576 Mar 1 15:33 train +# -rw-r--r-- 1 root root 43829433 May 16 07:55 train_list.txt +# drwxr-xr-x 1002 root root 24576 Mar 1 15:41 val +# -rw-r--r-- 1 root root 2144499 May 16 07:56 val_list.txt +``` + +## Step 3: Training +Notice:if use AMP, modify PaddleClas/ppcls/configs/ImageNet/VGG/VGG16.yaml, +``` +AMP: + scale_loss: 128.0 + use_dynamic_loss_scaling: True + # O1: mixed fp16 + level: O1 +``` +Notice: modify PaddleClas/ppcls/configs/ImageNet/VGG/VGG16.yaml file, modify the datasets path as yours. +``` +cd PaddleClas +export FLAGS_cudnn_exhaustive_search=True +export FLAGS_cudnn_batchnorm_spatial_persistent=True +export CUDA_VISIBLE_DEVICES=0,1,2,3 +python3 -u -m paddle.distributed.launch --gpus=0,1,2,3 tools/train.py -c ppcls/configs/ImageNet/VGG/VGG16.yaml -o Arch.pretrained=False -o Global.device=gpu +``` + +## Reference +- [PaddleClas](https://github.com/PaddlePaddle/PaddleClas) \ No newline at end of file diff --git a/cv/detection/pp-yoloe/paddlepaddle/README.md b/cv/detection/pp-yoloe/paddlepaddle/README.md new file mode 100644 index 000000000..b64c70729 --- /dev/null +++ b/cv/detection/pp-yoloe/paddlepaddle/README.md @@ -0,0 +1,39 @@ +# PP-YOLOE +## Model description +PP-YOLOE is an excellent single-stage anchor-free model based on PP-YOLOv2, surpassing a variety of popular YOLO models. PP-YOLOE has a series of models, named s/m/l/x, which are configured through width multiplier and depth multiplier. PP-YOLOE avoids using special operators, such as Deformable Convolution or Matrix NMS, to be deployed friendly on various hardware. + +## Step 1: Installing +``` +git clone https://github.com/PaddlePaddle/PaddleDetection.git +``` + +``` +cd PaddleDetection +pip3 install -r requirements.txt +``` + +## Step 2: Prepare Datasets +Download [COCO2017](https://cocodataset.org/), the path as /home/datasets/coco/, then the COCO2017 path as follows: +``` +root@5574247e63f8:/home# ls -al /home/datasets/coco +total 5208 +drwxrwxr-x 6 1003 1003 93 Dec 29 2021 . +drwxr-xr-x 6 root root 179 Jul 18 06:48 .. +drwxrwxr-x 2 1003 1003 322 Sep 24 2021 annotations +drwxrwxr-x 2 1003 1003 54 Dec 29 2021 pkl_coco +drwxrwxr-x 2 1003 1003 3846144 Sep 24 2021 train2017 +drwxrwxr-x 2 1003 1003 163840 Sep 24 2021 val2017 +``` + +## Step 3: Training +Notice: modify configs/ppyoloe/ppyoloe_crn_s_300e_coco.yml file, modify the datasets path as yours. +``` +cd PaddleDetection +export FLAGS_cudnn_exhaustive_search=True +export FLAGS_cudnn_batchnorm_spatial_persistent=True +export CUDA_VISIBLE_DEVICES=0,1,2,3,4,5,6,7 +python3 -u -m paddle.distributed.launch --gpus 0,1,2,3,4,5,6,7 tools/train.py -c configs/ppyoloe/ppyoloe_crn_s_300e_coco.yml --use_vdl=true --eval -o log_iter=5 +``` + +## Reference +- [PaddleDetection](https://github.com/PaddlePaddle/PaddleDetection) \ No newline at end of file diff --git a/cv/detection/ssd/paddlepaddle/README.md b/cv/detection/ssd/paddlepaddle/README.md new file mode 100644 index 000000000..5ed24ff0f --- /dev/null +++ b/cv/detection/ssd/paddlepaddle/README.md @@ -0,0 +1,39 @@ +# SSD +## Model description +We present a method for detecting objects in images using a single deep neural network. Our approach, named SSD, discretizes the output space of bounding boxes into a set of default boxes over different aspect ratios and scales per feature map location. At prediction time, the network generates scores for the presence of each object category in each default box and produces adjustments to the box to better match the object shape. Additionally, the network combines predictions from multiple feature maps with different resolutions to naturally handle objects of various sizes. Our SSD model is simple relative to methods that require object proposals because it completely eliminates proposal generation and subsequent pixel or feature resampling stage and encapsulates all computation in a single network. This makes SSD easy to train and straightforward to integrate into systems that require a detection component. Experimental results on the PASCAL VOC, MS COCO, and ILSVRC datasets confirm that SSD has comparable accuracy to methods that utilize an additional object proposal step and is much faster, while providing a unified framework for both training and inference. Compared to other single stage methods, SSD has much better accuracy, even with a smaller input image size. For 300x300 input, SSD achieves 72.1% mAP on VOC2007 test at 58 FPS on a Nvidia Titan X and for 500x500 input, SSD achieves 75.1% mAP, outperforming a comparable state of the art Faster R-CNN model. Code is available at https://github.com/weiliu89/caffe/tree/ssd . + +## Step 1: Installing +``` +git clone https://github.com/PaddlePaddle/PaddleDetection.git +``` + +``` +cd PaddleDetection +pip3 install -r requirements.txt +``` + +## Step 2: Prepare Datasets +Download [COCO2017](https://cocodataset.org/), the path as /home/datasets/coco/, then the COCO2017 path as follows: +``` +root@5574247e63f8:/home# ls -al /home/datasets/coco +total 5208 +drwxrwxr-x 6 1003 1003 93 Dec 29 2021 . +drwxr-xr-x 6 root root 179 Jul 18 06:48 .. +drwxrwxr-x 2 1003 1003 322 Sep 24 2021 annotations +drwxrwxr-x 2 1003 1003 54 Dec 29 2021 pkl_coco +drwxrwxr-x 2 1003 1003 3846144 Sep 24 2021 train2017 +drwxrwxr-x 2 1003 1003 163840 Sep 24 2021 val2017 +``` + +## Step 3: Training +Notice: modify configs/ssd/ssd_mobilenet_v1_300_120e_voc.yml file, modify the datasets path as yours. +``` +cd PaddleDetection +export FLAGS_cudnn_exhaustive_search=True +export FLAGS_cudnn_batchnorm_spatial_persistent=True +export CUDA_VISIBLE_DEVICES=0,1 +python3 -u -m paddle.distributed.launch --gpus 0,1 tools/train.py -c configs/ssd/ssd_mobilenet_v1_300_120e_voc.yml --eval +``` + +## Reference +- [PaddleDetection](https://github.com/PaddlePaddle/PaddleDetection) \ No newline at end of file diff --git a/cv/ocr/crnn/paddlepaddle/README.md b/cv/ocr/crnn/paddlepaddle/README.md new file mode 100644 index 000000000..223218bb9 --- /dev/null +++ b/cv/ocr/crnn/paddlepaddle/README.md @@ -0,0 +1,40 @@ +# CRNN + + +## Step 1: Installing +``` +git clone https://github.com/PaddlePaddle/PaddleOCR.git +``` + +``` +cd PaddleOCR +pip3 install -r requirements.txt +``` + +## Step 2: Prepare Datasets +Download [ICDAR2015](https://paperswithcode.com/dataset/icdar-2015), then the icdar-2015 path as follows: +``` +root@AE-ubuntu:/home/datasets/ICDAR2015/text_localization# ls -al /home/datasets/ICDAR2015/text_localization +total 133420 +drwxr-xr-x 4 root root 179 Jul 21 15:54 . +drwxr-xr-x 3 root root 39 Jul 21 15:50 .. +drwxr-xr-x 2 root root 12288 Jul 21 15:53 ch4_test_images +-rw-r--r-- 1 root root 44359601 Jul 21 15:51 ch4_test_images.zip +-rw-r--r-- 1 root root 90667586 Jul 21 15:51 ch4_training_images.zip +drwxr-xr-x 2 root root 24576 Jul 21 15:53 icdar_c4_train_imgs +-rw-r--r-- 1 root root 468453 Jul 21 15:54 test_icdar2015_label.txt +-rw-r--r-- 1 root root 1063118 Jul 21 15:54 train_icdar2015_label.txt +``` + +## Step 3: Training +Notice: modify configs/ppyoloe/ppyoloe_crn_s_300e_coco.yml file, modify the datasets path as yours. +``` +cd PaddleOCR +export FLAGS_cudnn_exhaustive_search=True +export FLAGS_cudnn_batchnorm_spatial_persistent=True +export CUDA_VISIBLE_DEVICES=0,1,2,3,4,5,6,7 +python3 -u -m paddle.distributed.launch --gpus 0,1,2,3,4,5,6,7 tools/train.py -c configs/rec/rec_mv3_none_bilstm_ctc.yml Global.use_visualdl=True +``` + +## Reference +- [PaddleOCR](https://github.com/PaddlePaddle/PaddleOCR) \ No newline at end of file diff --git a/cv/semantic_segmentation/dnlnet/paddlepaddle/README.md b/cv/semantic_segmentation/dnlnet/paddlepaddle/README.md new file mode 100644 index 000000000..4e65cf67f --- /dev/null +++ b/cv/semantic_segmentation/dnlnet/paddlepaddle/README.md @@ -0,0 +1,57 @@ +# dnlnet + + +## Step 1: Installing +``` +git clone https://github.com/PaddlePaddle/PaddleSeg.git +``` + +``` +cd PaddleSeg +pip3 install -r requirements.txt +``` + +## Step 2: Prepare Datasets +Download [CityScapes](https://www.cityscapes-dataset.com/), the path as /home/datasets/cityscapes/. +Datasets preprocessing: +``` +pip3 install cityscapesscripts + +python3 tools/convert_cityscapes.py --cityscapes_path /home/datasets/cityscapes/ --num_workers 8 + +python3 tools/create_dataset_list.py /home/datasets/cityscapes --type cityscapes --separator "," +``` + +then the cityscapes path as follows: +``` +root@5574247e63f8:~# ls -al /home/datasets/cityscapes/ +total 11567948 +drwxr-xr-x 4 root root 227 Jul 18 03:32 . +drwxr-xr-x 6 root root 179 Jul 18 06:48 .. +-rw-r--r-- 1 root root 298 Feb 20 2016 README +drwxr-xr-x 5 root root 58 Jul 18 03:30 gtFine +-rw-r--r-- 1 root root 252567705 Jul 18 03:22 gtFine_trainvaltest.zip +drwxr-xr-x 5 root root 58 Jul 18 03:30 leftImg8bit +-rw-r--r-- 1 root root 11592327197 Jul 18 03:27 leftImg8bit_trainvaltest.zip +-rw-r--r-- 1 root root 1646 Feb 17 2016 license.txt +-rw-r--r-- 1 root root 193690 Jul 18 03:32 test.txt +-rw-r--r-- 1 root root 398780 Jul 18 03:32 train.txt +-rw-r--r-- 1 root root 65900 Jul 18 03:32 val.txt +``` + +## Step 3: Training +Notice: modify configs/dnlnet/dnlnet_resnet50_os8_cityscapes_1024x512_80k.yml file, modify the datasets path as yours. +``` +cd PaddleSeg +export FLAGS_cudnn_exhaustive_search=True +export FLAGS_cudnn_batchnorm_spatial_persistent=True +export CUDA_VISIBLE_DEVICES=4,5,6,7 # 设置4张可用的卡 +python3 -u -m paddle.distributed.launch train.py \ + --config configs/dnlnet/dnlnet_resnet50_os8_cityscapes_1024x512_80k.yml \ + --do_eval \ + --precision fp16 \ + --amp_level O1 +``` + +## Reference +- [PaddleSeg](https://github.com/PaddlePaddle/PaddleSeg) \ No newline at end of file diff --git a/cv/semantic_segmentation/unet/paddlepaddle/README.md b/cv/semantic_segmentation/unet/paddlepaddle/README.md new file mode 100644 index 000000000..cbfe7bce7 --- /dev/null +++ b/cv/semantic_segmentation/unet/paddlepaddle/README.md @@ -0,0 +1,62 @@ +# UNet +## Model description +A network and training strategy that relies on the strong use of data augmentation to use the available annotated samples more efficiently. +The architecture consists of a contracting path to capture context and a symmetric expanding path that enables precise localization. + +## Step 1: Installing +``` +git clone https://github.com/PaddlePaddle/PaddleSeg.git +``` + +``` +cd PaddleSeg +pip3 install -r requirements.txt +``` + +## Step 2: Prepare Datasets +Download [CityScapes](https://www.cityscapes-dataset.com/), the path as /home/datasets/cityscapes/. +Datasets preprocessing: +``` +pip3 install cityscapesscripts + +python3 tools/convert_cityscapes.py --cityscapes_path /home/datasets/cityscapes/ --num_workers 8 + +python3 tools/create_dataset_list.py /home/datasets/cityscapes --type cityscapes --separator "," +``` + +then the cityscapes path as follows: +``` +root@5574247e63f8:~# ls -al /home/datasets/cityscapes/ +total 11567948 +drwxr-xr-x 4 root root 227 Jul 18 03:32 . +drwxr-xr-x 6 root root 179 Jul 18 06:48 .. +-rw-r--r-- 1 root root 298 Feb 20 2016 README +drwxr-xr-x 5 root root 58 Jul 18 03:30 gtFine +-rw-r--r-- 1 root root 252567705 Jul 18 03:22 gtFine_trainvaltest.zip +drwxr-xr-x 5 root root 58 Jul 18 03:30 leftImg8bit +-rw-r--r-- 1 root root 11592327197 Jul 18 03:27 leftImg8bit_trainvaltest.zip +-rw-r--r-- 1 root root 1646 Feb 17 2016 license.txt +-rw-r--r-- 1 root root 193690 Jul 18 03:32 test.txt +-rw-r--r-- 1 root root 398780 Jul 18 03:32 train.txt +-rw-r--r-- 1 root root 65900 Jul 18 03:32 val.txt +``` + +## Step 3: Training +Notice: modify configs/ssd/ssd_mobilenet_v1_300_120e_voc.yml file, modify the datasets path as yours. +The training is use AMP model. +``` +cd PaddleSeg +export FLAGS_cudnn_exhaustive_search=True +export FLAGS_cudnn_batchnorm_spatial_persistent=True +export CUDA_VISIBLE_DEVICES=0,1,2,3 +python3 -u -m paddle.distributed.launch --gpus 0,1,2,3 train.py \ + --config configs/unet/unet_cityscapes_1024x512_160k.yml \ + --do_eval \ + --use_vdl \ + --save_dir output_unet_amp \ + --precision fp16 \ + --amp_level O1 +``` + +## Reference +- [PaddleSeg](https://github.com/PaddlePaddle/PaddleSeg) \ No newline at end of file diff --git a/nlp/text_correction/ernie/paddlepaddle/README.md b/nlp/text_correction/ernie/paddlepaddle/README.md new file mode 100644 index 000000000..1cb6afd65 --- /dev/null +++ b/nlp/text_correction/ernie/paddlepaddle/README.md @@ -0,0 +1,29 @@ +# Ernie + + +## Step 1: Installing +``` +git clone https://github.com/PaddlePaddle/PaddleNLP.git +``` +``` +cd PaddleNLP +pip3 install -r requirements.txt +``` + +## Step 2: Training +``` +cd examples/text_correction/ernie-csc +pip3 install -r requirements.txt + + +python3 download.py --data_dir ./extra_train_ds/ --url https://github.com/wdimmy/Automatic-Corpus-Generation/raw/master/corpus/train.sgml +python3 change_sgml_to_txt.py -i extra_train_ds/train.sgml -o extra_train_ds/train.txt + +export CUDA_VISIBLE_DEVICES=0 +export FLAGS_cudnn_exhaustive_search=True +export FLAGS_cudnn_batchnorm_spatial_persistent=True +python3 -u train.py --batch_size 32 --logging_steps 100 --epochs 10 --learning_rate 5e-5 --model_name_or_path ernie-1.0 --output_dir ./checkpoints/ --extra_train_ds_dir ./extra_train_ds/ --max_seq_length 192 +``` + +## Reference +- [PaddleNLP](https://github.com/PaddlePaddle/PaddleNLP) \ No newline at end of file diff --git a/nlp/translation/transformer/paddlepaddle/README.md b/nlp/translation/transformer/paddlepaddle/README.md new file mode 100644 index 000000000..f8f0898f1 --- /dev/null +++ b/nlp/translation/transformer/paddlepaddle/README.md @@ -0,0 +1,26 @@ +# Transformer + + +## Step 1: Installing +``` +git clone https://github.com/PaddlePaddle/PaddleNLP.git +``` + +``` +cd PaddleNLP +pip3 install -r requirements.txt +``` + +## Step 2: Training +The training is use AMP model. +``` +cd PaddleNLP/examples/machine_translation/transformer +export FLAGS_cudnn_exhaustive_search=True +export FLAGS_cudnn_batchnorm_spatial_persistent=True +export CUDA_VISIBLE_DEVICES=0,1,2,3,4,5,6,7 +python3 -u -m paddle.distributed.launch --gpus=0,1,2,3,4,5,6,7 train.py --config ./configs/transformer.big.yaml \ +--use_amp True --amp_level O1 +``` + +## Reference +- [PaddleNLP](https://github.com/PaddlePaddle/PaddleNLP) \ No newline at end of file diff --git a/recommendation/wide_deep/paddlepaddle/README.md b/recommendation/wide_deep/paddlepaddle/README.md new file mode 100644 index 000000000..4c438f435 --- /dev/null +++ b/recommendation/wide_deep/paddlepaddle/README.md @@ -0,0 +1,35 @@ +# Wide&Deep + + +## Step 1: Installing +``` +git clone https://github.com/PaddlePaddle/PaddleRec.git +``` + +``` +cd PaddleRec +pip3 install -r requirements.txt +``` + +## Step 2: Training +``` +cd PaddleRec + +# 下载数据集 +pushd datasets/criteo/ +sh run.sh +popd + +pushd models/rank/wide_deep +export FLAGS_cudnn_exhaustive_search=True +export FLAGS_cudnn_batchnorm_spatial_persistent=True +export CUDA_VISIBLE_DEVICES=3 +# train +python3 -u ../../../tools/trainer.py -m config_bigdata.yaml +# Eval +python3 -u ../../../tools/infer.py -m config_bigdata.yaml +popd +``` + +## Reference +- [PaddleRec](https://github.com/PaddlePaddle/PaddleRec) \ No newline at end of file -- Gitee From 5dad403fc073f2ce9b28487bd530e0660cbc030d Mon Sep 17 00:00:00 2001 From: majorli6 Date: Mon, 14 Nov 2022 15:13:38 +0800 Subject: [PATCH 2/2] Add the models based on PaddlePaddle link #I5Z34W Add the models based on PaddlePaddle - googlenet - resnet50 - maskrcnn - yolov3 - pp-ocr db - pse - deeplabv3 - bert - deepfm authored by may: xiaomei.wang@iluvatar.ai Signed-off-by: majorli6 --- .../googlenet/paddlepaddle/README.md | 55 ++++++++++++++++++ .../resnet50/paddlepaddle/README.md | 44 +++++++++++++++ cv/detection/maskrcnn/paddlepaddle/README.md | 44 +++++++++++++++ cv/detection/yolov3/paddlepaddle/README.md | 42 ++++++++++++++ cv/ocr/pp-ocr db/paddlepaddle/README.md | 40 +++++++++++++ cv/ocr/pse/paddlepaddle/README.md | 39 +++++++++++++ .../deeplabv3/paddlepaddle/README.md | 56 +++++++++++++++++++ .../bert/paddlepaddle/README.md | 25 +++++++++ .../bert/paddlepaddle/train_bert.py | 41 ++++++++++++++ .../bert/paddlepaddle/train_bert.sh | 52 +++++++++++++++++ recommendation/deepfm/paddlepaddle/README.md | 31 ++++++++++ 11 files changed, 469 insertions(+) create mode 100644 cv/classification/googlenet/paddlepaddle/README.md create mode 100644 cv/classification/resnet50/paddlepaddle/README.md create mode 100644 cv/detection/maskrcnn/paddlepaddle/README.md create mode 100644 cv/detection/yolov3/paddlepaddle/README.md create mode 100644 cv/ocr/pp-ocr db/paddlepaddle/README.md create mode 100644 cv/ocr/pse/paddlepaddle/README.md create mode 100644 cv/semantic_segmentation/deeplabv3/paddlepaddle/README.md create mode 100644 nlp/language_model/bert/paddlepaddle/README.md create mode 100644 nlp/language_model/bert/paddlepaddle/train_bert.py create mode 100644 nlp/language_model/bert/paddlepaddle/train_bert.sh create mode 100644 recommendation/deepfm/paddlepaddle/README.md diff --git a/cv/classification/googlenet/paddlepaddle/README.md b/cv/classification/googlenet/paddlepaddle/README.md new file mode 100644 index 000000000..48e3256be --- /dev/null +++ b/cv/classification/googlenet/paddlepaddle/README.md @@ -0,0 +1,55 @@ +# GoogLeNet + +## Model description +GoogLeNet is a type of convolutional neural network based on the Inception architecture. It utilises Inception modules, which allow the network to choose between multiple convolutional filter sizes in each block. An Inception network stacks these modules on top of each other, with occasional max-pooling layers with stride 2 to halve the resolution of the grid. + +## Step 1: Installing + +```bash +git clone --recursive https://github.com/PaddlePaddle/PaddleClas.git +cd PaddleClas +pip3 install -r requirements.txt +``` + +## Step 2: Download data + +Download the [ImageNet Dataset](https://www.image-net.org/download.php) + +```bash +# IMAGENET PATH as follow: +#ls -al /home/datasets/imagenet_jpeg/ +#total 52688 +# drwxr-xr-x 1002 root root 24576 Mar 1 15:33 train +# -rw-r--r-- 1 root root 43829433 May 16 07:55 train_list.txt +# drwxr-xr-x 1002 root root 24576 Mar 1 15:41 val +# -rw-r--r-- 1 root root 2144499 May 16 07:56 val_list.txt +# ----------------------- +# train_list.txt has the following format +# n01440764/n01440764_10026.JPEG 0 +# ... + +# val_list.txt has the following format +# ILSVRC2012_val_00000001.JPEG 65 +# ----------------------- +``` + +## Step 3: Run GoogLeNet AMP + +```bash +# Modify the file:/paddleclas/ppcls/configs/ImageNet/Inception/GoogLeNet.yaml to add the option of AMP + +AMP: + scale_loss: 128.0 + use_dynamic_loss_scaling: True + # O1: mixed fp16 + level: O1 +``` + +```bash +# Make sure your dataset path is the same as above +cd PaddleClas +export FLAGS_cudnn_exhaustive_search=True +export FLAGS_cudnn_batchnorm_spatial_persistent=True +export CUDA_VISIBLE_DEVICES=0,1,2,3 +python3 -u -m paddle.distributed.launch --gpus=0,1,2,3 tools/train.py -c ppcls/configs/ImageNet/Inception/GoogLeNet.yaml +``` \ No newline at end of file diff --git a/cv/classification/resnet50/paddlepaddle/README.md b/cv/classification/resnet50/paddlepaddle/README.md new file mode 100644 index 000000000..03ad5010f --- /dev/null +++ b/cv/classification/resnet50/paddlepaddle/README.md @@ -0,0 +1,44 @@ +# ResNet50 +## Model description +Residual Networks, or ResNets, learn residual functions with reference to the layer inputs, instead of learning unreferenced functions. Instead of hoping each few stacked layers directly fit a desired underlying mapping, residual nets let these layers fit a residual mapping. + +## Step 1: Installing + +```bash +git clone --recursive https://github.com/PaddlePaddle/PaddleClas.git +cd PaddleClas +pip3 install -r requirements.txt +``` + +## Step 2: Download data + +Download the [ImageNet Dataset](https://www.image-net.org/download.php) + +```bash +# IMAGENET PATH as follow: +#ls -al /home/datasets/imagenet_jpeg/ +#total 52688 +# drwxr-xr-x 1002 root root 24576 Mar 1 15:33 train +# -rw-r--r-- 1 root root 43829433 May 16 07:55 train_list.txt +# drwxr-xr-x 1002 root root 24576 Mar 1 15:41 val +# -rw-r--r-- 1 root root 2144499 May 16 07:56 val_list.txt +# ----------------------- +# train_list.txt has the following format +# n01440764/n01440764_10026.JPEG 0 +# ... + +# val_list.txt has the following format +# ILSVRC2012_val_00000001.JPEG 65 +# ----------------------- +``` + +## Step 3: Run ResNet50 + +```bash +# Make sure your dataset path is the same as above +cd PaddleClas +export FLAGS_cudnn_exhaustive_search=True +export FLAGS_cudnn_batchnorm_spatial_persistent=True +export CUDA_VISIBLE_DEVICES=0,1,2,3 +python3 -u -m paddle.distributed.launch --gpus=0,1,2,3 tools/train.py -c ppcls/configs/ImageNet/ResNet/ResNet50.yaml -o Arch.pretrained=False -o Global.device=gpu +``` \ No newline at end of file diff --git a/cv/detection/maskrcnn/paddlepaddle/README.md b/cv/detection/maskrcnn/paddlepaddle/README.md new file mode 100644 index 000000000..cbf05e28e --- /dev/null +++ b/cv/detection/maskrcnn/paddlepaddle/README.md @@ -0,0 +1,44 @@ +# Mask R-CNN + +## Model description + +Nuclei segmentation is both an important and in some ways ideal task for modern computer vision methods, e.g. convolutional neural networks. While recent developments in theory and open-source software have made these tools easier to implement, expert knowledge is still required to choose the right model architecture and training setup. We compare two popular segmentation frameworks, U-Net and Mask-RCNN in the nuclei segmentation task and find that they have different strengths and failures. To get the best of both worlds, we develop an ensemble model to combine their predictions that can outperform both models by a significant margin and should be considered when aiming for best nuclei segmentation performance. + +## Step 1: Installing + +```bash +git clone --recursive https://github.com/PaddlePaddle/PaddleDetection.git +cd PaddleDetection +pip3 install -r requirements.txt +python3 setup.py install --user +``` + +## Step 2: Download data + +Download the [COCO Dataset](https://cocodataset.org/#home) + +```bash + +#COCO PATH as follow: +#ls -al /home/datasets/coco +#total 5208 +#drwxrwxr-x 6 1003 1003 93 Dec 29 2021 . +#drwxr-xr-x 6 root root 179 Jul 18 06:48 .. +#drwxrwxr-x 2 1003 1003 322 Sep 24 2021 annotations +#drwxrwxr-x 2 1003 1003 54 Dec 29 2021 pkl_coco +#drwxrwxr-x 2 1003 1003 3846144 Sep 24 2021 train2017 +#drwxrwxr-x 2 1003 1003 163840 Sep 24 2021 val2017 + +``` + +## Step 3: Run Mask R-CNN + +```bash +# Make sure your dataset path is the same as above +#coco_dir=${coco_dir:-/home/datasets/coco/} +sed -i "s#dataset/coco#${coco_dir}#g" configs/datasets/coco_instance.yml +export FLAGS_cudnn_exhaustive_search=True +export FLAGS_cudnn_batchnorm_spatial_persistent=True +export CUDA_VISIBLE_DEVICES=0,1,2,3,4,5,6,7 +python3 -u -m paddle.distributed.launch --gpus 0,1,2,3,4,5,6,7 tools/train.py -c configs/mask_rcnn/mask_rcnn_r50_fpn_1x_coco.yml --use_vdl=true --eval --amp +``` \ No newline at end of file diff --git a/cv/detection/yolov3/paddlepaddle/README.md b/cv/detection/yolov3/paddlepaddle/README.md new file mode 100644 index 000000000..d8b9f34fe --- /dev/null +++ b/cv/detection/yolov3/paddlepaddle/README.md @@ -0,0 +1,42 @@ +# YOLOv3 + +## Model description + +We present some updates to YOLO! We made a bunch of little design changes to make it better. We also trained this new network that’s pretty swell. It’s a little bigger than last time but more accurate. It’s still fast though, don’t worry. At 320 × 320 YOLOv3 runs in 22 ms at 28.2 mAP, as accurate as SSD but three times faster. When we look at the old .5 IOU mAP detection metric YOLOv3 is quite good. It achieves 57.9 AP50 in 51 ms on a Titan X, compared to 57.5 AP50 in 198 ms by RetinaNet, similar performance but 3.8× faster. As always, all the code is online at https://pjreddie.com/yolo/. + +## Step 1: Installing + +```bash +git clone --recursive https://github.com/PaddlePaddle/PaddleDetection.git +cd PaddleDetection +pip3 install -r requirements.txt +``` + +## Step 2: Download data + +Download the [COCO Dataset](https://cocodataset.org/#home) + +```bash + +#COCO PATH as follow: +#ls -al /home/datasets/coco +#total 5208 +#drwxrwxr-x 6 1003 1003 93 Dec 29 2021 . +#drwxr-xr-x 6 root root 179 Jul 18 06:48 .. +#drwxrwxr-x 2 1003 1003 322 Sep 24 2021 annotations +#drwxrwxr-x 2 1003 1003 54 Dec 29 2021 pkl_coco +#drwxrwxr-x 2 1003 1003 3846144 Sep 24 2021 train2017 +#drwxrwxr-x 2 1003 1003 163840 Sep 24 2021 val2017 + +``` + +## Step 3: Run YOLOv3 + +```bash +# Make sure your dataset path is the same as above +cd PaddleDetection +export FLAGS_cudnn_exhaustive_search=True +export FLAGS_cudnn_batchnorm_spatial_persistent=True +export CUDA_VISIBLE_DEVICES=0,1,2,3,4,5,6,7 +python3 -u -m paddle.distributed.launch --gpus 0,1,2,3,4,5,6,7 tools/train.py -c configs/yolov3/yolov3_darknet53_270e_coco.yml -o TrainReader.batch_size=16 LearningRate.base_lr=0.002 worker_num=4 --use_vdl=true --eval +``` \ No newline at end of file diff --git a/cv/ocr/pp-ocr db/paddlepaddle/README.md b/cv/ocr/pp-ocr db/paddlepaddle/README.md new file mode 100644 index 000000000..0e13ef5d4 --- /dev/null +++ b/cv/ocr/pp-ocr db/paddlepaddle/README.md @@ -0,0 +1,40 @@ +# PP-OCR DB + +## Step 1: Installing +```bash +git clone --recursive https://github.com/PaddlePaddle/PaddleOCR.git +cd PaddleOCR +pip3 install -r requirements.txt +``` + +## Step 2: Download data + +Download the [ICDAR2015 Dataset](https://deepai.org/dataset/icdar-2015) + +```bash + +#ICDAR2015 PATH as follow: +#ls -al /home/datasets/ICDAR2015/text_localization +#total 133420 +#drwxr-xr-x 4 root root 179 Jul 21 15:54 . +#drwxr-xr-x 3 root root 39 Jul 21 15:50 .. +#drwxr-xr-x 2 root root 12288 Jul 21 15:53 ch4_test_images +#-rw-r--r-- 1 root root 44359601 Jul 21 15:51 ch4_test_images.zip +#-rw-r--r-- 1 root root 90667586 Jul 21 15:51 ch4_training_images.zip +#drwxr-xr-x 2 root root 24576 Jul 21 15:53 icdar_c4_train_imgs +#-rw-r--r-- 1 root root 468453 Jul 21 15:54 test_icdar2015_label.txt +#-rw-r--r-- 1 root root 1063118 Jul 21 15:54 train_icdar2015_label.txt + +``` + +## Step 3: Run PP-OCR DB + +```bash +# Make sure your dataset path is the same as above +wget -P ./pretrain_models/ https://paddleocr.bj.bcebos.com/pretrained/MobileNetV3_large_x0_5_pretrained.pdparams +export FLAGS_cudnn_exhaustive_search=True +export FLAGS_cudnn_batchnorm_spatial_persistent=True +export CUDA_VISIBLE_DEVICES=0,1,2,3 +python3 -u -m paddle.distributed.launch --gpus '0,1,2,3' tools/train.py -c configs/det/det_mv3_db.yml -o Global.use_visualdl=True \ +>train.log 2>&1 & +``` diff --git a/cv/ocr/pse/paddlepaddle/README.md b/cv/ocr/pse/paddlepaddle/README.md new file mode 100644 index 000000000..7b4092dfb --- /dev/null +++ b/cv/ocr/pse/paddlepaddle/README.md @@ -0,0 +1,39 @@ +# PSE + +## Step 1: Installing +```bash +git clone --recursive https://github.com/PaddlePaddle/PaddleOCR.git +cd PaddleOCR +pip3 install -r requirements.txt +``` + +## Step 2: Download data + +Download the [ICDAR2015 Dataset](https://deepai.org/dataset/icdar-2015) + +```bash + +#ICDAR2015 PATH as follow: +#ls -al /home/datasets/ICDAR2015/text_localization +#total 133420 +#drwxr-xr-x 4 root root 179 Jul 21 15:54 . +#drwxr-xr-x 3 root root 39 Jul 21 15:50 .. +#drwxr-xr-x 2 root root 12288 Jul 21 15:53 ch4_test_images +#-rw-r--r-- 1 root root 44359601 Jul 21 15:51 ch4_test_images.zip +#-rw-r--r-- 1 root root 90667586 Jul 21 15:51 ch4_training_images.zip +#drwxr-xr-x 2 root root 24576 Jul 21 15:53 icdar_c4_train_imgs +#-rw-r--r-- 1 root root 468453 Jul 21 15:54 test_icdar2015_label.txt +#-rw-r--r-- 1 root root 1063118 Jul 21 15:54 train_icdar2015_label.txt + +``` + +## Step 3: Run PSE + +```bash +# Make sure your dataset path is the same as above +wget -P ./pretrain_models/ https://paddleocr.bj.bcebos.com/pretrained/ResNet50_vd_ssld_pretrained.pdparams +export FLAGS_cudnn_exhaustive_search=True +export FLAGS_cudnn_batchnorm_spatial_persistent=True +export CUDA_VISIBLE_DEVICES=0 +python3 -u -m paddle.distributed.launch --gpus 0,1,2,3 tools/train.py -c configs/det/det_r50_vd_pse.yml -o Global.use_amp=True Global.scale_loss=1024.0 Global.use_dynamic_loss_scaling=True +``` \ No newline at end of file diff --git a/cv/semantic_segmentation/deeplabv3/paddlepaddle/README.md b/cv/semantic_segmentation/deeplabv3/paddlepaddle/README.md new file mode 100644 index 000000000..76f4ade50 --- /dev/null +++ b/cv/semantic_segmentation/deeplabv3/paddlepaddle/README.md @@ -0,0 +1,56 @@ +# DeepLab + +## Model description + +DeepLabv3 is a semantic segmentation architecture that improves upon DeepLabv2 with several modifications. +To handle the problem of segmenting objects at multiple scales, modules are designed which employ atrous convolution in cascade or in parallel to capture multi-scale context by adopting multiple atrous rates. + +## Step 1: Installing + +```bash +git clone --recursive https://github.com/PaddlePaddle/PaddleSeg.git +cd PaddleSeg +pip3 install -r requirements.txt +``` + +## Step 2: Download data + +Download the [CityScapes Dataset](https://www.cityscapes-dataset.com/) + +```bash +# Datasets preprocessing +pip3 install cityscapesscripts + +python3 tools/convert_cityscapes.py --cityscapes_path /home/datasets/cityscapes/ --num_workers 8 + +python3 tools/create_dataset_list.py /home/datasets/cityscapes --type cityscapes --separator "," +#CityScapes PATH as follow: +# ls -al /home/datasets/cityscapes/ +#total 11567948 +#drwxr-xr-x 4 root root 227 Jul 18 03:32 . +#drwxr-xr-x 6 root root 179 Jul 18 06:48 .. +#-rw-r--r-- 1 root root 298 Feb 20 2016 README +#drwxr-xr-x 5 root root 58 Jul 18 03:30 gtFine +#-rw-r--r-- 1 root root 252567705 Jul 18 03:22 gtFine_trainvaltest.zip +#drwxr-xr-x 5 root root 58 Jul 18 03:30 leftImg8bit +#-rw-r--r-- 1 root root 11592327197 Jul 18 03:27 leftImg8bit_trainvaltest.zip +#-rw-r--r-- 1 root root 1646 Feb 17 2016 license.txt +#-rw-r--r-- 1 root root 193690 Jul 18 03:32 test.txt +#-rw-r--r-- 1 root root 398780 Jul 18 03:32 train.txt +#-rw-r--r-- 1 root root 65900 Jul 18 03:32 val.txt +``` + +## Step 3: Run DeepLab + +```bash +# Make sure your dataset path is the same as above +# data_dir=${data_dir:-/home/datasets/cityscapes/} +sed -i "s#: data/cityscapes#: ${data_dir}#g" configs/_base_/cityscapes.yml +export FLAGS_cudnn_exhaustive_search=True +export FLAGS_cudnn_batchnorm_spatial_persistent=True +export CUDA_VISIBLE_DEVICES=0,1,2,3 +python3 -u -m paddle.distributed.launch --gpus 0,1,2,3 train.py \ + --config configs/deeplabv3/deeplabv3_resnet50_os8_cityscapes_1024x512_80k.yml \ + --do_eval \ + --use_vdl +``` \ No newline at end of file diff --git a/nlp/language_model/bert/paddlepaddle/README.md b/nlp/language_model/bert/paddlepaddle/README.md new file mode 100644 index 000000000..cf6b895ab --- /dev/null +++ b/nlp/language_model/bert/paddlepaddle/README.md @@ -0,0 +1,25 @@ +# BERT Pretraining + +## Model description + +BERT, or Bidirectional Encoder Representations from Transformers, improves upon standard Transformers by removing the unidirectionality constraint by using a masked language model (MLM) pre-training objective. The masked language model randomly masks some of the tokens from the input, and the objective is to predict the original vocabulary id of the masked word based only on its context. Unlike left-to-right language model pre-training, the MLM objective enables the representation to fuse the left and the right context, which allows us to pre-train a deep bidirectional Transformer. In addition to the masked language model, BERT uses a next sentence prediction task that jointly pre-trains text-pair representations. + +## Step 1: Installing + +```bash +git clone --recursive https://github.com/PaddlePaddle/PaddleNLP.git +cd PaddleNLP +pip3 install -r requirements.txt +``` + +## Step 2: Download data + +Download the [MNLI Dataset](http://www.nyu.edu/projects/bowman/multinli/) + + +## Step 3: Run BERT + +```bash +# Make sure your dataset path is the same as above +bash train_bert.sh +``` diff --git a/nlp/language_model/bert/paddlepaddle/train_bert.py b/nlp/language_model/bert/paddlepaddle/train_bert.py new file mode 100644 index 000000000..2d8d6d00c --- /dev/null +++ b/nlp/language_model/bert/paddlepaddle/train_bert.py @@ -0,0 +1,41 @@ +# Copyright (c) 2022, Shanghai Iluvatar CoreX Semiconductor Co., Ltd. +# All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +import os +import sys +import re + + +os.chdir("./PaddleNLP") + +# check infer log + +expected = [1, 1, 1, 0, 0] +DELTA = 0.1 +with open("./infer.log", "r") as f: + log = f.read() + labels = re.findall(r"Label\: (.*) ", log) + Negative_probs = re.findall(r"Negative prob: (.*) ", log) + Positive_probs = re.findall(r"Positive prob: (.*) ", log) + print(labels) + print(Negative_probs) + print(Positive_probs) + for i, (label, pos, neg) in enumerate(zip(labels, Positive_probs, Negative_probs)): + delta = abs(float(expected[i]) - float(pos)) + print("Infer result: {}, {:.5f}, expected: {:.5f}".format(label, float(pos), float(expected[i]))) + if delta > DELTA: + print("Check failed!") + sys.exit(-1) + \ No newline at end of file diff --git a/nlp/language_model/bert/paddlepaddle/train_bert.sh b/nlp/language_model/bert/paddlepaddle/train_bert.sh new file mode 100644 index 000000000..e36875b24 --- /dev/null +++ b/nlp/language_model/bert/paddlepaddle/train_bert.sh @@ -0,0 +1,52 @@ +#!/bin/bash + +# Copyright (c) 2022, Shanghai Iluvatar CoreX Semiconductor Co., Ltd. +# All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +cd PaddleNLP + +pip3 install -r requirements.txt +python3 setup.py install --user + +export CUDA_VISIBLE_DEVICES=0 +export FLAGS_cudnn_exhaustive_search=True +export FLAGS_cudnn_batchnorm_spatial_persistent=True +python3 examples/language_model/bert/run_glue.py \ + --model_type bert \ + --model_name_or_path bert-base-uncased \ + --task_name SST2 \ + --max_seq_length 128 \ + --batch_size 32 \ + --learning_rate 2e-5 \ + --num_train_epochs 3 \ + --logging_steps 100 \ + --save_steps 500 \ + --output_dir ./tmp/ \ + --device gpu \ + --use_amp False + +python3 examples/language_model/bert/export_model.py \ + --model_type bert \ + --model_path ./tmp/sst2_ft_model_6315.pdparams \ + --output_path ./infer_model/model + +python3 examples/language_model/bert/predict.py \ + --model_path ./infer_model/model \ + --device gpu \ + --max_seq_length 128 \ + --device gpu 2>&1 | tee infer.log + +cd .. +python3 train_bert.py \ No newline at end of file diff --git a/recommendation/deepfm/paddlepaddle/README.md b/recommendation/deepfm/paddlepaddle/README.md new file mode 100644 index 000000000..faf3f733e --- /dev/null +++ b/recommendation/deepfm/paddlepaddle/README.md @@ -0,0 +1,31 @@ +# DeepFM + +## Step 1: Installing + +```bash +git clone --recursive https://github.com/PaddlePaddle/PaddleRec.git +cd PaddleRec +pip3 install -r requirements.txt +``` + +## Step 2: Download data + +```bash +cd PaddleRec +cd datasets/criteo/ +sh run.sh +``` + + +## Step 3: Run DeepFM + +```bash +cd models/rank/deepfm +export FLAGS_cudnn_exhaustive_search=True +export FLAGS_cudnn_batchnorm_spatial_persistent=True +export CUDA_VISIBLE_DEVICES=3 +# train +python3 -u ../../../tools/trainer.py -m config_bigdata.yaml +# Eval +python3 -u ../../../tools/infer.py -m config_bigdata.yaml +``` \ No newline at end of file -- Gitee