예제 #1
0
def models_test(test_status=60, data_type="fabric", only_two_model=None):
    # test different score threshold of one-model method without background
    one_model = BatchTrain(
        cfg_path='../configs/{}/faster_rcnn_r50_fpn_1x_1_model.py'.format(
            data_type),
        data_mode='test',
        train_sleep_time=0,
        test_sleep_time=test_status)

    # test two-model method using one-model method without background as second model
    one_model.two_model_test(data_type)
예제 #2
0
def models_train(test_status=-10, data_type="fabric", const_weights=None):
    # train for one-model method without background
    BatchTrain(
        cfg_path='../configs/{}/faster_rcnn_r50_fpn_1x_1_model.py'.format(
            data_type),
        data_mode='test',
        train_sleep_time=0,
        test_sleep_time=test_status).common_train()
    #
    # train first model of two-model method
    first_model_train(dataset_name=data_type)

    # train constant loss weight of Defect Net method
    # train for finding best constant defect finding network loss weight
    BatchTrain(
        cfg_path='../configs/{}/faster_rcnn_r50_fpn_1x_defectnet_const.py'.
        format(data_type),
        data_mode='test',
        train_sleep_time=0,
        test_sleep_time=test_status).find_best_constant_loss_weight(
            const_weights)

    # train variable loss weight of Defect Net method
    # train for exponent defect finding network loss weight
    BatchTrain(
        cfg_path='../configs/{}/faster_rcnn_r50_fpn_1x_defectnet_exp.py'.
        format(data_type),
        data_mode='test',
        train_sleep_time=0,
        test_sleep_time=test_status).common_train()
    #
    # train for inverse defect finding network loss weight
    BatchTrain(
        cfg_path='../configs/{}/faster_rcnn_r50_fpn_1x_defectnet_inv.py'.
        format(data_type),
        data_mode='test',
        train_sleep_time=0,
        test_sleep_time=test_status).common_train()
    #
    # train for linear defect finding network loss weight
    BatchTrain(
        cfg_path='../configs/{}/faster_rcnn_r50_fpn_1x_defectnet_lin.py'.
        format(data_type),
        data_mode='test',
        train_sleep_time=0,
        test_sleep_time=test_status).common_train()
    pass
예제 #3
0
def models_train(test_status=10, data_type="fabric", const_weights=None):
    # train all models
    root = '../configs/{}/'.format(data_type)
    paths = glob.glob(os.path.join(root, 'baseline_model_*.py'))
    paths.sort()
    for cfg_path in paths:
        m = BatchTrain(cfg_path=cfg_path,
                       data_mode='test',
                       train_sleep_time=0,
                       test_sleep_time=test_status)
        m.common_train()

    # test stacking tricks
    paths = glob.glob(os.path.join(root, '*_mst_*k*.py'))
    paths.sort()
    for cfg_path in paths:
        m = BatchTrain(cfg_path=cfg_path,
                       data_mode='test',
                       train_sleep_time=0,
                       test_sleep_time=test_status)
        params = {
            'test_cfg': {
                'rcnn':
                mmcv.ConfigDict(score_thr=0.05,
                                nms=dict(type='soft_nms', iou_thr=0.5),
                                max_per_img=100)
            },
            'uid': "stacking tricks"
        }
예제 #4
0
def models_test(test_status=60, data_type="fabric", only_two_model=None):
    # test different score threshold of one-model method without background
    one_model = BatchTrain(
        cfg_path='../configs/{}/one_model_cascade_rcnn_r50_fpn_1x.py'.format(
            data_type),
        data_mode='test',
        train_sleep_time=0,
        test_sleep_time=test_status)
    if not only_two_model:
        one_model.score_threshold_test()

    # test two-model method using one-model method without background as second model
    one_model.two_model_test(data_type)

    # test different normal images proportion for inverse defect finding network loss weight
    if not only_two_model:
        BatchTrain(
            cfg_path='../configs/{}/defectnet_inverse_cascade_rcnn_r50_fpn_1x.py'
            .format(data_type),
            data_mode='test',
            train_sleep_time=0,
            test_sleep_time=test_status).normal_proportion_test()
    pass
예제 #5
0
def models_train(test_status=-10, data_type="fabric", const_weights=None):
    # train all models
    root = '../configs/{}/'.format(data_type)
    paths = glob.glob(os.path.join(root, 'defectnet/baseline_model.py'))
    paths.sort()
    for cfg_path in paths:
        m = BatchTrain(cfg_path=cfg_path,
                       data_mode='test',
                       train_sleep_time=0,
                       test_sleep_time=test_status)
        m.common_train()

    # test stacking tricks
    paths = glob.glob(os.path.join(root, 'defectnet/*_mst_*_k*.py'))
    paths.sort()
    for cfg_path in paths:
        m = BatchTrain(cfg_path=cfg_path,
                       data_mode='test',
                       train_sleep_time=0,
                       test_sleep_time=test_status)
        params = {
            'test_cfg': {
                'rcnn':
                mmcv.ConfigDict(score_thr=0.05,
                                nms=dict(type='soft_nms', iou_thr=0.5),
                                max_per_img=100)
            },
            'uid': "stacking tricks"
        }
        m.common_train(**params)

    # test different softnms thresholds
    iou_thrs = np.linspace(0.1, 0.9, 9)
    for iou_thr in iou_thrs:
        softnms_model = BatchTrain(
            cfg_path='../configs/{}/baseline_model.py'.format(data_type),
            data_mode='test',
            train_sleep_time=0,
            test_sleep_time=test_status)
        params = {
            'test_cfg': {
                'rcnn':
                mmcv.ConfigDict(score_thr=0.05,
                                nms=dict(type='soft_nms', iou_thr=iou_thr),
                                max_per_img=100)
            },
            'uid': iou_thr
        }
        softnms_model.common_train(**params)