Skip to content

Commit

Permalink
experiments_finetune
Browse files Browse the repository at this point in the history
  • Loading branch information
Brilliant-B committed Aug 7, 2023
1 parent 55753c0 commit 23db5d9
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 18 deletions.
2 changes: 1 addition & 1 deletion configs/fpn_neck.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
samples_per_gpu=3,
workers_per_gpu=2,
val=dict(split='ImageSets/SegmentationContext/tiny_val.txt',),
test=dict(split='ImageSets/SegmentationContext/val.txt',),
test=dict(split='ImageSets/SegmentationContext/tiny_val.txt',),
)

checkpoint_config = dict(interval=2000,)
Expand Down
2 changes: 1 addition & 1 deletion configs/linear_neck.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
samples_per_gpu=32,
workers_per_gpu=2,
val=dict(split='ImageSets/SegmentationContext/tiny_val.txt',),
test=dict(split='ImageSets/SegmentationContext/val.txt',),
test=dict(split='ImageSets/SegmentationContext/tiny_val.txt',),
)

checkpoint_config = dict(interval=2000,)
Expand Down
2 changes: 1 addition & 1 deletion configs/sfp_neck.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
samples_per_gpu=3,
workers_per_gpu=2,
val=dict(split='ImageSets/SegmentationContext/tiny_val.txt',),
test=dict(split='ImageSets/SegmentationContext/val.txt',),
test=dict(split='ImageSets/SegmentationContext/tiny_val.txt',),
)

checkpoint_config = dict(interval=2000,)
Expand Down
5 changes: 2 additions & 3 deletions test.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,6 @@ def main():
cfg.data.test.test_mode = True
if args.gpu_id is not None:
cfg.gpu_ids = [args.gpu_id]

# init distributed env first, since logger depends on the dist info.
if args.launcher == 'none':
cfg.gpu_ids = [args.gpu_id]
Expand All @@ -166,10 +165,10 @@ def main():
mmcv.mkdir_or_exist(osp.abspath(args.work_dir))
timestamp = time.strftime('%Y%m%d_%H%M%S', time.localtime())
if args.aug_test:
json_file = osp.join(args.work_dir,
json_file = osp.join(args.work_dir.replace("/hy-tmp/", ""),
f'eval_multi_scale_{timestamp}.json')
else:
json_file = osp.join(args.work_dir,
json_file = osp.join(args.work_dir.replace("/hy-tmp/", ""),
f'eval_single_scale_{timestamp}.json')
elif rank == 0:
work_dir = osp.join('./work_dirs',
Expand Down
9 changes: 4 additions & 5 deletions test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

GPU=0
NAME="eva2_segmenter"
CONFIGS="configs/Hyper_Control.py"
CKPT="workbench/eva2_segmenter/train/finetune_1/iter_14000.pth"
WORK_DIR="workbench/${NAME}/eval/"
SHOW_DIR="workbench/${NAME}/eval/inference/"
CONFIGS="configs/linear_neck.py"
CKPT="/hy-tmp/workbench/eva2_segmenter/train/neck_linear_finetune_0/iter_22000.pth"
WORK_DIR="/hy-tmp/workbench/${NAME}/eval/"
SHOW_DIR="/hy-tmp/workbench/${NAME}/eval/inference/"

python test.py --eval mIoU --gpu-id ${GPU} \
--config ${CONFIGS} \
Expand All @@ -14,4 +14,3 @@ python test.py --eval mIoU --gpu-id ${GPU} \
--show-dir ${SHOW_DIR} \
# --no-validate
# --load-from ${LOAD}

9 changes: 5 additions & 4 deletions train.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,11 +212,12 @@ def main(args, info, verbose=False):

# create work_dir
mmcv.mkdir_or_exist(osp.abspath(cfg.work_dir))
mmcv.mkdir_or_exist(osp.abspath(cfg.work_dir.replace("/hy-tmp/", "")))
# dump config
cfg.dump(osp.join(cfg.work_dir, osp.basename(config)))
cfg.dump(osp.join(cfg.work_dir.replace("/hy-tmp/", ""), osp.basename(config)))
# init the logger before other steps
timestamp = time.strftime('%Y%m%d_%H%M%S', time.localtime())
log_file = osp.join(cfg.work_dir, f'{timestamp}.log')
log_file = osp.join(cfg.work_dir.replace("/hy-tmp/", ""), f'{timestamp}.log')
logger = get_root_logger(log_file=log_file, log_level=cfg.log_level)

# init the meta dict to record some important information such as
Expand Down Expand Up @@ -280,10 +281,10 @@ def main(args, info, verbose=False):

if __name__ == '__main__':
args = parse_args()
neck_choices = ["linear", "fpn", "sfp"][:1]
neck_choices = ["linear", "fpn", "sfp"]
for n in neck_choices:
hyper_info = {
"finetune_code": 0,
"finetune_code": 1,
"config_neck": n,
}
main(args, hyper_info)
5 changes: 2 additions & 3 deletions train.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@

GPU=0
NAME="eva2_segmenter"
WORK_DIR="workbench/${NAME}/train/"
RESUME="workbench/${NAME}/train/finetune_1/iter_14000.pth"
WORK_DIR="/hy-tmp/workbench/${NAME}/train/"
RESUME="/hy-tmp/neck_linear_finetune_0/iter_6000.pth"
LOAD=""

python train.py --seed 0 --deterministic --gpu-ids ${GPU} \
--work-dir ${WORK_DIR} \
# --resume-from ${RESUME} \
# --no-validate
# --load-from ${LOAD}

0 comments on commit 23db5d9

Please sign in to comment.