From 7236955133e0e1ba8551908b7e021944fc74bd03 Mon Sep 17 00:00:00 2001 From: zhouyuanshen Date: Fri, 24 Jul 2020 21:20:45 +0800 Subject: [PATCH] fix README.md and shell scripts in fasterrcnn --- model_zoo/official/cv/faster_rcnn/README.md | 3 ++- .../scripts/run_distribute_train.sh | 27 ++++++++++++------- .../scripts/run_standalone_train.sh | 25 +++++++++++------ 3 files changed, 36 insertions(+), 19 deletions(-) diff --git a/model_zoo/official/cv/faster_rcnn/README.md b/model_zoo/official/cv/faster_rcnn/README.md index 6fe3fb67e36..a8f51df89d0 100644 --- a/model_zoo/official/cv/faster_rcnn/README.md +++ b/model_zoo/official/cv/faster_rcnn/README.md @@ -93,7 +93,8 @@ sh run_distribute_train.sh [MINDSPORE_HCCL_CONFIG_PATH] [PRETRAINED_MODEL] sh run_standalone_train.sh [PRETRAINED_MODEL] ``` -> About rank_table.json, you can refer to the [distributed training tutorial](https://www.mindspore.cn/tutorial/en/master/advanced_use/distributed_training.html). +> Rank_table.json which is specified by MINDSPORE_HCCL_CONFIG_PATH is needed when you are running a distribute task. You can generate it by using the [hccl_tools](https://gitee.com/mindspore/mindspore/tree/master/model_zoo/utils/hccl_tools). +> As for PRETRAINED_MODEL,if not set, the model will be trained from the very beginning.Ready-made pretrained_models are not available now. Stay tuned. #### Result diff --git a/model_zoo/official/cv/faster_rcnn/scripts/run_distribute_train.sh b/model_zoo/official/cv/faster_rcnn/scripts/run_distribute_train.sh index bc6ebd4a181..4f01831d485 100755 --- a/model_zoo/official/cv/faster_rcnn/scripts/run_distribute_train.sh +++ b/model_zoo/official/cv/faster_rcnn/scripts/run_distribute_train.sh @@ -14,7 +14,7 @@ # limitations under the License. # ============================================================================ -if [ $# != 2 ] +if [ $# -lt 1 ] || [ $# -gt 2 ] then echo "Usage: sh run_train.sh [MINDSPORE_HCCL_CONFIG_PATH] [PRETRAINED_PATH]" exit 1 @@ -27,11 +27,9 @@ get_real_path(){ echo "$(realpath -m $PWD/$1)" fi } -PATH1=$(get_real_path $1) -PATH2=$(get_real_path $2) +PATH1=$(get_real_path $1) echo $PATH1 -echo $PATH2 if [ ! -f $PATH1 ] then @@ -39,10 +37,15 @@ then exit 1 fi -if [ ! -f $PATH2 ] -then - echo "error: PRETRAINED_PATH=$PATH2 is not a file" -exit 1 +if [ $# == 2 ] +then + PATH2=$(get_real_path $2) + echo $PATH2 + if [ ! -f $PATH2 ] + then + echo "error: PRETRAINED_PATH=$PATH2 is not a file" + exit 1 + fi fi ulimit -u unlimited @@ -63,7 +66,11 @@ do cd ./train_parallel$i || exit echo "start training for rank $RANK_ID, device $DEVICE_ID" env > env.log - python train.py --do_train=True --device_id=$i --rank_id=$i --run_distribute=True --device_num=$DEVICE_NUM \ - --pre_trained=$PATH2 &> log & + if [ $# == 2 ] + then + python train.py --do_train=True --device_id=$i --rank_id=$i --run_distribute=True --device_num=$DEVICE_NUM --pre_trained=$PATH2 &> log & + else + python train.py --do_train=True --device_id=$i --rank_id=$i --run_distribute=True --device_num=$DEVICE_NUM &> log & + fi cd .. done diff --git a/model_zoo/official/cv/faster_rcnn/scripts/run_standalone_train.sh b/model_zoo/official/cv/faster_rcnn/scripts/run_standalone_train.sh index 3197da016ee..6f14e2a4c0b 100755 --- a/model_zoo/official/cv/faster_rcnn/scripts/run_standalone_train.sh +++ b/model_zoo/official/cv/faster_rcnn/scripts/run_standalone_train.sh @@ -14,7 +14,7 @@ # limitations under the License. # ============================================================================ -if [ $# != 1 ] +if [ $# -gt 1 ] then echo "Usage: sh run_standalone_train.sh [PRETRAINED_PATH]" exit 1 @@ -27,13 +27,17 @@ get_real_path(){ echo "$(realpath -m $PWD/$1)" fi } -PATH1=$(get_real_path $1) -echo $PATH1 -if [ ! -f $PATH1 ] -then - echo "error: PRETRAINED_PATH=$PATH1 is not a file" -exit 1 +if [ $# == 1 ] +then + PATH1=$(get_real_path $1) + echo $PATH1 + + if [ ! -f $PATH1 ] + then + echo "error: PRETRAINED_PATH=$PATH1 is not a file" + exit 1 + fi fi ulimit -u unlimited @@ -53,5 +57,10 @@ cp -r ../src ./train cd ./train || exit echo "start training for device $DEVICE_ID" env > env.log -python train.py --do_train=True --device_id=$DEVICE_ID --pre_trained=$PATH1 &> log & +if [ $# == 1 ] +then + python train.py --do_train=True --device_id=$DEVICE_ID --pre_trained=$PATH1 &> log & +else + python train.py --do_train=True --device_id=$DEVICE_ID &> log & +fi cd ..