From e78372b101d1505be3fce46bc72a48ceb15557e4 Mon Sep 17 00:00:00 2001 From: zhouyuanshen Date: Fri, 31 Jul 2020 16:31:05 +0800 Subject: [PATCH] pretrained_model must be set when run training tasks --- model_zoo/official/cv/faster_rcnn/README.md | 4 ++-- .../scripts/run_distribute_train.sh | 24 +++++++------------ .../scripts/run_standalone_train.sh | 24 +++++++------------ 3 files changed, 18 insertions(+), 34 deletions(-) diff --git a/model_zoo/official/cv/faster_rcnn/README.md b/model_zoo/official/cv/faster_rcnn/README.md index 9b29d4aabf..56be9bfa79 100644 --- a/model_zoo/official/cv/faster_rcnn/README.md +++ b/model_zoo/official/cv/faster_rcnn/README.md @@ -94,7 +94,7 @@ sh run_standalone_train.sh [PRETRAINED_MODEL] ``` > Rank_table.json which is specified by RANK_TABLE_FILE 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. +> As for PRETRAINED_MODEL,it should be a ResNet50 checkpoint that trained over ImageNet2012. Ready-made pretrained_models are not available now. Stay tuned. #### Result @@ -125,7 +125,7 @@ sh run_eval.sh [VALIDATION_JSON_FILE] [CHECKPOINT_PATH] #### Result -Inference result will be stored in the example path, whose folder name is "infer". Under this, you can find result like the followings in log. +Inference result will be stored in the example path, whose folder name is "eval". Under this, you can find result like the followings in log. ``` Average Precision (AP) @[ IoU=0.50:0.95 | area= all | maxDets=100 ] = 0.360 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 b790f32a53..015730269a 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 [ $# -lt 1 ] || [ $# -gt 2 ] +if [ $# -ne 2 ] then echo "Usage: sh run_train.sh [RANK_TABLE_FILE] [PRETRAINED_PATH]" exit 1 @@ -37,15 +37,12 @@ then exit 1 fi -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 +PATH2=$(get_real_path $2) +echo $PATH2 +if [ ! -f $PATH2 ] +then + echo "error: PRETRAINED_PATH=$PATH2 is not a file" +exit 1 fi ulimit -u unlimited @@ -65,11 +62,6 @@ do cd ./train_parallel$i || exit echo "start training for rank $RANK_ID, device $DEVICE_ID" env > env.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 + python train.py --do_train=True --device_id=$i --rank_id=$i --run_distribute=True --device_num=$DEVICE_NUM --pre_trained=$PATH2 &> log & 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 6f14e2a4c0..3239cabeb1 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 [ $# -gt 1 ] +if [ $# -ne 1 ] then echo "Usage: sh run_standalone_train.sh [PRETRAINED_PATH]" exit 1 @@ -28,16 +28,13 @@ get_real_path(){ fi } -if [ $# == 1 ] -then - PATH1=$(get_real_path $1) - echo $PATH1 +PATH1=$(get_real_path $1) +echo $PATH1 - if [ ! -f $PATH1 ] - then - echo "error: PRETRAINED_PATH=$PATH1 is not a file" - exit 1 - fi +if [ ! -f $PATH1 ] +then + echo "error: PRETRAINED_PATH=$PATH1 is not a file" +exit 1 fi ulimit -u unlimited @@ -57,10 +54,5 @@ cp -r ../src ./train cd ./train || exit echo "start training for device $DEVICE_ID" env > env.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 +python train.py --do_train=True --device_id=$DEVICE_ID --pre_trained=$PATH1 &> log & cd ..