forked from mindspore-Ecosystem/mindspore
!11929 some words are misssplelled in centernet script
From: @caojian05 Reviewed-by: @wuxuejian,@oacjiewen,@liangchenghui Signed-off-by: @liangchenghui
This commit is contained in:
commit
fa0e9a2c7b
|
@ -300,7 +300,6 @@ Parameters for dataset (Training/Evaluation):
|
|||
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
|
||||
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
|
||||
std variance of RGB image
|
||||
flip_idx the corresponding point index of keypoints when flip the image
|
||||
|
|
|
@ -45,7 +45,7 @@ parser.add_argument("--data_dir", type=str, default="", help="Dataset directory,
|
|||
"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("--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")
|
||||
|
||||
args_opt = parser.parse_args()
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
# ============================================================================
|
||||
|
||||
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 "=============================================================================================================="
|
||||
|
||||
|
@ -28,4 +28,4 @@ PROJECT_DIR=$(cd "$(dirname "$0")" || exit; pwd)
|
|||
python ${PROJECT_DIR}/../src/dataset.py \
|
||||
--coco_data_dir=$COCO_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 &
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
# ============================================================================
|
||||
|
||||
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 "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"
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
# ============================================================================
|
||||
|
||||
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 "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"
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
# ============================================================================
|
||||
|
||||
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 "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"
|
||||
|
@ -52,4 +52,4 @@ python ${PROJECT_DIR}/../train.py \
|
|||
--mindrecord_dir=$MINDRECORD_DIR \
|
||||
--mindrecord_prefix="coco_hp.train.mind" \
|
||||
--visual_image=false \
|
||||
--save_result_dir="" > training_log.txt 2>&1 &
|
||||
--save_result_dir="" > training_log.txt 2>&1 &
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
# ============================================================================
|
||||
|
||||
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 "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"
|
||||
|
@ -47,4 +47,4 @@ python ${PROJECT_DIR}/../train.py \
|
|||
--mindrecord_dir=$MINDRECORD_DIR \
|
||||
--mindrecord_prefix="coco_hp.train.mind" \
|
||||
--visual_image=false \
|
||||
--save_result_dir="" > training_log.txt 2>&1 &
|
||||
--save_result_dir="" > training_log.txt 2>&1 &
|
||||
|
|
|
@ -276,7 +276,7 @@ class DLAUp(nn.Cell):
|
|||
Upsampling of DLA network.
|
||||
|
||||
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
|
||||
last_level(int): The ending stage of the final upsampling
|
||||
|
||||
|
|
|
@ -32,7 +32,6 @@ dataset_config = edict({
|
|||
'aug_rot': 0.0,
|
||||
'rotate': 0,
|
||||
'flip_prop': 0.5,
|
||||
'color_aug': False,
|
||||
'mean': np.array([0.40789654, 0.44719302, 0.47026115], 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]],
|
||||
|
|
|
@ -26,7 +26,7 @@ import pycocotools.coco as coco
|
|||
import mindspore.dataset as ds
|
||||
from mindspore import log as logger
|
||||
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.visual import visual_image
|
||||
|
||||
|
@ -37,7 +37,7 @@ cv2.setNumThreads(0)
|
|||
class COCOHP(ds.Dataset):
|
||||
"""
|
||||
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:
|
||||
data_dir(str): Path of coco dataset.
|
||||
|
@ -67,7 +67,7 @@ class COCOHP(ds.Dataset):
|
|||
os.makedirs(self.save_path)
|
||||
|
||||
def init(self, data_dir, keep_res=False):
|
||||
"""initailize additional info"""
|
||||
"""initialize additional info"""
|
||||
logger.info('Initializing coco 2017 {} data.'.format(self.run_mode))
|
||||
if not os.path.isdir(data_dir):
|
||||
raise RuntimeError("Invalid dataset path")
|
||||
|
@ -236,9 +236,8 @@ class COCOHP(ds.Dataset):
|
|||
|
||||
return eval_image, meta
|
||||
|
||||
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)
|
||||
def get_aug_param(self, img):
|
||||
"""get data augmentation parameters"""
|
||||
img = cv2.imdecode(img, cv2.IMREAD_COLOR)
|
||||
width = img.shape[1]
|
||||
c = np.array([img.shape[1] / 2., img.shape[0] / 2.], dtype=np.float32)
|
||||
|
@ -266,21 +265,22 @@ class COCOHP(ds.Dataset):
|
|||
flipped = True
|
||||
img = img[:, ::-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)
|
||||
inp = cv2.warpAffine(img, trans_input, (self.data_opt.input_res[0], self.data_opt.input_res[1]),
|
||||
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
|
||||
# inp = (inp.astype(np.float32) / 255. - self.data_opt.mean) / self.data_opt.std
|
||||
# inp = inp.transpose(2, 0, 1)
|
||||
|
||||
if 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")
|
||||
|
||||
assert self.data_opt.output_res[0] == self.data_opt.output_res[1]
|
||||
output_res = self.data_opt.output_res[0]
|
||||
num_joints = self.data_opt.num_joints
|
||||
max_objs = self.data_opt.max_objs
|
||||
|
@ -314,22 +314,20 @@ class COCOHP(ds.Dataset):
|
|||
for e in self.data_opt.flip_idx:
|
||||
pts[e[0]], pts[e[1]] = pts[e[1]].copy(), pts[e[0]].copy()
|
||||
|
||||
lt = [bbox[0], bbox[3]]
|
||||
rb = [bbox[2], bbox[1]]
|
||||
lt, rb = [bbox[0], bbox[3]], [bbox[2], bbox[1]]
|
||||
bbox[:2] = affine_transform(bbox[:2], trans_output_rot)
|
||||
bbox[2:] = affine_transform(bbox[2:], trans_output_rot)
|
||||
if rot != 0:
|
||||
lt = affine_transform(lt, trans_output_rot)
|
||||
rb = affine_transform(rb, trans_output_rot)
|
||||
bbox[0] = min(lt[0], rb[0], bbox[0], bbox[2])
|
||||
bbox[2] = max(lt[0], rb[0], bbox[0], bbox[2])
|
||||
bbox[1] = min(lt[1], rb[1], bbox[1], bbox[3])
|
||||
bbox[3] = max(lt[1], rb[1], bbox[1], bbox[3])
|
||||
for i in range(2):
|
||||
bbox[i] = min(lt[i], rb[i], bbox[i], bbox[i+2])
|
||||
bbox[i+2] = max(lt[i], rb[i], bbox[i], bbox[i+2])
|
||||
bbox = np.clip(bbox, 0, output_res - 1)
|
||||
h, w = bbox[3] - bbox[1], bbox[2] - bbox[0]
|
||||
if h <= 0 or w <= 0:
|
||||
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_int = ct.astype(np.int32)
|
||||
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
|
||||
reg_mask[k] = 0
|
||||
|
||||
hp_radius = radius
|
||||
for j in range(num_joints):
|
||||
if pts[j, 2] > 0:
|
||||
pts[j, :2] = affine_transform(pts[j, :2], trans_output_rot)
|
||||
|
|
|
@ -163,7 +163,7 @@ class DeformConv2d(nn.Cell):
|
|||
stride (int): The distance of kernel moving. 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.
|
||||
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:
|
||||
Tensor, detection of images(bboxes, score, keypoints and category id of each objects)
|
||||
"""
|
||||
|
|
|
@ -62,7 +62,7 @@ class NMS(nn.Cell):
|
|||
|
||||
class GatherTopK(nn.Cell):
|
||||
"""
|
||||
Gather topk features through all channeles
|
||||
Gather topk features through all channels
|
||||
|
||||
Args: None
|
||||
|
||||
|
@ -107,7 +107,7 @@ class GatherTopKChannel(nn.Cell):
|
|||
Args: None
|
||||
|
||||
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):
|
||||
super(GatherTopKChannel, self).__init__()
|
||||
|
@ -281,7 +281,7 @@ class FlipLROff(nn.Cell):
|
|||
self.concat = ops.Concat(axis=1)
|
||||
|
||||
def construct(self, kps):
|
||||
"""flip and gather kps at specfied position"""
|
||||
"""flip and gather kps at specified position"""
|
||||
# kps: 2b, 2J, h, w
|
||||
kps_o, kps_f = self.half(kps)
|
||||
# b, 2J, h, w
|
||||
|
|
|
@ -501,7 +501,7 @@ class LossCallBack(Callback):
|
|||
|
||||
def step_begin(self, run_context):
|
||||
"""
|
||||
Get begining time of each step
|
||||
Get beginning time of each step
|
||||
"""
|
||||
self._begin_time = time.time()
|
||||
|
||||
|
@ -575,7 +575,7 @@ class CenterNetMultiEpochsDecayLR(LearningRateSchedule):
|
|||
Args:
|
||||
learning_rate(float): Initial learning rate.
|
||||
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.
|
||||
factor(int): Learning rate decay factor. Default: 10.
|
||||
|
||||
|
@ -612,7 +612,7 @@ class MultiEpochsDecayLR(LearningRateSchedule):
|
|||
|
||||
Args:
|
||||
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.
|
||||
factor(int): Learning rate decay factor. Default: 10.
|
||||
|
||||
|
|
Loading…
Reference in New Issue