From 9784a58da2afb4a4f1bd928cdd0c95882a986a64 Mon Sep 17 00:00:00 2001 From: wukesong Date: Fri, 21 Aug 2020 17:23:55 +0800 Subject: [PATCH] add script shell --- .../official/cv/alexnet/requirements.txt | 2 ++ .../scripts/run_standalone_eval_ascend.sh | 22 +++++++++++++++++++ .../scripts/run_standalone_eval_gpu.sh | 22 +++++++++++++++++++ .../scripts/run_standalone_train_ascend.sh | 22 +++++++++++++++++++ .../scripts/run_standalone_train_gpu.sh | 22 +++++++++++++++++++ model_zoo/official/cv/lenet/requirements.txt | 1 + .../scripts/run_standalone_eval_ascend.sh | 22 +++++++++++++++++++ .../lenet/scripts/run_standalone_eval_cpu.sh | 22 +++++++++++++++++++ .../lenet/scripts/run_standalone_eval_gpu.sh | 22 +++++++++++++++++++ .../scripts/run_standalone_train_ascend.sh | 22 +++++++++++++++++++ .../lenet/scripts/run_standalone_train_cpu.sh | 22 +++++++++++++++++++ .../lenet/scripts/run_standalone_train_gpu.sh | 22 +++++++++++++++++++ model_zoo/official/cv/lenet/train.py | 4 +++- 13 files changed, 226 insertions(+), 1 deletion(-) create mode 100644 model_zoo/official/cv/alexnet/requirements.txt create mode 100755 model_zoo/official/cv/alexnet/scripts/run_standalone_eval_ascend.sh create mode 100755 model_zoo/official/cv/alexnet/scripts/run_standalone_eval_gpu.sh create mode 100755 model_zoo/official/cv/alexnet/scripts/run_standalone_train_ascend.sh create mode 100755 model_zoo/official/cv/alexnet/scripts/run_standalone_train_gpu.sh create mode 100644 model_zoo/official/cv/lenet/requirements.txt create mode 100755 model_zoo/official/cv/lenet/scripts/run_standalone_eval_ascend.sh create mode 100755 model_zoo/official/cv/lenet/scripts/run_standalone_eval_cpu.sh create mode 100755 model_zoo/official/cv/lenet/scripts/run_standalone_eval_gpu.sh create mode 100755 model_zoo/official/cv/lenet/scripts/run_standalone_train_ascend.sh create mode 100755 model_zoo/official/cv/lenet/scripts/run_standalone_train_cpu.sh create mode 100755 model_zoo/official/cv/lenet/scripts/run_standalone_train_gpu.sh diff --git a/model_zoo/official/cv/alexnet/requirements.txt b/model_zoo/official/cv/alexnet/requirements.txt new file mode 100644 index 00000000000..309f5bb846e --- /dev/null +++ b/model_zoo/official/cv/alexnet/requirements.txt @@ -0,0 +1,2 @@ +easydict +numpy \ No newline at end of file diff --git a/model_zoo/official/cv/alexnet/scripts/run_standalone_eval_ascend.sh b/model_zoo/official/cv/alexnet/scripts/run_standalone_eval_ascend.sh new file mode 100755 index 00000000000..0a9cb9fb869 --- /dev/null +++ b/model_zoo/official/cv/alexnet/scripts/run_standalone_eval_ascend.sh @@ -0,0 +1,22 @@ +#!/bin/bash +# Copyright 2020 Huawei Technologies Co., Ltd +# +# 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. +# ============================================================================ + +# an simple tutorial as follows, more parameters can be setting +script_self=$(readlink -f "$0") +self_path=$(dirname "${script_self}") +DATA_PATH=$1 +CKPT_PATH=$2 +python -s ${self_path}/../eval.py --data_path=./$DATA_PATH --device_target="Ascend" --ckpt_path=./$CKPT_PATH > log.txt 2>&1 & diff --git a/model_zoo/official/cv/alexnet/scripts/run_standalone_eval_gpu.sh b/model_zoo/official/cv/alexnet/scripts/run_standalone_eval_gpu.sh new file mode 100755 index 00000000000..c3713cbc4a1 --- /dev/null +++ b/model_zoo/official/cv/alexnet/scripts/run_standalone_eval_gpu.sh @@ -0,0 +1,22 @@ +#!/bin/bash +# Copyright 2020 Huawei Technologies Co., Ltd +# +# 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. +# ============================================================================ + +# an simple tutorial as follows, more parameters can be setting +script_self=$(readlink -f "$0") +self_path=$(dirname "${script_self}") +DATA_PATH=$1 +CKPT_PATH=$2 +python -s ${self_path}/../eval.py --data_path=./$DATA_PATH --device_target="GPU" --ckpt_path=./$CKPT_PATH > log.txt 2>&1 & diff --git a/model_zoo/official/cv/alexnet/scripts/run_standalone_train_ascend.sh b/model_zoo/official/cv/alexnet/scripts/run_standalone_train_ascend.sh new file mode 100755 index 00000000000..f17ca01b2ff --- /dev/null +++ b/model_zoo/official/cv/alexnet/scripts/run_standalone_train_ascend.sh @@ -0,0 +1,22 @@ +#!/bin/bash +# Copyright 2020 Huawei Technologies Co., Ltd +# +# 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. +# ============================================================================ + +# an simple tutorial, more +script_self=$(readlink -f "$0") +self_path=$(dirname "${script_self}") +DATA_PATH=$1 +CKPT_PATH=$2 +python -s ${self_path}/../train.py --data_path=./$DATA_PATH --device_target="Ascend" --ckpt_path=./$CKPT_PATH > log.txt 2>&1 & diff --git a/model_zoo/official/cv/alexnet/scripts/run_standalone_train_gpu.sh b/model_zoo/official/cv/alexnet/scripts/run_standalone_train_gpu.sh new file mode 100755 index 00000000000..7f794878432 --- /dev/null +++ b/model_zoo/official/cv/alexnet/scripts/run_standalone_train_gpu.sh @@ -0,0 +1,22 @@ +#!/bin/bash +# Copyright 2020 Huawei Technologies Co., Ltd +# +# 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. +# ============================================================================ + +# an simple tutorial as follows, more parameters can be setting +script_self=$(readlink -f "$0") +self_path=$(dirname "${script_self}") +DATA_PATH=$1 +CKPT_PATH=$2 +python -s ${self_path}/../train.py --data_path=./$DATA_PATH --device_target="GPU" --ckpt_path=./$CKPT_PATH > log.txt 2>&1 & diff --git a/model_zoo/official/cv/lenet/requirements.txt b/model_zoo/official/cv/lenet/requirements.txt new file mode 100644 index 00000000000..66799b7632a --- /dev/null +++ b/model_zoo/official/cv/lenet/requirements.txt @@ -0,0 +1 @@ +easydict diff --git a/model_zoo/official/cv/lenet/scripts/run_standalone_eval_ascend.sh b/model_zoo/official/cv/lenet/scripts/run_standalone_eval_ascend.sh new file mode 100755 index 00000000000..0a9cb9fb869 --- /dev/null +++ b/model_zoo/official/cv/lenet/scripts/run_standalone_eval_ascend.sh @@ -0,0 +1,22 @@ +#!/bin/bash +# Copyright 2020 Huawei Technologies Co., Ltd +# +# 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. +# ============================================================================ + +# an simple tutorial as follows, more parameters can be setting +script_self=$(readlink -f "$0") +self_path=$(dirname "${script_self}") +DATA_PATH=$1 +CKPT_PATH=$2 +python -s ${self_path}/../eval.py --data_path=./$DATA_PATH --device_target="Ascend" --ckpt_path=./$CKPT_PATH > log.txt 2>&1 & diff --git a/model_zoo/official/cv/lenet/scripts/run_standalone_eval_cpu.sh b/model_zoo/official/cv/lenet/scripts/run_standalone_eval_cpu.sh new file mode 100755 index 00000000000..1d709a7b711 --- /dev/null +++ b/model_zoo/official/cv/lenet/scripts/run_standalone_eval_cpu.sh @@ -0,0 +1,22 @@ +#!/bin/bash +# Copyright 2020 Huawei Technologies Co., Ltd +# +# 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. +# ============================================================================ + +# an simple tutorial as follows, more parameters can be setting +script_self=$(readlink -f "$0") +self_path=$(dirname "${script_self}") +DATA_PATH=$1 +CKPT_PATH=$2 +python -s ${self_path}/../eval.py --data_path=./$DATA_PATH --device_target="CPU" --ckpt_path=./$CKPT_PATH > log.txt 2>&1 & diff --git a/model_zoo/official/cv/lenet/scripts/run_standalone_eval_gpu.sh b/model_zoo/official/cv/lenet/scripts/run_standalone_eval_gpu.sh new file mode 100755 index 00000000000..c3713cbc4a1 --- /dev/null +++ b/model_zoo/official/cv/lenet/scripts/run_standalone_eval_gpu.sh @@ -0,0 +1,22 @@ +#!/bin/bash +# Copyright 2020 Huawei Technologies Co., Ltd +# +# 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. +# ============================================================================ + +# an simple tutorial as follows, more parameters can be setting +script_self=$(readlink -f "$0") +self_path=$(dirname "${script_self}") +DATA_PATH=$1 +CKPT_PATH=$2 +python -s ${self_path}/../eval.py --data_path=./$DATA_PATH --device_target="GPU" --ckpt_path=./$CKPT_PATH > log.txt 2>&1 & diff --git a/model_zoo/official/cv/lenet/scripts/run_standalone_train_ascend.sh b/model_zoo/official/cv/lenet/scripts/run_standalone_train_ascend.sh new file mode 100755 index 00000000000..9f4e238dbbc --- /dev/null +++ b/model_zoo/official/cv/lenet/scripts/run_standalone_train_ascend.sh @@ -0,0 +1,22 @@ +#!/bin/bash +# Copyright 2020 Huawei Technologies Co., Ltd +# +# 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. +# ============================================================================ + +# an simple tutorial as follows, more parameters can be setting +script_self=$(readlink -f "$0") +self_path=$(dirname "${script_self}") +DATA_PATH=$1 +CKPT_PATH=$2 +python -s ${self_path}/../train.py --data_path=./$DATA_PATH --device_target="Ascend" --ckpt_path=./$CKPT_PATH > log.txt 2>&1 & \ No newline at end of file diff --git a/model_zoo/official/cv/lenet/scripts/run_standalone_train_cpu.sh b/model_zoo/official/cv/lenet/scripts/run_standalone_train_cpu.sh new file mode 100755 index 00000000000..f9234cf8220 --- /dev/null +++ b/model_zoo/official/cv/lenet/scripts/run_standalone_train_cpu.sh @@ -0,0 +1,22 @@ +#!/bin/bash +# Copyright 2020 Huawei Technologies Co., Ltd +# +# 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. +# ============================================================================ + +# an simple tutorial as follows, more parameters can be setting +script_self=$(readlink -f "$0") +self_path=$(dirname "${script_self}") +DATA_PATH=$1 +CKPT_PATH=$2 +python -s ${self_path}/../train.py --data_path=./$DATA_PATH --device_target="CPU" --ckpt_path=./$CKPT_PATH > log.txt 2>&1 & diff --git a/model_zoo/official/cv/lenet/scripts/run_standalone_train_gpu.sh b/model_zoo/official/cv/lenet/scripts/run_standalone_train_gpu.sh new file mode 100755 index 00000000000..7f794878432 --- /dev/null +++ b/model_zoo/official/cv/lenet/scripts/run_standalone_train_gpu.sh @@ -0,0 +1,22 @@ +#!/bin/bash +# Copyright 2020 Huawei Technologies Co., Ltd +# +# 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. +# ============================================================================ + +# an simple tutorial as follows, more parameters can be setting +script_self=$(readlink -f "$0") +self_path=$(dirname "${script_self}") +DATA_PATH=$1 +CKPT_PATH=$2 +python -s ${self_path}/../train.py --data_path=./$DATA_PATH --device_target="GPU" --ckpt_path=./$CKPT_PATH > log.txt 2>&1 & diff --git a/model_zoo/official/cv/lenet/train.py b/model_zoo/official/cv/lenet/train.py index 22828421884..2c45c5b3274 100644 --- a/model_zoo/official/cv/lenet/train.py +++ b/model_zoo/official/cv/lenet/train.py @@ -36,6 +36,8 @@ if __name__ == "__main__": help='device where the code will be implemented (default: Ascend)') parser.add_argument('--data_path', type=str, default="./Data", help='path where the dataset is saved') + parser.add_argument('--ckpt_path', type=str, default="./ckpt", help='if is test, must provide\ + path where the trained ckpt file') parser.add_argument('--dataset_sink_mode', type=bool, default=True, help='dataset_sink_mode is False or True') args = parser.parse_args() @@ -53,7 +55,7 @@ if __name__ == "__main__": time_cb = TimeMonitor(data_size=ds_train.get_dataset_size()) config_ck = CheckpointConfig(save_checkpoint_steps=cfg.save_checkpoint_steps, keep_checkpoint_max=cfg.keep_checkpoint_max) - ckpoint_cb = ModelCheckpoint(prefix="checkpoint_lenet", config=config_ck) + ckpoint_cb = ModelCheckpoint(prefix="checkpoint_lenet", directory=args.ckpt_path, config=config_ck) model = Model(network, net_loss, net_opt, metrics={"Accuracy": Accuracy()}) print("============== Starting Training ==============")