# -*- coding: utf-8 -*-
# TODO: Need test harness to do (something smarter than) gridsearch of these guys
"""
In this file dicts specify all possible combinations of the varied parameters
and lists specify the union of parameters
Rename to pipe_cfgdef
"""
from __future__ import absolute_import, division, print_function
import utool as ut
print, rrr, profile = ut.inject2(__name__, '[cfgbank]')
ALIAS_KEYS = {
'proot': 'pipeline_root',
'RI': 'rotation_invariance',
'AI': 'affine_invariance',
#'AQH': 'augment_queryside_hack',
'QRH': 'augment_queryside_hack',
'SV': 'sv_on',
#'SVxy': 'xy_thresh',
#'SVxy': 'xy_thresh',
}
[docs]def augbase(basedict, updatedict):
newdict = basedict.copy()
newdict.update(updatedict)
return newdict
[docs]def apply_param(cfg, **kwargs):
import copy
cfg = copy.deepcopy(cfg)
for _ in cfg:
_.update(**kwargs)
return cfg
[docs]def apply_k(cfg):
return apply_param(cfg, K=[1, 2, 3, 4, 5, 7, 10])
[docs]def apply_knorm(cfg):
return apply_param(cfg, K=[1, 2, 3, 4, 10], Knorm=[1, 2, 3])
[docs]def apply_CircQRH(cfg):
return apply_param(cfg, augment_queryside_hack=True, affine_invariance=False)
[docs]def apply_Ell(cfg):
return apply_param(cfg, augment_queryside_hack=False, affine_invariance=True)
[docs]def apply_EllQRH(cfg):
return apply_param(cfg, augment_queryside_hack=True, affine_invariance=True)
exclude_vars = vars().keys() # this line is before tests
default = [{}]
baseline = [{
'resize_dim': 'area',
'dim_size': 450,
}]
#baseline = [{}]
ScoreMech = candidacy_namescore = [
{
'score_method': ['nsum'],
'prescore_method': ['nsum'],
},
#{
# 'score_method': ['nsum'],
# 'prescore_method': ['csum'],
#},
{
'score_method': ['csum'],
'prescore_method': ['csum'],
}
]
CircQRH = apply_CircQRH(default)
Ell = apply_Ell(default)
EllQRH = apply_EllQRH(default)
CircQRH_K = apply_k(CircQRH)
CircQRH_Knrom = apply_knorm(CircQRH)
Ell_K = apply_k(Ell)
EllQRH_K = apply_k(EllQRH)
Ell_ScoreMech = apply_Ell(ScoreMech)
CircQRH_ScoreMech = apply_CircQRH(ScoreMech)
[docs]def best(metadata):
"""
Infer the best pipeline config based on the metadata
"""
if metadata is not None:
ibs = metadata.get('ibs', None)
if ibs is not None:
dbname = ibs.get_dbname()
if dbname == 'PZ_Master1':
return apply_param(CircQRH, K=3)
if dbname in ['GZ_Master1', 'GZ_ALL']:
return apply_param(Ell, K=1)
if dbname in ['NNP_MasterGIRM_core', 'GIRM_Master1']:
return apply_param(Ell, K=2)
if dbname in ['WS_Hard']:
return apply_param(default)
return default
featscoremetch = [
{
'lnbnn_on': True,
'fg_on': [True, False],
},
{
'lnbnn_on': False,
'ratio_thresh': 0,
'fg_on': [True, False],
},
{
'lnbnn_on': False,
'dist_on': True,
'fg_on': [True, False],
},
{
'lnbnn_on': False,
'const_on': True,
'fg_on': [True, False],
},
#{
# 'lnbnn_on': False,
# 'lograt_on': True,
#},
]
[docs]def get_candidacy_dbnames():
return [
'PZ_MTEST',
#'NNP_MasterGIRM_core',
'PZ_Master0',
'NNP_Master3',
'GZ_ALL',
'PZ_FlankHack',
#'JAG_Kelly',
#'JAG_Kieryn',
#'LF_Bajo_bonito',
#'LF_OPTIMIZADAS_NI_V_E',
#'LF_WEST_POINT_OPTIMIZADAS',
#'GZ_Master0',
#'GIR_Tanya',
]
# Test all combinations of invariance
invar = candinvar = candidacy_invariance = [
{'affine_invariance': [True], 'rotation_invariance': [False], 'augment_queryside_hack': [False]},
{'affine_invariance': [True], 'rotation_invariance': [True], 'augment_queryside_hack': [False]},
{'affine_invariance': [False], 'rotation_invariance': [True], 'augment_queryside_hack': [False]},
{'affine_invariance': [False], 'rotation_invariance': [False], 'augment_queryside_hack': [False]},
{'affine_invariance': [True], 'rotation_invariance': [False], 'augment_queryside_hack': [True]},
{'affine_invariance': [False], 'rotation_invariance': [False], 'augment_queryside_hack': [True]},
]
# Special value used to specify the current IBEIS configuration
custom = 'custom'
include_vars = vars().keys() # this line is after tests
# List of all valid tests
TEST_NAMES = set(include_vars) - set(exclude_vars)