From fe2058ab420b4831a9dd827fc81062db2cc40a66 Mon Sep 17 00:00:00 2001 From: zhouneng Date: Thu, 8 Jul 2021 11:40:49 +0800 Subject: [PATCH] fix coding mistakes --- .../cv/inceptionv4/scripts/run_distribute_train_ascend.sh | 4 +--- .../cv/inceptionv4/scripts/run_distribute_train_gpu.sh | 3 +-- .../official/cv/inceptionv4/scripts/run_eval_ascend.sh | 3 +-- model_zoo/official/cv/inceptionv4/scripts/run_eval_cpu.sh | 5 ++--- model_zoo/official/cv/inceptionv4/scripts/run_eval_gpu.sh | 5 ++--- .../cv/inceptionv4/scripts/run_standalone_train_ascend.sh | 4 +--- .../cv/inceptionv4/scripts/run_standalone_train_cpu.sh | 3 +-- model_zoo/official/cv/yolov4/src/transforms.py | 6 +++--- 8 files changed, 12 insertions(+), 21 deletions(-) diff --git a/model_zoo/official/cv/inceptionv4/scripts/run_distribute_train_ascend.sh b/model_zoo/official/cv/inceptionv4/scripts/run_distribute_train_ascend.sh index 371c39d254a..bf91ed469df 100644 --- a/model_zoo/official/cv/inceptionv4/scripts/run_distribute_train_ascend.sh +++ b/model_zoo/official/cv/inceptionv4/scripts/run_distribute_train_ascend.sh @@ -17,7 +17,6 @@ export HCCL_CONNECT_TIMEOUT=600 export RANK_TABLE_FILE=$1 DATA_DIR=$2 -DS_TYPE=$3 export RANK_SIZE=8 BASE_PATH=$(cd ./"`dirname $0`" || exit; pwd) @@ -50,7 +49,6 @@ do env > env.log taskset -c $cmdopt python -u ../train.py --config_path=$CONFIG_FILE \ --device_id $i \ - --dataset_path=$DATA_DIR \ - --ds_type=$DS_TYPE > log.txt 2>&1 & + --dataset_path=$DATA_DIR > log.txt 2>&1 & cd ../ done diff --git a/model_zoo/official/cv/inceptionv4/scripts/run_distribute_train_gpu.sh b/model_zoo/official/cv/inceptionv4/scripts/run_distribute_train_gpu.sh index cec7096884a..5331a78a675 100644 --- a/model_zoo/official/cv/inceptionv4/scripts/run_distribute_train_gpu.sh +++ b/model_zoo/official/cv/inceptionv4/scripts/run_distribute_train_gpu.sh @@ -22,7 +22,6 @@ cp -r ./src ./device cd ./device || exit DATA_DIR=$1 -DS_TYPE=$2 export DEVICE_ID=0 export RANK_SIZE=8 @@ -32,4 +31,4 @@ CONFIG_FILE="${BASE_PATH}/../default_config_gpu.yaml" echo "start training" mpirun -n $RANK_SIZE --allow-run-as-root python train.py --config_path=$CONFIG_FILE --dataset_path=$DATA_DIR \ ---platform='GPU' --ds_type=$DS_TYPE > train.log 2>&1 & +--platform='GPU' > train.log 2>&1 & diff --git a/model_zoo/official/cv/inceptionv4/scripts/run_eval_ascend.sh b/model_zoo/official/cv/inceptionv4/scripts/run_eval_ascend.sh index 823a1a62b0e..32b1c3cb044 100644 --- a/model_zoo/official/cv/inceptionv4/scripts/run_eval_ascend.sh +++ b/model_zoo/official/cv/inceptionv4/scripts/run_eval_ascend.sh @@ -17,7 +17,6 @@ export DEVICE_ID=$1 DATA_DIR=$2 CHECKPOINT_PATH=$3 -DS_TYPE=$4 export RANK_SIZE=1 BASE_PATH=$(cd ./"`dirname $0`" || exit; pwd) @@ -29,5 +28,5 @@ cd ./evaluation_ascend || exit echo "start training for device id $DEVICE_ID" env > env.log python ../eval.py --config_path=$CONFIG_FILE --platform=Ascend --dataset_path=$DATA_DIR \ ---checkpoint_path=$CHECKPOINT_PATH --ds_type=$DS_TYPE > eval.log 2>&1 & +--checkpoint_path=$CHECKPOINT_PATH > eval.log 2>&1 & cd ../ diff --git a/model_zoo/official/cv/inceptionv4/scripts/run_eval_cpu.sh b/model_zoo/official/cv/inceptionv4/scripts/run_eval_cpu.sh index 11010a57dac..a082617b071 100644 --- a/model_zoo/official/cv/inceptionv4/scripts/run_eval_cpu.sh +++ b/model_zoo/official/cv/inceptionv4/scripts/run_eval_cpu.sh @@ -23,11 +23,10 @@ cd ./evaluation || exit DATA_DIR=$1 CKPT_DIR=$2 -DS_TYPE=$3 BASE_PATH=$(cd ./"`dirname $0`" || exit; pwd) CONFIG_FILE="${BASE_PATH}/../default_config_cpu.yaml" echo "start evaluation" -python eval.py --config_path=$CONFIG_FILE --dataset_path=$DATA_DIR --checkpoint_path=$CKPT_DIR --platform='CPU' \ ---ds_type=$DS_TYPE > eval.log 2>&1 & +python eval.py --config_path=$CONFIG_FILE --dataset_path=$DATA_DIR --checkpoint_path=$CKPT_DIR \ +--platform='CPU' > eval.log 2>&1 & diff --git a/model_zoo/official/cv/inceptionv4/scripts/run_eval_gpu.sh b/model_zoo/official/cv/inceptionv4/scripts/run_eval_gpu.sh index 00d07ae5d66..11e305fefcd 100644 --- a/model_zoo/official/cv/inceptionv4/scripts/run_eval_gpu.sh +++ b/model_zoo/official/cv/inceptionv4/scripts/run_eval_gpu.sh @@ -26,11 +26,10 @@ export RANK_SIZE=1 DATA_DIR=$1 CKPT_DIR=$2 -DS_TYPE=$3 BASE_PATH=$(cd ./"`dirname $0`" || exit; pwd) CONFIG_FILE="${BASE_PATH}/../default_config_gpu.yaml" echo "start evaluation" -python eval.py --config_path=$CONFIG_FILE --dataset_path=$DATA_DIR --checkpoint_path=$CKPT_DIR --platform='GPU' \ ---ds_type=$DS_TYPE > eval.log 2>&1 & +python eval.py --config_path=$CONFIG_FILE --dataset_path=$DATA_DIR --checkpoint_path=$CKPT_DIR \ +--platform='GPU' > eval.log 2>&1 & diff --git a/model_zoo/official/cv/inceptionv4/scripts/run_standalone_train_ascend.sh b/model_zoo/official/cv/inceptionv4/scripts/run_standalone_train_ascend.sh index 3e7d09703f4..55444ac6381 100644 --- a/model_zoo/official/cv/inceptionv4/scripts/run_standalone_train_ascend.sh +++ b/model_zoo/official/cv/inceptionv4/scripts/run_standalone_train_ascend.sh @@ -17,7 +17,6 @@ export RANK_SIZE=1 export DEVICE_ID=$1 DATA_DIR=$2 -DS_TYPE=$3 BASE_PATH=$(cd ./"`dirname $0`" || exit; pwd) CONFIG_FILE="${BASE_PATH}/../default_config.yaml" @@ -28,6 +27,5 @@ echo "start training for device id $DEVICE_ID" env > env.log python -u ../train.py --config_path=$CONFIG_FILE \ --device_id=$1 \ - --dataset_path=$DATA_DIR \ - --ds_type=$DS_TYPE > log.txt 2>&1 & + --dataset_path=$DATA_DIR > log.txt 2>&1 & cd ../ diff --git a/model_zoo/official/cv/inceptionv4/scripts/run_standalone_train_cpu.sh b/model_zoo/official/cv/inceptionv4/scripts/run_standalone_train_cpu.sh index c31ed2b1757..1453b0953e0 100644 --- a/model_zoo/official/cv/inceptionv4/scripts/run_standalone_train_cpu.sh +++ b/model_zoo/official/cv/inceptionv4/scripts/run_standalone_train_cpu.sh @@ -15,7 +15,6 @@ # ============================================================================ DATA_DIR=$1 -DS_TYPE=$2 BASE_PATH=$(cd ./"`dirname $0`" || exit; pwd) CONFIG_FILE="${BASE_PATH}/../default_config_cpu.yaml" @@ -25,5 +24,5 @@ mkdir ./train_standalone cd ./train_standalone || exit env > env.log python -u ../train.py --config_path=$CONFIG_FILE \ - --dataset_path=$DATA_DIR --platform=CPU --ds_type=$DS_TYPE > log.txt 2>&1 & + --dataset_path=$DATA_DIR --platform=CPU > log.txt 2>&1 & cd ../ diff --git a/model_zoo/official/cv/yolov4/src/transforms.py b/model_zoo/official/cv/yolov4/src/transforms.py index 83d275be1c2..4bbb69448fc 100644 --- a/model_zoo/official/cv/yolov4/src/transforms.py +++ b/model_zoo/official/cv/yolov4/src/transforms.py @@ -19,7 +19,7 @@ import copy import numpy as np from PIL import Image import cv2 -from model_utils.config import config + def _rand(a=0., b=1.): return np.random.rand() * (b - a) + a @@ -550,13 +550,13 @@ class MultiScaleTrans: if self.size_dict.get(seed_key, None) is None: random.seed(seed_key) - new_size = random.choice(config.multi_scale) + new_size = random.choice(self.default_config.multi_scale) self.size_dict[seed_key] = new_size seed = seed_key input_size = self.size_dict[seed] for img, anno in zip(imgs, annos): - img, anno = preprocess_fn(img, anno, config, input_size, self.device_num, self.each_multiscale) + img, anno = preprocess_fn(img, anno, self.default_config, input_size, self.device_num, self.each_multiscale) ret_imgs.append(img.transpose(2, 0, 1).copy()) bbox_true_1, bbox_true_2, bbox_true_3, gt_box1, gt_box2, gt_box3 = \ _preprocess_true_boxes(true_boxes=anno, anchors=self.anchor_scales, in_shape=img.shape[0:2],