!11929 some words are misssplelled in centernet script

From: @caojian05
Reviewed-by: @wuxuejian,@oacjiewen,@liangchenghui
Signed-off-by: @liangchenghui
This commit is contained in:
mindspore-ci-bot 2021-02-02 20:23:33 +08:00 committed by Gitee
commit fa0e9a2c7b
13 changed files with 34 additions and 39 deletions

View File

@ -300,7 +300,6 @@ Parameters for dataset (Training/Evaluation):
aug_rot properbility of image rotation during data augmenation: N, default is 0.0 aug_rot properbility of image rotation during data augmenation: N, default is 0.0
rotate maximum value of rotation angle during data augmentation: N, default is 0.0 rotate maximum value of rotation angle during data augmentation: N, default is 0.0
flip_prop properbility of image flip during data augmenation: N, default is 0.5 flip_prop properbility of image flip during data augmenation: N, default is 0.5
color_aug whether use color augmentation: True | False, default is False
mean mean value of RGB image mean mean value of RGB image
std variance of RGB image std variance of RGB image
flip_idx the corresponding point index of keypoints when flip the image flip_idx the corresponding point index of keypoints when flip the image

View File

@ -45,7 +45,7 @@ parser.add_argument("--data_dir", type=str, default="", help="Dataset directory,
"and the relative path in anno_path") "and the relative path in anno_path")
parser.add_argument("--run_mode", type=str, default="test", help="test or validation, default is test.") parser.add_argument("--run_mode", type=str, default="test", help="test or validation, default is test.")
parser.add_argument("--visual_image", type=str, default="false", help="Visulize the ground truth and predicted image") parser.add_argument("--visual_image", type=str, default="false", help="Visulize the ground truth and predicted image")
parser.add_argument("--enable_eval", type=str, default="true", help="Wether evaluate accuracy after prediction") parser.add_argument("--enable_eval", type=str, default="true", help="Whether evaluate accuracy after prediction")
parser.add_argument("--save_result_dir", type=str, default="", help="The path to save the predict results") parser.add_argument("--save_result_dir", type=str, default="", help="The path to save the predict results")
args_opt = parser.parse_args() args_opt = parser.parse_args()

View File

@ -15,7 +15,7 @@
# ============================================================================ # ============================================================================
echo "==============================================================================================================" echo "=============================================================================================================="
echo "Please run the scipt as: " echo "Please run the script as: "
echo "bash convert_dataset_to_mindrecord.sh /path/coco_dataset_dir /path/mindrecord_dataset_dir" echo "bash convert_dataset_to_mindrecord.sh /path/coco_dataset_dir /path/mindrecord_dataset_dir"
echo "==============================================================================================================" echo "=============================================================================================================="
@ -28,4 +28,4 @@ PROJECT_DIR=$(cd "$(dirname "$0")" || exit; pwd)
python ${PROJECT_DIR}/../src/dataset.py \ python ${PROJECT_DIR}/../src/dataset.py \
--coco_data_dir=$COCO_DIR \ --coco_data_dir=$COCO_DIR \
--mindrecord_dir=$MINDRECORD_DIR \ --mindrecord_dir=$MINDRECORD_DIR \
--mindrecord_prefix="coco_hp.train.mind" > create_dataset.log 2>&1 & --mindrecord_prefix="coco_hp.train.mind" > create_dataset.log 2>&1 &

View File

@ -15,7 +15,7 @@
# ============================================================================ # ============================================================================
echo "==============================================================================================================" echo "=============================================================================================================="
echo "Please run the scipt as: " echo "Please run the script as: "
echo "bash run_standalone_eval_ascend.sh DEVICE_ID RUN_MODE DATA_DIR LOAD_CHECKPOINT_PATH" echo "bash run_standalone_eval_ascend.sh DEVICE_ID RUN_MODE DATA_DIR LOAD_CHECKPOINT_PATH"
echo "for example of validation: bash run_standalone_eval_ascend.sh 0 val /path/coco_dataset /path/load_ckpt" echo "for example of validation: bash run_standalone_eval_ascend.sh 0 val /path/coco_dataset /path/load_ckpt"
echo "for example of test: bash run_standalone_eval_ascend.sh 0 test /path/coco_dataset /path/load_ckpt" echo "for example of test: bash run_standalone_eval_ascend.sh 0 test /path/coco_dataset /path/load_ckpt"

View File

@ -15,7 +15,7 @@
# ============================================================================ # ============================================================================
echo "==============================================================================================================" echo "=============================================================================================================="
echo "Please run the scipt as: " echo "Please run the script as: "
echo "bash run_standalone_eval_cpu.sh RUN_MODE DATA_DIR LOAD_CHECKPOINT_PATH" echo "bash run_standalone_eval_cpu.sh RUN_MODE DATA_DIR LOAD_CHECKPOINT_PATH"
echo "for example of validation: bash run_standalone_eval_cpu.sh val /path/coco_dataset /path/load_ckpt" echo "for example of validation: bash run_standalone_eval_cpu.sh val /path/coco_dataset /path/load_ckpt"
echo "for example of test: bash run_standalone_eval_cpu.sh test /path/coco_dataset /path/load_ckpt" echo "for example of test: bash run_standalone_eval_cpu.sh test /path/coco_dataset /path/load_ckpt"

View File

@ -15,7 +15,7 @@
# ============================================================================ # ============================================================================
echo "==============================================================================================================" echo "=============================================================================================================="
echo "Please run the scipt as: " echo "Please run the script as: "
echo "bash run_standalone_train_ascend.sh DEVICE_ID MINDRECORD_DIR LOAD_CHECKPOINT_PATH" echo "bash run_standalone_train_ascend.sh DEVICE_ID MINDRECORD_DIR LOAD_CHECKPOINT_PATH"
echo "for example: bash run_standalone_train_ascend.sh 0 /path/mindrecord_dataset /path/load_ckpt" echo "for example: bash run_standalone_train_ascend.sh 0 /path/mindrecord_dataset /path/load_ckpt"
echo "if no ckpt, just run: bash run_standalone_train_ascend.sh 0 /path/mindrecord_dataset" echo "if no ckpt, just run: bash run_standalone_train_ascend.sh 0 /path/mindrecord_dataset"
@ -52,4 +52,4 @@ python ${PROJECT_DIR}/../train.py \
--mindrecord_dir=$MINDRECORD_DIR \ --mindrecord_dir=$MINDRECORD_DIR \
--mindrecord_prefix="coco_hp.train.mind" \ --mindrecord_prefix="coco_hp.train.mind" \
--visual_image=false \ --visual_image=false \
--save_result_dir="" > training_log.txt 2>&1 & --save_result_dir="" > training_log.txt 2>&1 &

View File

@ -15,7 +15,7 @@
# ============================================================================ # ============================================================================
echo "==============================================================================================================" echo "=============================================================================================================="
echo "Please run the scipt as: " echo "Please run the script as: "
echo "bash run_standalone_train_cpu.sh MINDRECORD_DIR LOAD_CHECKPOINT_PATH" echo "bash run_standalone_train_cpu.sh MINDRECORD_DIR LOAD_CHECKPOINT_PATH"
echo "for example: bash run_standalone_train_cpu.sh /path/mindrecord_dataset /path/load_ckpt" echo "for example: bash run_standalone_train_cpu.sh /path/mindrecord_dataset /path/load_ckpt"
echo "if no ckpt, just run: bash run_standalone_train_cpu.sh /path/mindrecord_dataset" echo "if no ckpt, just run: bash run_standalone_train_cpu.sh /path/mindrecord_dataset"
@ -47,4 +47,4 @@ python ${PROJECT_DIR}/../train.py \
--mindrecord_dir=$MINDRECORD_DIR \ --mindrecord_dir=$MINDRECORD_DIR \
--mindrecord_prefix="coco_hp.train.mind" \ --mindrecord_prefix="coco_hp.train.mind" \
--visual_image=false \ --visual_image=false \
--save_result_dir="" > training_log.txt 2>&1 & --save_result_dir="" > training_log.txt 2>&1 &

View File

@ -276,7 +276,7 @@ class DLAUp(nn.Cell):
Upsampling of DLA network. Upsampling of DLA network.
Args: Args:
startp(int): The begining stage startup upsampling startp(int): The beginning stage startup upsampling
channels(list int): The channels of each stage after upsampling channels(list int): The channels of each stage after upsampling
last_level(int): The ending stage of the final upsampling last_level(int): The ending stage of the final upsampling

View File

@ -32,7 +32,6 @@ dataset_config = edict({
'aug_rot': 0.0, 'aug_rot': 0.0,
'rotate': 0, 'rotate': 0,
'flip_prop': 0.5, 'flip_prop': 0.5,
'color_aug': False,
'mean': np.array([0.40789654, 0.44719302, 0.47026115], dtype=np.float32), 'mean': np.array([0.40789654, 0.44719302, 0.47026115], dtype=np.float32),
'std': np.array([0.28863828, 0.27408164, 0.27809835], dtype=np.float32), 'std': np.array([0.28863828, 0.27408164, 0.27809835], dtype=np.float32),
'flip_idx': [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12], [13, 14], [15, 16]], 'flip_idx': [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12], [13, 14], [15, 16]],

View File

@ -26,7 +26,7 @@ import pycocotools.coco as coco
import mindspore.dataset as ds import mindspore.dataset as ds
from mindspore import log as logger from mindspore import log as logger
from mindspore.mindrecord import FileWriter from mindspore.mindrecord import FileWriter
from src.image import color_aug, get_affine_transform, affine_transform from src.image import get_affine_transform, affine_transform
from src.image import gaussian_radius, draw_umich_gaussian, draw_msra_gaussian, draw_dense_reg from src.image import gaussian_radius, draw_umich_gaussian, draw_msra_gaussian, draw_dense_reg
from src.visual import visual_image from src.visual import visual_image
@ -37,7 +37,7 @@ cv2.setNumThreads(0)
class COCOHP(ds.Dataset): class COCOHP(ds.Dataset):
""" """
Encapsulation class of COCO person keypoints datast. Encapsulation class of COCO person keypoints datast.
Initilize and preprocess of image for training and testing. Initialize and preprocess of image for training and testing.
Args: Args:
data_dir(str): Path of coco dataset. data_dir(str): Path of coco dataset.
@ -67,7 +67,7 @@ class COCOHP(ds.Dataset):
os.makedirs(self.save_path) os.makedirs(self.save_path)
def init(self, data_dir, keep_res=False): def init(self, data_dir, keep_res=False):
"""initailize additional info""" """initialize additional info"""
logger.info('Initializing coco 2017 {} data.'.format(self.run_mode)) logger.info('Initializing coco 2017 {} data.'.format(self.run_mode))
if not os.path.isdir(data_dir): if not os.path.isdir(data_dir):
raise RuntimeError("Invalid dataset path") raise RuntimeError("Invalid dataset path")
@ -236,9 +236,8 @@ class COCOHP(ds.Dataset):
return eval_image, meta return eval_image, meta
def preprocess_fn(self, img, num_objects, keypoints, bboxes, category_id): def get_aug_param(self, img):
"""image pre-process and augmentation""" """get data augmentation parameters"""
num_objs = min(num_objects, self.data_opt.max_objs)
img = cv2.imdecode(img, cv2.IMREAD_COLOR) img = cv2.imdecode(img, cv2.IMREAD_COLOR)
width = img.shape[1] width = img.shape[1]
c = np.array([img.shape[1] / 2., img.shape[0] / 2.], dtype=np.float32) c = np.array([img.shape[1] / 2., img.shape[0] / 2.], dtype=np.float32)
@ -266,21 +265,22 @@ class COCOHP(ds.Dataset):
flipped = True flipped = True
img = img[:, ::-1, :] img = img[:, ::-1, :]
c[0] = width - c[0] - 1 c[0] = width - c[0] - 1
return img, width, c, s, rot, flipped
def preprocess_fn(self, img, num_objects, keypoints, bboxes, category_id):
"""image pre-process and augmentation"""
num_objs = min(num_objects, self.data_opt.max_objs)
img, width, c, s, rot, flipped = self.get_aug_param(img)
trans_input = get_affine_transform(c, s, rot, self.data_opt.input_res) trans_input = get_affine_transform(c, s, rot, self.data_opt.input_res)
inp = cv2.warpAffine(img, trans_input, (self.data_opt.input_res[0], self.data_opt.input_res[1]), inp = cv2.warpAffine(img, trans_input, (self.data_opt.input_res[0], self.data_opt.input_res[1]),
flags=cv2.INTER_LINEAR) flags=cv2.INTER_LINEAR)
if self.run_mode == "train" and self.data_opt.color_aug:
color_aug(self._data_rng, inp / 255., self.data_opt.eig_val, self.data_opt.eig_vec)
inp *= 255.
# caution: image normalization and transpose to nchw will both be done on device # caution: image normalization and transpose to nchw will both be done on device
# inp = (inp.astype(np.float32) / 255. - self.data_opt.mean) / self.data_opt.std # inp = (inp.astype(np.float32) / 255. - self.data_opt.mean) / self.data_opt.std
# inp = inp.transpose(2, 0, 1) # inp = inp.transpose(2, 0, 1)
if self.data_opt.output_res[0] != self.data_opt.output_res[1]: assert self.data_opt.output_res[0] == self.data_opt.output_res[1]
raise ValueError("Only square image was supported to used as output for convinient")
output_res = self.data_opt.output_res[0] output_res = self.data_opt.output_res[0]
num_joints = self.data_opt.num_joints num_joints = self.data_opt.num_joints
max_objs = self.data_opt.max_objs max_objs = self.data_opt.max_objs
@ -314,22 +314,20 @@ class COCOHP(ds.Dataset):
for e in self.data_opt.flip_idx: for e in self.data_opt.flip_idx:
pts[e[0]], pts[e[1]] = pts[e[1]].copy(), pts[e[0]].copy() pts[e[0]], pts[e[1]] = pts[e[1]].copy(), pts[e[0]].copy()
lt = [bbox[0], bbox[3]] lt, rb = [bbox[0], bbox[3]], [bbox[2], bbox[1]]
rb = [bbox[2], bbox[1]]
bbox[:2] = affine_transform(bbox[:2], trans_output_rot) bbox[:2] = affine_transform(bbox[:2], trans_output_rot)
bbox[2:] = affine_transform(bbox[2:], trans_output_rot) bbox[2:] = affine_transform(bbox[2:], trans_output_rot)
if rot != 0: if rot != 0:
lt = affine_transform(lt, trans_output_rot) lt = affine_transform(lt, trans_output_rot)
rb = affine_transform(rb, trans_output_rot) rb = affine_transform(rb, trans_output_rot)
bbox[0] = min(lt[0], rb[0], bbox[0], bbox[2]) for i in range(2):
bbox[2] = max(lt[0], rb[0], bbox[0], bbox[2]) bbox[i] = min(lt[i], rb[i], bbox[i], bbox[i+2])
bbox[1] = min(lt[1], rb[1], bbox[1], bbox[3]) bbox[i+2] = max(lt[i], rb[i], bbox[i], bbox[i+2])
bbox[3] = max(lt[1], rb[1], bbox[1], bbox[3])
bbox = np.clip(bbox, 0, output_res - 1) bbox = np.clip(bbox, 0, output_res - 1)
h, w = bbox[3] - bbox[1], bbox[2] - bbox[0] h, w = bbox[3] - bbox[1], bbox[2] - bbox[0]
if h <= 0 or w <= 0: if h <= 0 or w <= 0:
continue continue
radius = gaussian_radius((math.ceil(h), math.ceil(w))) hp_radius = radius = gaussian_radius((math.ceil(h), math.ceil(w)))
ct = np.array([(bbox[0] + bbox[2]) / 2, (bbox[1] + bbox[3]) / 2], dtype=np.float32) ct = np.array([(bbox[0] + bbox[2]) / 2, (bbox[1] + bbox[3]) / 2], dtype=np.float32)
ct_int = ct.astype(np.int32) ct_int = ct.astype(np.int32)
wh[k] = 1. * w, 1. * h wh[k] = 1. * w, 1. * h
@ -341,7 +339,6 @@ class COCOHP(ds.Dataset):
hm[cls_id, ct_int[1], ct_int[0]] = 0.9999 hm[cls_id, ct_int[1], ct_int[0]] = 0.9999
reg_mask[k] = 0 reg_mask[k] = 0
hp_radius = radius
for j in range(num_joints): for j in range(num_joints):
if pts[j, 2] > 0: if pts[j, 2] > 0:
pts[j, :2] = affine_transform(pts[j, :2], trans_output_rot) pts[j, :2] = affine_transform(pts[j, :2], trans_output_rot)

View File

@ -163,7 +163,7 @@ class DeformConv2d(nn.Cell):
stride (int): The distance of kernel moving. Default: 1. stride (int): The distance of kernel moving. Default: 1.
padding (int): Implicit paddings size on both sides of the input. Default: 1. padding (int): Implicit paddings size on both sides of the input. Default: 1.
has_bias (bool): Specifies whether the layer uses a bias vector. Default: False. has_bias (bool): Specifies whether the layer uses a bias vector. Default: False.
modulation (bool): If True, modulated defomable convolution (Deformable ConvNets v2). Defaut: True. modulation (bool): If True, modulated defomable convolution (Deformable ConvNets v2). Default: True.
Returns: Returns:
Tensor, detection of images(bboxes, score, keypoints and category id of each objects) Tensor, detection of images(bboxes, score, keypoints and category id of each objects)
""" """

View File

@ -62,7 +62,7 @@ class NMS(nn.Cell):
class GatherTopK(nn.Cell): class GatherTopK(nn.Cell):
""" """
Gather topk features through all channeles Gather topk features through all channels
Args: None Args: None
@ -107,7 +107,7 @@ class GatherTopKChannel(nn.Cell):
Args: None Args: None
Returns: Returns:
Tuple of Tensors, top_k scores, indexes, and the indexes in height and width direcction repectively. Tuple of Tensors, top_k scores, indexes, and the indexes in height and width direcction respectively.
""" """
def __init__(self): def __init__(self):
super(GatherTopKChannel, self).__init__() super(GatherTopKChannel, self).__init__()
@ -281,7 +281,7 @@ class FlipLROff(nn.Cell):
self.concat = ops.Concat(axis=1) self.concat = ops.Concat(axis=1)
def construct(self, kps): def construct(self, kps):
"""flip and gather kps at specfied position""" """flip and gather kps at specified position"""
# kps: 2b, 2J, h, w # kps: 2b, 2J, h, w
kps_o, kps_f = self.half(kps) kps_o, kps_f = self.half(kps)
# b, 2J, h, w # b, 2J, h, w

View File

@ -501,7 +501,7 @@ class LossCallBack(Callback):
def step_begin(self, run_context): def step_begin(self, run_context):
""" """
Get begining time of each step Get beginning time of each step
""" """
self._begin_time = time.time() self._begin_time = time.time()
@ -575,7 +575,7 @@ class CenterNetMultiEpochsDecayLR(LearningRateSchedule):
Args: Args:
learning_rate(float): Initial learning rate. learning_rate(float): Initial learning rate.
warmup_steps(int): Warmup steps. warmup_steps(int): Warmup steps.
multi_steps(list int): The steps coresponding to decay learning rate. multi_steps(list int): The steps corresponding to decay learning rate.
steps_per_epoch(int): How many steps for each epoch. steps_per_epoch(int): How many steps for each epoch.
factor(int): Learning rate decay factor. Default: 10. factor(int): Learning rate decay factor. Default: 10.
@ -612,7 +612,7 @@ class MultiEpochsDecayLR(LearningRateSchedule):
Args: Args:
learning_rate(float): Initial learning rate. learning_rate(float): Initial learning rate.
multi_steps(list int): The steps coresponding to decay learning rate. multi_steps(list int): The steps corresponding to decay learning rate.
steps_per_epoch(int): How many steps for each epoch. steps_per_epoch(int): How many steps for each epoch.
factor(int): Learning rate decay factor. Default: 10. factor(int): Learning rate decay factor. Default: 10.