Skip to content

Commit

Permalink
recovered original training routine
Browse files Browse the repository at this point in the history
  • Loading branch information
josephs-cvar committed Jan 26, 2020
1 parent 1edb121 commit 70804cd
Show file tree
Hide file tree
Showing 4 changed files with 375 additions and 2 deletions.
@@ -0,0 +1,182 @@
---
MXNET_VERSION: "mxnet"
output_path: "./output/fpn/voc_imagenet"
symbol: resnet_v1_101_fpn_dcn_rcnn_oneshot_v3
gpus: '0,1,2,3'
CLASS_AGNOSTIC: true
SCALES:
- 800
- 1280
TEST_SCALES: [[800, 1280]] # single scale testing
#TEST_SCALES: [[480, 800], [576, 900], [688, 1100], [800, 1200], [1200, 1600], [1400, 2000]] # multi-scale testing
default:
frequent: 10
kvstore: device
network:
pretrained: "./data/fpn_dcn_coco"
pretrained_epoch: 0
pretrained_weights_are_priority: true
PIXEL_MEANS:
- 103.06
- 115.90
- 123.15
IMAGE_STRIDE: 32
RCNN_FEAT_STRIDE: 16
RPN_FEAT_STRIDE:
- 4
- 8
- 16
- 32
- 64
FIXED_PARAMS:
- conv1
- bn_conv1
- res2
- bn2
- gamma
- beta
FIXED_PARAMS_SHARED:
- conv1
- bn_conv1
- res2
- bn2
- res3
- bn3
- res4
- bn4
- gamma
- beta
ANCHOR_RATIOS:
- 0.5
- 1
- 2
ANCHOR_SCALES:
- 8
NUM_ANCHORS: 3
EMBEDDING_DIM: 256
REPS_PER_CLASS: 5
SIGMA: 0.5
EMBED_LOSS_ENABLED: True
EMBED_LOSS_MARGIN: 0.5
SOFTMAX_ENABLED: True
REP_L2_NORM: True
EMBED_L2_NORM: True
SEPARABLE_REPS: False
REPS_CLS_LOSS: False
SEPARABLE_REPS_INIT: True
ADDITIONAL_LINEAR_CLS_LOSS: True
dataset:
NUM_CLASSES: 122
balance_classes: true
num_ex_per_class: 200
max_num_extra_classes: 122
dataset: PascalVOC;ImageNet
dataset_path: "/dccstor/leonidka1/data/VOCdevkit;/dccstor/leonidka1/data/imagenet/ILSVRC"
cls_filter_files: './data/Imagenet_LOC/Pascal_inloc_cls2id_map.pkl:./data/Imagenet_LOC/Pascal_inloc_first101_categories.txt'
image_set: 2007_trainval+2012_trainval;train_loc
per_category_epoch_max: 0;10
root_path: "./data"
test_image_set: ;val_partial
proposal: rpn
TRAIN:
UPDATE_REPS_VIA_CLUSTERING: true
NUMEX_FOR_CLUSTERING: 200
REPS_LR_MULT: 1 #0.01
lr: 0.001
warmup_lr: 0.001
warmup_step: 250
warmup: true
lr_step: '4,20,30'
wd: 0.0001
begin_epoch: 0
end_epoch: 22
model_prefix: 'fpn_pascal_imagenet'
# whether resume training
RESUME: false
# whether flip image
FLIP: true
# whether shuffle image
SHUFFLE: true
# whether use OHEM
ENABLE_OHEM: true
# size of images for each device, 2 for rcnn, 1 for rpn and e2e
BATCH_IMAGES: 1
# e2e changes behavior of anchor loader and metric
END2END: true
# group images with similar aspect ratio
ASPECT_GROUPING: true
# R-CNN
# rcnn rois batch size
BATCH_ROIS: -1
BATCH_ROIS_OHEM: 512 #128
# rcnn rois sampling params
FG_FRACTION: 0.25
FG_THRESH: 0.5
BG_THRESH_HI: 0.5
BG_THRESH_LO: 0.0
# rcnn bounding box regression params
BBOX_REGRESSION_THRESH: 0.5
BBOX_WEIGHTS:
- 1.0
- 1.0
- 1.0
- 1.0
# RPN anchor loader
# rpn anchors batch size
RPN_BATCH_SIZE: 256
# rpn anchors sampling params
RPN_FG_FRACTION: 0.5
RPN_POSITIVE_OVERLAP: 0.7
RPN_NEGATIVE_OVERLAP: 0.3
RPN_CLOBBER_POSITIVES: false
# rpn bounding box regression params
RPN_BBOX_WEIGHTS:
- 1.0
- 1.0
- 1.0
- 1.0
RPN_POSITIVE_WEIGHT: -1.0
# used for end2end training
# RPN proposal
CXX_PROPOSAL: false
RPN_NMS_THRESH: 0.7
RPN_PRE_NMS_TOP_N: 12000
RPN_POST_NMS_TOP_N: 2000
RPN_MIN_SIZE: 0
# approximate bounding box regression
BBOX_NORMALIZATION_PRECOMPUTED: true
BBOX_MEANS:
- 0.0
- 0.0
- 0.0
- 0.0
BBOX_STDS:
- 0.1
- 0.1
- 0.2
- 0.2
TEST:
# use rpn to generate proposal
HAS_RPN: true
# size of images for each device
BATCH_IMAGES: 1
# RPN proposal
CXX_PROPOSAL: false
RPN_NMS_THRESH: 0.7
RPN_PRE_NMS_TOP_N: 12000
RPN_POST_NMS_TOP_N: 2000
RPN_MIN_SIZE: 0
# RPN generate proposal
PROPOSAL_NMS_THRESH: 0.7
PROPOSAL_PRE_NMS_TOP_N: 20000
PROPOSAL_POST_NMS_TOP_N: 2000
PROPOSAL_MIN_SIZE: 0
# RCNN nms
NMS: 0.3
USE_SOFTNMS: true
SOFTNMS_THRESH: 0.6
test_epoch: 15
max_per_image: 100
# soft nms
USE_SOFTNMS: true
SOFTNMS_THRESH: 0.6
@@ -0,0 +1,182 @@
---
MXNET_VERSION: "mxnet"
output_path: "./output/fpn/voc_imagenet"
symbol: resnet_v1_101_fpn_dcn_rcnn_oneshot_v3
gpus: '0,1'
CLASS_AGNOSTIC: true
SCALES:
- 800
- 1280
TEST_SCALES: [[800, 1280]] # single scale testing
#TEST_SCALES: [[480, 800], [576, 900], [688, 1100], [800, 1200], [1200, 1600], [1400, 2000]] # multi-scale testing
default:
frequent: 10
kvstore: device
network:
pretrained: "./data/fpn_dcn_coco"
pretrained_epoch: 0
pretrained_weights_are_priority: true
PIXEL_MEANS:
- 103.06
- 115.90
- 123.15
IMAGE_STRIDE: 32
RCNN_FEAT_STRIDE: 16
RPN_FEAT_STRIDE:
- 4
- 8
- 16
- 32
- 64
FIXED_PARAMS:
- conv1
- bn_conv1
- res2
- bn2
- gamma
- beta
FIXED_PARAMS_SHARED:
- conv1
- bn_conv1
- res2
- bn2
- res3
- bn3
- res4
- bn4
- gamma
- beta
ANCHOR_RATIOS:
- 0.5
- 1
- 2
ANCHOR_SCALES:
- 8
NUM_ANCHORS: 3
EMBEDDING_DIM: 256
REPS_PER_CLASS: 5
SIGMA: 0.5
EMBED_LOSS_ENABLED: True
EMBED_LOSS_MARGIN: 0.5
SOFTMAX_ENABLED: True
REP_L2_NORM: True
EMBED_L2_NORM: True
SEPARABLE_REPS: False
REPS_CLS_LOSS: False
SEPARABLE_REPS_INIT: True
ADDITIONAL_LINEAR_CLS_LOSS: True
dataset:
NUM_CLASSES: 122
balance_classes: true
num_ex_per_class: 200
max_num_extra_classes: 122
dataset: PascalVOC;ImageNet
dataset_path: "/dccstor/leonidka1/data/VOCdevkit;/dccstor/leonidka1/data/imagenet/ILSVRC"
cls_filter_files: './data/Imagenet_LOC/Pascal_inloc_cls2id_map.pkl:./data/Imagenet_LOC/Pascal_inloc_first101_categories.txt'
image_set: 2007_trainval+2012_trainval;train_loc
per_category_epoch_max: 0;10
root_path: "./data"
test_image_set: ;val_partial
proposal: rpn
TRAIN:
UPDATE_REPS_VIA_CLUSTERING: true
NUMEX_FOR_CLUSTERING: 200
REPS_LR_MULT: 1 #0.01
lr: 0.001
warmup_lr: 0.001
warmup_step: 250
warmup: true
lr_step: '4,6,20,30'
wd: 0.0001
begin_epoch: 0
end_epoch: 25
model_prefix: 'fpn_pascal_imagenet'
# whether resume training
RESUME: false
# whether flip image
FLIP: true
# whether shuffle image
SHUFFLE: true
# whether use OHEM
ENABLE_OHEM: true
# size of images for each device, 2 for rcnn, 1 for rpn and e2e
BATCH_IMAGES: 1
# e2e changes behavior of anchor loader and metric
END2END: true
# group images with similar aspect ratio
ASPECT_GROUPING: true
# R-CNN
# rcnn rois batch size
BATCH_ROIS: -1
BATCH_ROIS_OHEM: 512 #128
# rcnn rois sampling params
FG_FRACTION: 0.25
FG_THRESH: 0.5
BG_THRESH_HI: 0.5
BG_THRESH_LO: 0.0
# rcnn bounding box regression params
BBOX_REGRESSION_THRESH: 0.5
BBOX_WEIGHTS:
- 1.0
- 1.0
- 1.0
- 1.0
# RPN anchor loader
# rpn anchors batch size
RPN_BATCH_SIZE: 256
# rpn anchors sampling params
RPN_FG_FRACTION: 0.5
RPN_POSITIVE_OVERLAP: 0.7
RPN_NEGATIVE_OVERLAP: 0.3
RPN_CLOBBER_POSITIVES: false
# rpn bounding box regression params
RPN_BBOX_WEIGHTS:
- 1.0
- 1.0
- 1.0
- 1.0
RPN_POSITIVE_WEIGHT: -1.0
# used for end2end training
# RPN proposal
CXX_PROPOSAL: false
RPN_NMS_THRESH: 0.7
RPN_PRE_NMS_TOP_N: 12000
RPN_POST_NMS_TOP_N: 2000
RPN_MIN_SIZE: 0
# approximate bounding box regression
BBOX_NORMALIZATION_PRECOMPUTED: true
BBOX_MEANS:
- 0.0
- 0.0
- 0.0
- 0.0
BBOX_STDS:
- 0.1
- 0.1
- 0.2
- 0.2
TEST:
# use rpn to generate proposal
HAS_RPN: true
# size of images for each device
BATCH_IMAGES: 1
# RPN proposal
CXX_PROPOSAL: false
RPN_NMS_THRESH: 0.7
RPN_PRE_NMS_TOP_N: 12000
RPN_POST_NMS_TOP_N: 2000
RPN_MIN_SIZE: 0
# RPN generate proposal
PROPOSAL_NMS_THRESH: 0.7
PROPOSAL_PRE_NMS_TOP_N: 20000
PROPOSAL_POST_NMS_TOP_N: 2000
PROPOSAL_MIN_SIZE: 0
# RCNN nms
NMS: 0.3
USE_SOFTNMS: true
SOFTNMS_THRESH: 0.6
test_epoch: 15
max_per_image: 100
# soft nms
USE_SOFTNMS: true
SOFTNMS_THRESH: 0.6
11 changes: 10 additions & 1 deletion fpn/few_shot_benchmark.py
Expand Up @@ -493,7 +493,12 @@ def get_workpoint():
model_case = args.test_name
test_model_name = args.test_name


if args.test_name == 'RepMet_inloc_re': # RepMet detector
cfg_fname = root+'/experiments/cfgs/resnet_v1_101_voc0712_trainval_fpn_dcn_oneshot_end2end_ohem_8_orig.yaml'
test_classes_fname =root+'/data/Imagenet_LOC/in_domain_categories.txt' # 214 categories
roidb_fname = root+'/data/Imagenet_LOC/voc_inloc_roidb.pkl'
model_case = args.test_name
test_model_name = args.test_name
if args.test_name == 'Vanilla_inloc': # 'nb19_214_train_hist_11':
cfg_fname = root+'/experiments/cfgs/resnet_v1_101_voc0712_trainval_fpn_dcn_oneshot_end2end_ohem_19_noemb.yaml'
test_classes_fname = root+'/data/Imagenet_LOC/in_domain_categories.txt' # 214 categories
Expand Down Expand Up @@ -694,6 +699,10 @@ def load_a_model(config,model_case=0):
def_model = root+'/data/Imagenet_LOC/fpn_pascal_imagenet'
epoch = 15
arg_params, aux_params = load_param(def_model, epoch, process=True)
if model_case == 'RepMet_inloc_re':
def_model = root+'/output/fpn/voc_imagenet/resnet_v1_101_voc0712_trainval_fpn_dcn_oneshot_end2end_ohem_8_orig/2007_trainval+2012_trainval_train_loc/fpn_pascal_imagenet'
epoch = 22
arg_params, aux_params = load_param(def_model, epoch, process=True)

if model_case == 'Vanilla_inloc':
vanilla_model = root + '/data/Imagenet_LOC/fpn_pascal_imagenet_base' # v
Expand Down
2 changes: 1 addition & 1 deletion notebooks/logo_usecase_routines.py
Expand Up @@ -56,7 +56,7 @@ def disp_dets2(img,dets,save_file_path):
plt.imshow(img_d)
#plt.figure(figsize=(28, 28))
fig.savefig(save_file_path)

def test_on_query_image(fs_serv,test_img_fname,score_thresh=0.1,det_engines=1,figure_factor=2.2,FontScale=2.3):
img = cv2.imread(test_img_fname, cv2.IMREAD_COLOR | cv2.IMREAD_IGNORE_ORIENTATION)

Expand Down

0 comments on commit 70804cd

Please sign in to comment.