clould
This commit is contained in:
parent
1e9786e7a8
commit
fa6e4dd4f9
|
@ -162,16 +162,16 @@ def modelarts_process():
|
||||||
print("#" * 200, os.listdir(save_dir_1))
|
print("#" * 200, os.listdir(save_dir_1))
|
||||||
print("#" * 200, os.listdir(os.path.join(config.data_path, config.modelarts_dataset_unzip_name)))
|
print("#" * 200, os.listdir(os.path.join(config.data_path, config.modelarts_dataset_unzip_name)))
|
||||||
|
|
||||||
config.dataset_path = os.path.join(config.data_path, config.modelarts_dataset_unzip_name)
|
config.coco_root = os.path.join(config.data_path, config.modelarts_dataset_unzip_name)
|
||||||
config.coco_root = config.dataset_path
|
config.checkpoint_path = os.path.join(config.output_path, config.ckpt_path)
|
||||||
config.checkpoint_path = os.path.join(config.dataset_path, config.ckpt_path)
|
config.ann_file = os.path.join(config.coco_root, config.ann_file)
|
||||||
config.ann_file = os.path.join(config.dataset_path, config.ann_file)
|
|
||||||
config.mindrecord_dir = os.path.join(config.dataset_path, config.mindrecord_dir)
|
|
||||||
|
|
||||||
context.set_context(mode=context.GRAPH_MODE, device_target="Ascend", device_id=get_device_id())
|
context.set_context(mode=context.GRAPH_MODE, device_target="Ascend", device_id=get_device_id())
|
||||||
|
|
||||||
@moxing_wrapper(pre_process=modelarts_process)
|
@moxing_wrapper(pre_process=modelarts_process)
|
||||||
def eval_():
|
def eval_():
|
||||||
|
config.mindrecord_dir = os.path.join(config.coco_root, config.mindrecord_dir)
|
||||||
|
print('\neval.py config:\n', config)
|
||||||
prefix = "MaskRcnn_eval.mindrecord"
|
prefix = "MaskRcnn_eval.mindrecord"
|
||||||
mindrecord_dir = config.mindrecord_dir
|
mindrecord_dir = config.mindrecord_dir
|
||||||
mindrecord_file = os.path.join(mindrecord_dir, prefix)
|
mindrecord_file = os.path.join(mindrecord_dir, prefix)
|
||||||
|
|
|
@ -77,6 +77,6 @@ do
|
||||||
echo "start training for rank $RANK_ID, device $DEVICE_ID"
|
echo "start training for rank $RANK_ID, device $DEVICE_ID"
|
||||||
env > env.log
|
env > env.log
|
||||||
taskset -c $cmdopt python train.py --do_train=True --device_id=$i --rank_id=$i --run_distribute=True --device_num=$DEVICE_NUM \
|
taskset -c $cmdopt python train.py --do_train=True --device_id=$i --rank_id=$i --run_distribute=True --device_num=$DEVICE_NUM \
|
||||||
--pre_trained=$PATH2 --data_path=$PATH3 &> log &
|
--pre_trained=$PATH2 --coco_root=$PATH3 &> log &
|
||||||
cd ..
|
cd ..
|
||||||
done
|
done
|
||||||
|
|
|
@ -65,5 +65,5 @@ cd ./eval || exit
|
||||||
env > env.log_eval
|
env > env.log_eval
|
||||||
echo "start eval for device $DEVICE_ID"
|
echo "start eval for device $DEVICE_ID"
|
||||||
python ./eval.py --device_id=$DEVICE_ID --ann_file=$PATH1 --checkpoint_path=$PATH2 \
|
python ./eval.py --device_id=$DEVICE_ID --ann_file=$PATH1 --checkpoint_path=$PATH2 \
|
||||||
--data_path=$PATH3 &> log_eval.txt &
|
--coco_root=$PATH3 &> log_eval.txt &
|
||||||
cd ..
|
cd ..
|
||||||
|
|
|
@ -56,5 +56,5 @@ cp -r ../src ./train
|
||||||
cd ./train || exit
|
cd ./train || exit
|
||||||
echo "start training for device $DEVICE_ID"
|
echo "start training for device $DEVICE_ID"
|
||||||
env > env.log
|
env > env.log
|
||||||
python ./train.py --do_train=True --device_id=$DEVICE_ID --pre_trained=$PATH1 --data_path=$PATH2 &> log.txt &
|
python ./train.py --do_train=True --device_id=$DEVICE_ID --pre_trained=$PATH1 --coco_root=$PATH2 &> log.txt &
|
||||||
cd ..
|
cd ..
|
||||||
|
|
|
@ -31,12 +31,6 @@ from .model_utils.config import config
|
||||||
|
|
||||||
config.mask_shape = (28, 28)
|
config.mask_shape = (28, 28)
|
||||||
|
|
||||||
if config.enable_modelarts and config.need_modelarts_dataset_unzip:
|
|
||||||
config.coco_root = os.path.join(config.data_path, config.modelarts_dataset_unzip_name)
|
|
||||||
else:
|
|
||||||
config.coco_root = config.data_path
|
|
||||||
config.mindrecord_dir = os.path.join(config.coco_root, config.mindrecord_dir)
|
|
||||||
|
|
||||||
def bbox_overlaps(bboxes1, bboxes2, mode='iou'):
|
def bbox_overlaps(bboxes1, bboxes2, mode='iou'):
|
||||||
"""Calculate the ious between each bbox of bboxes1 and bboxes2.
|
"""Calculate the ious between each bbox of bboxes1 and bboxes2.
|
||||||
|
|
||||||
|
|
|
@ -98,16 +98,17 @@ def modelarts_pre_process():
|
||||||
print("#" * 200, os.listdir(save_dir_1))
|
print("#" * 200, os.listdir(save_dir_1))
|
||||||
print("#" * 200, os.listdir(os.path.join(config.data_path, config.modelarts_dataset_unzip_name)))
|
print("#" * 200, os.listdir(os.path.join(config.data_path, config.modelarts_dataset_unzip_name)))
|
||||||
|
|
||||||
config.dataset_path = os.path.join(config.data_path, config.modelarts_dataset_unzip_name)
|
config.coco_root = os.path.join(config.data_path, config.modelarts_dataset_unzip_name)
|
||||||
config.pre_trained = os.path.join(config.dataset_path, config.ckpt_path)
|
config.pre_trained = os.path.join(config.coco_root, config.pre_trained)
|
||||||
config.save_checkpoint_path = config.output_path
|
config.save_checkpoint_path = config.output_path
|
||||||
config.mindrecord_dir = os.path.join(config.dataset_path, config.mindrecord_dir)
|
|
||||||
|
|
||||||
|
|
||||||
context.set_context(mode=context.GRAPH_MODE, device_target="Ascend", device_id=get_device_id())
|
context.set_context(mode=context.GRAPH_MODE, device_target="Ascend", device_id=get_device_id())
|
||||||
|
|
||||||
@moxing_wrapper(pre_process=modelarts_pre_process)
|
@moxing_wrapper(pre_process=modelarts_pre_process)
|
||||||
def train_maskrcnn():
|
def train_maskrcnn():
|
||||||
|
config.mindrecord_dir = os.path.join(config.coco_root, config.mindrecord_dir)
|
||||||
|
print('\ntrain.py config:\n', config)
|
||||||
print("Start train for maskrcnn!")
|
print("Start train for maskrcnn!")
|
||||||
if not config.do_eval and config.run_distribute:
|
if not config.do_eval and config.run_distribute:
|
||||||
init()
|
init()
|
||||||
|
@ -130,12 +131,12 @@ def train_maskrcnn():
|
||||||
if not os.path.isdir(mindrecord_dir):
|
if not os.path.isdir(mindrecord_dir):
|
||||||
os.makedirs(mindrecord_dir)
|
os.makedirs(mindrecord_dir)
|
||||||
if config.dataset == "coco":
|
if config.dataset == "coco":
|
||||||
if os.path.isdir(config.data_path):
|
if os.path.isdir(config.coco_root):
|
||||||
print("Create Mindrecord.")
|
print("Create Mindrecord.")
|
||||||
data_to_mindrecord_byte_image("coco", True, prefix)
|
data_to_mindrecord_byte_image("coco", True, prefix)
|
||||||
print("Create Mindrecord Done, at {}".format(mindrecord_dir))
|
print("Create Mindrecord Done, at {}".format(mindrecord_dir))
|
||||||
else:
|
else:
|
||||||
raise Exception("data_path not exits.")
|
raise Exception("coco_root not exits.")
|
||||||
else:
|
else:
|
||||||
if os.path.isdir(config.IMAGE_DIR) and os.path.exists(config.ANNO_PATH):
|
if os.path.isdir(config.IMAGE_DIR) and os.path.exists(config.ANNO_PATH):
|
||||||
print("Create Mindrecord.")
|
print("Create Mindrecord.")
|
||||||
|
|
|
@ -11,7 +11,7 @@ device_target: Ascend
|
||||||
enable_profiling: False
|
enable_profiling: False
|
||||||
|
|
||||||
# ==============================================================================
|
# ==============================================================================
|
||||||
modelarts_dataset_unzip_name: 'ImageNet_Original'
|
modelarts_dataset_unzip_name: 'cifar10'
|
||||||
need_modelarts_dataset_unzip: True
|
need_modelarts_dataset_unzip: True
|
||||||
|
|
||||||
# config for mobilenet, cifar10
|
# config for mobilenet, cifar10
|
||||||
|
@ -34,11 +34,10 @@ lr_max: 0.1
|
||||||
|
|
||||||
# Image classification - train
|
# Image classification - train
|
||||||
dataset: 'cifar10'
|
dataset: 'cifar10'
|
||||||
run_distribute: True
|
run_distribute: False
|
||||||
device_num: 1
|
device_num: 1
|
||||||
dataset_path: "/cache/data"
|
dataset_path: "/cache/data"
|
||||||
device_target: 'Ascend'
|
pre_trained: ''
|
||||||
pre_trained: ""
|
|
||||||
parameter_server: False
|
parameter_server: False
|
||||||
|
|
||||||
# Image classification - eval
|
# Image classification - eval
|
||||||
|
|
|
@ -36,11 +36,10 @@ lr_end: 0.0
|
||||||
|
|
||||||
# Image classification - train
|
# Image classification - train
|
||||||
dataset: 'imagenet2012'
|
dataset: 'imagenet2012'
|
||||||
run_distribute: True
|
run_distribute: False
|
||||||
device_num: 1
|
device_num: 1
|
||||||
dataset_path: "/cache/data"
|
dataset_path: "/cache/data"
|
||||||
device_target: 'Ascend'
|
pre_trained: ''
|
||||||
pre_trained: ""
|
|
||||||
parameter_server: False
|
parameter_server: False
|
||||||
|
|
||||||
# Image classification - eval
|
# Image classification - eval
|
||||||
|
|
|
@ -97,8 +97,8 @@ def modelarts_pre_process():
|
||||||
print("#" * 200, os.listdir(os.path.join(config.data_path, config.modelarts_dataset_unzip_name)))
|
print("#" * 200, os.listdir(os.path.join(config.data_path, config.modelarts_dataset_unzip_name)))
|
||||||
|
|
||||||
config.dataset_path = os.path.join(config.data_path, config.modelarts_dataset_unzip_name)
|
config.dataset_path = os.path.join(config.data_path, config.modelarts_dataset_unzip_name)
|
||||||
config.ckpt_path = config.output_path
|
config.save_checkpoint_path = config.output_path
|
||||||
config.pre_trained = os.path.join(config.dataset_path, config.pre_trained)
|
# config.pre_trained = os.path.join(config.dataset_path, config.pre_trained)
|
||||||
|
|
||||||
|
|
||||||
@moxing_wrapper(pre_process=modelarts_pre_process)
|
@moxing_wrapper(pre_process=modelarts_pre_process)
|
||||||
|
|
|
@ -19,7 +19,6 @@ audio_path: "/cache/data"
|
||||||
npy_path: "/cache/data"
|
npy_path: "/cache/data"
|
||||||
info_path: "/cache/data"
|
info_path: "/cache/data"
|
||||||
info_name: 'annotations_final.csv'
|
info_name: 'annotations_final.csv'
|
||||||
device_target: 'Ascend'
|
|
||||||
device_id: 0
|
device_id: 0
|
||||||
mr_path: "/cache/data"
|
mr_path: "/cache/data"
|
||||||
mr_name: ['train', 'val']
|
mr_name: ['train', 'val']
|
||||||
|
@ -41,7 +40,7 @@ prefix: 'MusicTagger'
|
||||||
model_name: 'MusicTagger-10_543.ckpt'
|
model_name: 'MusicTagger-10_543.ckpt'
|
||||||
|
|
||||||
# export
|
# export
|
||||||
file_name: "/cache/data/musicTagger/fcn-4.air"
|
file_name: "fcn-4"
|
||||||
file_format: "MINDIR"
|
file_format: "MINDIR"
|
||||||
|
|
||||||
# 310 infer
|
# 310 infer
|
||||||
|
|
|
@ -92,5 +92,5 @@ if __name__ == "__main__":
|
||||||
save_checkpoint_steps=config.save_step,
|
save_checkpoint_steps=config.save_step,
|
||||||
keep_checkpoint_max=config.keep_checkpoint_max,
|
keep_checkpoint_max=config.keep_checkpoint_max,
|
||||||
prefix=config.prefix,
|
prefix=config.prefix,
|
||||||
directory=config.checkpoint_path + "_{}".format(get_device_id()))
|
directory=config.checkpoint_path) # + "_{}".format(get_device_id())
|
||||||
print("train success")
|
print("train success")
|
||||||
|
|
Loading…
Reference in New Issue