From 16b097fde0f58f87a092d0c517007d70f4466587 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A5=9D=E5=BB=BA=E4=BC=9F?= <1076413770@qq.com> Date: Mon, 4 Jul 2022 11:03:50 +0800 Subject: [PATCH 1/5] =?UTF-8?q?'[=E8=A5=BF=E5=AE=89=E4=BA=A4=E9=80=9A?= =?UTF-8?q?=E5=A4=A7=E5=AD=A6][=E9=AB=98=E6=A0=A1=E8=B4=A1=E7=8C=AE][Pytor?= =?UTF-8?q?ch][EfficientNet-B3]--=E5=88=9D=E6=AC=A1=E6=8F=90=E4=BA=A4'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../EfficientNet-B3/README -raw.md | 52 +++++++++++++++++++ .../classification/EfficientNet-B3/README.md | 36 +++++++------ .../EfficientNet-B3/requirements.txt | 29 ++++++++--- .../EfficientNet-B3/test/train_eval_8p.sh | 2 +- .../EfficientNet-B3/test/train_full_1p.sh | 2 +- .../EfficientNet-B3/test/train_full_8p.sh | 2 +- .../test/train_performance_1p.sh | 2 +- .../test/train_performance_8p.sh | 2 +- .../EfficientNet-B3/tools/train_net.py | 2 + 9 files changed, 100 insertions(+), 29 deletions(-) create mode 100644 PyTorch/contrib/cv/classification/EfficientNet-B3/README -raw.md diff --git a/PyTorch/contrib/cv/classification/EfficientNet-B3/README -raw.md b/PyTorch/contrib/cv/classification/EfficientNet-B3/README -raw.md new file mode 100644 index 0000000000..a448405d96 --- /dev/null +++ b/PyTorch/contrib/cv/classification/EfficientNet-B3/README -raw.md @@ -0,0 +1,52 @@ +# EfficientNet-B3 + +This implements training of Efficientnet-B3 on the ImageNet dataset, mainly modified from [pycls](https://github.com/facebookresearch/pycls). + +## EfficientNet-B3 Detail + +For details, see[pycls](https://github.com/facebookresearch/pycls). + + +## Requirements + +- Install PyTorch ([pytorch.org](http://pytorch.org)) +- pip install pycls +- git clone https://github.com/facebookresearch/pycls +- pip install -r requirements.txt +- modify path of dataset in pycls/datasets/loader.py, you can modify the variable _DATA_DIR to your path of imagenet dataset. + +## Training + +To train a model, run scripts with the desired model architecture and the path to the ImageNet dataset: + +```bash +# 1p train 1p +bash test/train_full_1p.sh --data_path={data/path} # train accuracy + +bash test/train_performance_1p.sh --data_path={data/path} # train performance + +# 8p train 8p +bash test/train_full_8p.sh --data_path={data/path} # train accuracy + +bash test/train_performance_8p.sh --data_path={data/path} # train performance + +# 1p eval 1p +bash test/train_eval_8p.sh --data_path={data/path} + +# online inference demo +python3.7 demo.py + +# To ONNX +python3.7.5 pthtar2onnx.py + +``` + +## EfficientNet-B3 training result + +| Acc@1 | FPS | Npu_nums | Epochs | AMP_Type | +| :----: | :--: | :------: | :----: | :------: | +| - | 267 | 1 | 100 | O2 | +| 77.3418 | 1558 | 8 | 100 | O2 | + + + diff --git a/PyTorch/contrib/cv/classification/EfficientNet-B3/README.md b/PyTorch/contrib/cv/classification/EfficientNet-B3/README.md index a448405d96..36da255163 100644 --- a/PyTorch/contrib/cv/classification/EfficientNet-B3/README.md +++ b/PyTorch/contrib/cv/classification/EfficientNet-B3/README.md @@ -4,7 +4,8 @@ This implements training of Efficientnet-B3 on the ImageNet dataset, mainly modi ## EfficientNet-B3 Detail -For details, see[pycls](https://github.com/facebookresearch/pycls). +1. Migrate to Torch1.8 +2. Note: The original readme.md is changed to README_raw.md ## Requirements @@ -14,6 +15,11 @@ For details, see[pycls](https://github.com/facebookresearch/pycls). - git clone https://github.com/facebookresearch/pycls - pip install -r requirements.txt - modify path of dataset in pycls/datasets/loader.py, you can modify the variable _DATA_DIR to your path of imagenet dataset. +- Download the ImageNet dataset +- Note: Torch and Apex are linux_AARCH64 architecture packages + - apex: 0.1+ascend.20220505 + - torch: 1.8.1+ascend.rc2.20220505 + - torch-npu: 1.8.1rc2.post20220505 ## Training @@ -21,32 +27,28 @@ To train a model, run scripts with the desired model architecture and the path t ```bash # 1p train 1p -bash test/train_full_1p.sh --data_path={data/path} # train accuracy - +# run 1 epoch bash test/train_performance_1p.sh --data_path={data/path} # train performance -# 8p train 8p -bash test/train_full_8p.sh --data_path={data/path} # train accuracy - +# 8p train 8p +# run 1 epcoh bash test/train_performance_8p.sh --data_path={data/path} # train performance +# run 100 epoch, running time: 27h +bash test/train_full_8p.sh --data_path={data/path} # train accuracy # 1p eval 1p bash test/train_eval_8p.sh --data_path={data/path} - -# online inference demo -python3.7 demo.py - -# To ONNX -python3.7.5 pthtar2onnx.py - ``` ## EfficientNet-B3 training result -| Acc@1 | FPS | Npu_nums | Epochs | AMP_Type | -| :----: | :--: | :------: | :----: | :------: | -| - | 267 | 1 | 100 | O2 | -| 77.3418 | 1558 | 8 | 100 | O2 | +| Acc@1 | FPS | Npu_nums | Epochs | AMP_Type | Torch | +| :----: | :--: | :------: | :----: | :------: | :---: | +| - | 267 | 1 | 100 | O2 | 1.5 | +| 77.3418 | 1558 | 8 | 100 | O2 | 1.5 | +| - | 321 | 1 | 100 | O2 | 1.8 | +| 77.0613 | 1317 | 8 | 100 | O2 | 1.8 | + diff --git a/PyTorch/contrib/cv/classification/EfficientNet-B3/requirements.txt b/PyTorch/contrib/cv/classification/EfficientNet-B3/requirements.txt index 678848ed81..9e9fc6bb5a 100644 --- a/PyTorch/contrib/cv/classification/EfficientNet-B3/requirements.txt +++ b/PyTorch/contrib/cv/classification/EfficientNet-B3/requirements.txt @@ -1,7 +1,22 @@ -isort==4.3.21 -fvcore -parameterized -setuptools -simplejson -yacs - +certifi==2018.10.15 +cycler==0.11.0 +decorator==5.1.1 +fonttools==4.33.3 +iopath==0.1.9 +kiwisolver==1.4.3 +matplotlib==3.5.2 +mpmath==1.2.1 +numpy==1.21.6 +opencv-python==4.6.0.66 +packaging==21.3 +Pillow==9.1.1 +portalocker==2.4.0 +pyparsing==3.0.9 +python-dateutil==2.8.2 +PyYAML==6.0 +simplejson==3.17.6 +six==1.16.0 +sympy==1.10.1 +tqdm==4.64.0 +typing_extensions==4.2.0 +yacs==0.1.8 diff --git a/PyTorch/contrib/cv/classification/EfficientNet-B3/test/train_eval_8p.sh b/PyTorch/contrib/cv/classification/EfficientNet-B3/test/train_eval_8p.sh index e96a5c713d..7904f2eb47 100644 --- a/PyTorch/contrib/cv/classification/EfficientNet-B3/test/train_eval_8p.sh +++ b/PyTorch/contrib/cv/classification/EfficientNet-B3/test/train_eval_8p.sh @@ -41,7 +41,7 @@ fi # 数据集软链到脚本内部 cur_path=`pwd` -default_data_path=${cur_path}/pycls/datasets/data/ +default_data_path=${cur_path}/pycls/datasets/data rm -rf ${default_data_path}/imagenet ln -s ${data_path} ${default_data_path}/imagenet diff --git a/PyTorch/contrib/cv/classification/EfficientNet-B3/test/train_full_1p.sh b/PyTorch/contrib/cv/classification/EfficientNet-B3/test/train_full_1p.sh index ee7ed711a4..077f096b4d 100644 --- a/PyTorch/contrib/cv/classification/EfficientNet-B3/test/train_full_1p.sh +++ b/PyTorch/contrib/cv/classification/EfficientNet-B3/test/train_full_1p.sh @@ -49,7 +49,7 @@ fi # 数据集软链到脚本内 cur_path=`pwd` -default_data_path=${cur_path}/pycls/datasets/data/ +default_data_path=${cur_path}/pycls/datasets/data rm -rf ${default_data_path}/imagenet ln -s ${data_path} ${default_data_path}/imagenet diff --git a/PyTorch/contrib/cv/classification/EfficientNet-B3/test/train_full_8p.sh b/PyTorch/contrib/cv/classification/EfficientNet-B3/test/train_full_8p.sh index a2d1bc6d9d..8b8cd6793b 100644 --- a/PyTorch/contrib/cv/classification/EfficientNet-B3/test/train_full_8p.sh +++ b/PyTorch/contrib/cv/classification/EfficientNet-B3/test/train_full_8p.sh @@ -33,7 +33,7 @@ fi # 数据集软链到脚本内部 cur_path=`pwd` -default_data_path=${cur_path}/pycls/datasets/data/ +default_data_path=${cur_path}/pycls/datasets/data rm -rf ${default_data_path}/imagenet ln -s ${data_path} ${default_data_path}/imagenet diff --git a/PyTorch/contrib/cv/classification/EfficientNet-B3/test/train_performance_1p.sh b/PyTorch/contrib/cv/classification/EfficientNet-B3/test/train_performance_1p.sh index b6dbf22b45..c7b30add5a 100644 --- a/PyTorch/contrib/cv/classification/EfficientNet-B3/test/train_performance_1p.sh +++ b/PyTorch/contrib/cv/classification/EfficientNet-B3/test/train_performance_1p.sh @@ -49,7 +49,7 @@ fi # 数据集软链到脚本内 cur_path=`pwd` -default_data_path=${cur_path}/pycls/datasets/data/ +default_data_path=${cur_path}/pycls/datasets/data rm -rf ${default_data_path}/imagenet ln -s ${data_path} ${default_data_path}/imagenet diff --git a/PyTorch/contrib/cv/classification/EfficientNet-B3/test/train_performance_8p.sh b/PyTorch/contrib/cv/classification/EfficientNet-B3/test/train_performance_8p.sh index a0c0fe3139..fe0ba90c37 100644 --- a/PyTorch/contrib/cv/classification/EfficientNet-B3/test/train_performance_8p.sh +++ b/PyTorch/contrib/cv/classification/EfficientNet-B3/test/train_performance_8p.sh @@ -33,7 +33,7 @@ fi # 数据集软链到脚本内部 cur_path=`pwd` -default_data_path=${cur_path}/pycls/datasets/data/ +default_data_path=${cur_path}/pycls/datasets/data rm -rf ${default_data_path}/imagenet ln -s ${data_path} ${default_data_path}/imagenet diff --git a/PyTorch/contrib/cv/classification/EfficientNet-B3/tools/train_net.py b/PyTorch/contrib/cv/classification/EfficientNet-B3/tools/train_net.py index 270aca8c40..a61ffbc1b7 100644 --- a/PyTorch/contrib/cv/classification/EfficientNet-B3/tools/train_net.py +++ b/PyTorch/contrib/cv/classification/EfficientNet-B3/tools/train_net.py @@ -29,6 +29,8 @@ import pycls.core.trainer as trainer from pycls.core.config import cfg import argparse,sys,os,torch import torch +if torch.__version__>= '1.8.1': + import torch_npu def init_process_group(proc_rank, world_size, device_type="npu", port="29588"): """Initializes the default process group.""" -- Gitee From 64800aa4dda69320c20ec80a5b0dc1f479c72552 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A5=9D=E5=BB=BA=E4=BC=9F?= <11215357+stu_zhu@user.noreply.gitee.com> Date: Mon, 25 Jul 2022 02:57:51 +0000 Subject: [PATCH 2/5] update PyTorch/contrib/cv/classification/EfficientNet-B3/README.md. --- .../cv/classification/EfficientNet-B3/README.md | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/PyTorch/contrib/cv/classification/EfficientNet-B3/README.md b/PyTorch/contrib/cv/classification/EfficientNet-B3/README.md index 36da255163..cc0b6b5434 100644 --- a/PyTorch/contrib/cv/classification/EfficientNet-B3/README.md +++ b/PyTorch/contrib/cv/classification/EfficientNet-B3/README.md @@ -15,17 +15,22 @@ This implements training of Efficientnet-B3 on the ImageNet dataset, mainly modi - git clone https://github.com/facebookresearch/pycls - pip install -r requirements.txt - modify path of dataset in pycls/datasets/loader.py, you can modify the variable _DATA_DIR to your path of imagenet dataset. -- Download the ImageNet dataset +- Download the ImageNet dataset and Dataset must be in Efficientnet-B3/Pycls/datasets/data - Note: Torch and Apex are linux_AARCH64 architecture packages - - apex: 0.1+ascend.20220505 - - torch: 1.8.1+ascend.rc2.20220505 + - CANN: 5.0.RC1 + - Pytorch: 1.8.1+ascend.rc2.20220712 - torch-npu: 1.8.1rc2.post20220505 + - python:3.7.5 + - OS:Ubuntu 18.04.6+aarch ## Training To train a model, run scripts with the desired model architecture and the path to the ImageNet dataset: ```bash +# Link the dataset from source to target +ln -s {data/path} EfficientNet-B3/pycls/dataset/data + # 1p train 1p # run 1 epoch bash test/train_performance_1p.sh --data_path={data/path} # train performance -- Gitee From dea03fe5c27f643067b0047f1adff6d221202f12 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A5=9D=E5=BB=BA=E4=BC=9F?= <11215357+stu_zhu@user.noreply.gitee.com> Date: Mon, 25 Jul 2022 03:13:46 +0000 Subject: [PATCH 3/5] update PyTorch/contrib/cv/classification/EfficientNet-B3/README.md. --- PyTorch/contrib/cv/classification/EfficientNet-B3/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/PyTorch/contrib/cv/classification/EfficientNet-B3/README.md b/PyTorch/contrib/cv/classification/EfficientNet-B3/README.md index cc0b6b5434..cd3ee2f5e4 100644 --- a/PyTorch/contrib/cv/classification/EfficientNet-B3/README.md +++ b/PyTorch/contrib/cv/classification/EfficientNet-B3/README.md @@ -15,7 +15,7 @@ This implements training of Efficientnet-B3 on the ImageNet dataset, mainly modi - git clone https://github.com/facebookresearch/pycls - pip install -r requirements.txt - modify path of dataset in pycls/datasets/loader.py, you can modify the variable _DATA_DIR to your path of imagenet dataset. -- Download the ImageNet dataset and Dataset must be in Efficientnet-B3/Pycls/datasets/data +- Download the ImageNet dataset and Dataset must be in Efficientnet-B3/pycls/datasets/data - Note: Torch and Apex are linux_AARCH64 architecture packages - CANN: 5.0.RC1 - Pytorch: 1.8.1+ascend.rc2.20220712 @@ -29,7 +29,7 @@ To train a model, run scripts with the desired model architecture and the path t ```bash # Link the dataset from source to target -ln -s {data/path} EfficientNet-B3/pycls/dataset/data +ln -s {data/path} EfficientNet-B3/pycls/datasets/data # 1p train 1p # run 1 epoch -- Gitee From 5e95780cdd5b6c1b15b043c10e4957da256142b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A5=9D=E5=BB=BA=E4=BC=9F?= <1076413770@qq.com> Date: Mon, 1 Aug 2022 14:00:23 +0800 Subject: [PATCH 4/5] =?UTF-8?q?'[=E8=A5=BF=E5=AE=89=E4=BA=A4=E9=80=9A?= =?UTF-8?q?=E5=A4=A7=E5=AD=A6][=E9=AB=98=E6=A0=A1=E8=B4=A1=E7=8C=AE][Pytor?= =?UTF-8?q?ch][EfficientNet-B3]--=E5=88=9D=E6=AC=A1=E6=8F=90=E4=BA=A4'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cv/classification/EfficientNet-B3/README.md | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/PyTorch/contrib/cv/classification/EfficientNet-B3/README.md b/PyTorch/contrib/cv/classification/EfficientNet-B3/README.md index 36da255163..cd3ee2f5e4 100644 --- a/PyTorch/contrib/cv/classification/EfficientNet-B3/README.md +++ b/PyTorch/contrib/cv/classification/EfficientNet-B3/README.md @@ -15,17 +15,22 @@ This implements training of Efficientnet-B3 on the ImageNet dataset, mainly modi - git clone https://github.com/facebookresearch/pycls - pip install -r requirements.txt - modify path of dataset in pycls/datasets/loader.py, you can modify the variable _DATA_DIR to your path of imagenet dataset. -- Download the ImageNet dataset +- Download the ImageNet dataset and Dataset must be in Efficientnet-B3/pycls/datasets/data - Note: Torch and Apex are linux_AARCH64 architecture packages - - apex: 0.1+ascend.20220505 - - torch: 1.8.1+ascend.rc2.20220505 + - CANN: 5.0.RC1 + - Pytorch: 1.8.1+ascend.rc2.20220712 - torch-npu: 1.8.1rc2.post20220505 + - python:3.7.5 + - OS:Ubuntu 18.04.6+aarch ## Training To train a model, run scripts with the desired model architecture and the path to the ImageNet dataset: ```bash +# Link the dataset from source to target +ln -s {data/path} EfficientNet-B3/pycls/datasets/data + # 1p train 1p # run 1 epoch bash test/train_performance_1p.sh --data_path={data/path} # train performance -- Gitee From e0e87b4788ef7eb7eec395db71ee932f8fb425e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A5=9D=E5=BB=BA=E4=BC=9F?= <1076413770@qq.com> Date: Mon, 1 Aug 2022 18:07:19 +0800 Subject: [PATCH 5/5] =?UTF-8?q?'[=E8=A5=BF=E5=AE=89=E4=BA=A4=E9=80=9A?= =?UTF-8?q?=E5=A4=A7=E5=AD=A6][=E9=AB=98=E6=A0=A1=E8=B4=A1=E7=8C=AE][Pytor?= =?UTF-8?q?ch][EfficientNet-B3]--=E5=88=9D=E6=AC=A1=E6=8F=90=E4=BA=A4'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cv/classification/EfficientNet-B3/tools/train_net.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PyTorch/contrib/cv/classification/EfficientNet-B3/tools/train_net.py b/PyTorch/contrib/cv/classification/EfficientNet-B3/tools/train_net.py index a61ffbc1b7..e5d6d0abd9 100644 --- a/PyTorch/contrib/cv/classification/EfficientNet-B3/tools/train_net.py +++ b/PyTorch/contrib/cv/classification/EfficientNet-B3/tools/train_net.py @@ -29,7 +29,7 @@ import pycls.core.trainer as trainer from pycls.core.config import cfg import argparse,sys,os,torch import torch -if torch.__version__>= '1.8.1': +if torch.__version__>= '1.8': import torch_npu def init_process_group(proc_rank, world_size, device_type="npu", port="29588"): -- Gitee