diff --git a/model_zoo/official/cv/alexnet/requirements.txt b/model_zoo/official/cv/alexnet/requirements.txt new file mode 100644 index 0000000000..309f5bb846 --- /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 0000000000..0a9cb9fb86 --- /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 0000000000..c3713cbc4a --- /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 0000000000..f17ca01b2f --- /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 0000000000..7f79487843 --- /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 0000000000..66799b7632 --- /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 0000000000..0a9cb9fb86 --- /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 0000000000..1d709a7b71 --- /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 0000000000..c3713cbc4a --- /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 0000000000..9f4e238dbb --- /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 0000000000..f9234cf822 --- /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 0000000000..7f79487843 --- /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 2282842188..2c45c5b327 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 ==============")