示例#1
0
def testdata_post_sver(
    defaultdb='PZ_MTEST',
    qaid_list=None,
    daid_list=None,
    codename='vsmany',
    cfgdict=None,
):
    """
        >>> from wbia.algo.hots._pipeline_helpers import *  # NOQA
    """
    # TODO: testdata_pre('end')
    # from wbia.algo import Config
    if cfgdict is None:
        cfgdict = dict(codename=codename)
    import wbia

    p = 'default' + ut.get_cfg_lbl(cfgdict)
    qreq_ = wbia.testdata_qreq_(defaultdb=defaultdb,
                                default_qaids=qaid_list,
                                default_daids=daid_list,
                                p=p)
    ibs = qreq_.ibs
    locals_ = testrun_pipeline_upto(qreq_, 'end')
    cm_list = locals_['cm_list_SVER']
    # nnfilts_list   = locals_['nnfilts_list']
    return ibs, qreq_, cm_list
示例#2
0
def testdata_pre_baselinefilter(defaultdb='testdb1', qaid_list=None, daid_list=None, codename='vsmany'):
    cfgdict = dict(codename=codename)
    import ibeis
    p = 'default' + ut.get_cfg_lbl(cfgdict)
    qreq_ = ibeis.testdata_qreq_(defaultdb=defaultdb, default_qaids=qaid_list, default_daids=daid_list, p=p)
    locals_ = testrun_pipeline_upto(qreq_, 'baseline_neighbor_filter')
    nns_list, impossible_daids_list = ut.dict_take(locals_, ['nns_list', 'impossible_daids_list'])
    return qreq_, nns_list, impossible_daids_list
示例#3
0
def get_varied_acfg_labels(acfg_list, mainkey='_cfgname', checkname=False):
    """
        >>> from ibeis.expt.annotation_configs import *  # NOQA

    """
    #print(ut.list_str(varied_acfg_list, nl=2))
    for acfg in acfg_list:
        assert acfg['qcfg'][mainkey] == acfg['dcfg'][mainkey], (
            'should be the same for now')
    cfgname_list = [acfg['qcfg'][mainkey] for acfg in acfg_list]
    if checkname and ut.allsame(cfgname_list):
        cfgname_list = [None] * len(cfgname_list)

    # Hack to make common params between q and d appear the same
    _acfg_list = [compress_aidcfg(acfg) for acfg in acfg_list]

    flat_acfg_list = flatten_acfg_list(_acfg_list)
    nonvaried_dict, varied_acfg_list = ut.partition_varied_cfg_list(
        flat_acfg_list)

    SUPER_HACK = True
    if SUPER_HACK:
        # SUPER HACK, recompress remake the varied list after knowing what is varied
        _varied_keys = list(set(ut.flatten(
            [list(ut.flatten(
                [list(x.keys())
                 for x in unflatten_acfgdict(cfg).values()]
            )) for cfg in varied_acfg_list]
        )))
        _acfg_list = [
            compress_aidcfg(acfg, force_noncommon=_varied_keys)
            for acfg in acfg_list]
        flat_acfg_list = flatten_acfg_list(_acfg_list)
        nonvaried_dict, varied_acfg_list = ut.partition_varied_cfg_list(
            flat_acfg_list)

    shortened_cfg_list = [
        #{shorten_to_alias_labels(key): val for key, val in _dict.items()}
        ut.map_dict_keys(shorten_to_alias_labels, _dict)
        for _dict in varied_acfg_list]
    nonlbl_keys = ut.INTERNAL_CFGKEYS
    nonlbl_keys = [prefix +  key for key in nonlbl_keys
                   for prefix in ['', 'q', 'd']]
    # hack for sorting by q/d stuff first

    def get_key_order(cfg):
        keys = [k for k in cfg.keys() if k not in nonlbl_keys]
        sortorder = [2 * k.startswith('q') + 1 * k.startswith('d')
                     for k in keys]
        return ut.sortedby(keys, sortorder)[::-1]

    cfglbl_list = [
        ut.get_cfg_lbl(cfg, name, nonlbl_keys, key_order=get_key_order(cfg))
        for cfg, name in zip(shortened_cfg_list, cfgname_list)]

    if checkname:
        cfglbl_list = [x.lstrip(':') for x in cfglbl_list]
    return cfglbl_list
示例#4
0
 def __init__(self, fname, ext='.cPkl'):
     relevant_params = relevance[fname]
     relevant_cfg = ut.dict_subset(config, relevant_params)
     cfgstr = ut.get_cfg_lbl(relevant_cfg)
     dbdir = ut.truepath('/raid/work/Oxford/')
     super(SMKCacher, self).__init__(fname,
                                     cfgstr,
                                     cache_dir=dbdir,
                                     ext=ext)
示例#5
0
def testdata_pre_sver(defaultdb='PZ_MTEST', qaid_list=None, daid_list=None):
    """
        >>> from ibeis.algo.hots._pipeline_helpers import *  # NOQA
    """
    #from ibeis.algo import Config
    cfgdict = dict()
    import ibeis
    p = 'default' + ut.get_cfg_lbl(cfgdict)
    qreq_ = ibeis.testdata_qreq_(defaultdb=defaultdb, default_qaids=qaid_list, default_daids=daid_list, p=p)
    ibs = qreq_.ibs
    locals_ = testrun_pipeline_upto(qreq_, 'spatial_verification')
    cm_list = locals_['cm_list_FILT']
    #nnfilts_list   = locals_['nnfilts_list']
    return ibs, qreq_, cm_list
示例#6
0
def testdata_post_sver(defaultdb='PZ_MTEST', qaid_list=None, daid_list=None, codename='vsmany', cfgdict=None):
    """
        >>> from ibeis.algo.hots._pipeline_helpers import *  # NOQA
    """
    #from ibeis.algo import Config
    if cfgdict is None:
        cfgdict = dict(codename=codename)
    import ibeis
    p = 'default' + ut.get_cfg_lbl(cfgdict)
    qreq_ = ibeis.testdata_qreq_(defaultdb=defaultdb, default_qaids=qaid_list, default_daids=daid_list, p=p)
    ibs = qreq_.ibs
    locals_ = testrun_pipeline_upto(qreq_, 'vsone_reranking')
    cm_list = locals_['cm_list_SVER']
    #nnfilts_list   = locals_['nnfilts_list']
    return ibs, qreq_, cm_list
示例#7
0
def testdata_pre_vsonerr(defaultdb='PZ_MTEST', qaid_list=[1], daid_list='all'):
    """
        >>> from ibeis.algo.hots._pipeline_helpers import *  # NOQA
    """
    cfgdict = dict(sver_output_weighting=True, codename='vsmany', rrvsone_on=True)
    import ibeis
    p = 'default' + ut.get_cfg_lbl(cfgdict)
    qreq_ = ibeis.testdata_qreq_(defaultdb=defaultdb, default_qaids=qaid_list, default_daids=daid_list, p=p)
    ibs = qreq_.ibs
    qaid_list = qreq_.get_external_qaids().tolist()
    qaid = qaid_list[0]
    #daid_list = qreq_.get_external_daids().tolist()
    if len(ibs.get_annot_groundtruth(qaid)) == 0:
        print('WARNING: qaid=%r has no groundtruth' % (qaid,))
    locals_ = testrun_pipeline_upto(qreq_, 'vsone_reranking')
    cm_list = locals_['cm_list_SVER']
    return ibs, qreq_, cm_list, qaid_list
示例#8
0
def testdata_pre_weight_neighbors(defaultdb='testdb1', qaid_list=[1, 2], daid_list=None, codename='vsmany', cfgdict=None):
    """
    TODO: replace testdata_pre_weight_neighbors with
        >>> qreq_, args = plh.testdata_pre('weight_neighbors', defaultdb='testdb1',
        >>>                                a=['default:qindex=0:1,dindex=0:5,hackerrors=False'],
        >>>                                p=['default:codename=vsmany,bar_l2_on=True,fg_on=False'], verbose=True)
    """
    if cfgdict is None:
        cfgdict = dict(codename=codename)
    import ibeis
    p = 'default' + ut.get_cfg_lbl(cfgdict)
    qreq_ = ibeis.testdata_qreq_(defaultdb=defaultdb, default_qaids=qaid_list, default_daids=daid_list, p=p)
    ibs = qreq_.ibs
    locals_ = testrun_pipeline_upto(qreq_, 'weight_neighbors')
    nns_list, nnvalid0_list = ut.dict_take(locals_, ['nns_list', 'nnvalid0_list'])

    # qreq_, args = testdata_pre('weight_neighbors', defaultdb=defaultdb, p=['default:bar_l2_on=True,fg_on=False'])
    return ibs, qreq_, nns_list, nnvalid0_list
示例#9
0
def get_varied_acfg_labels(acfg_list, mainkey='_cfgname', checkname=False):
    """
        >>> from ibeis.expt.annotation_configs import *  # NOQA

    """
    #print(ut.list_str(varied_acfg_list, nl=2))
    for acfg in acfg_list:
        assert acfg['qcfg'][mainkey] == acfg['dcfg'][mainkey], (
            'should be the same for now')
    cfgname_list = [acfg['qcfg'][mainkey] for acfg in acfg_list]
    if checkname and ut.allsame(cfgname_list):
        cfgname_list = [None] * len(cfgname_list)

    # Hack to make common params between q and d appear the same
    _acfg_list = [compress_aidcfg(acfg) for acfg in acfg_list]

    flat_acfg_list = flatten_acfg_list(_acfg_list)
    nonvaried_dict, varied_acfg_list = ut.partition_varied_cfg_list(
        flat_acfg_list)

    SUPER_HACK = True
    if SUPER_HACK:
        # SUPER HACK, recompress remake the varied list after knowing what is varied
        _varied_keys = list(
            set(
                ut.flatten([
                    list(
                        ut.flatten([
                            list(x.keys())
                            for x in unflatten_acfgdict(cfg).values()
                        ])) for cfg in varied_acfg_list
                ])))
        _acfg_list = [
            compress_aidcfg(acfg, force_noncommon=_varied_keys)
            for acfg in acfg_list
        ]
        flat_acfg_list = flatten_acfg_list(_acfg_list)
        nonvaried_dict, varied_acfg_list = ut.partition_varied_cfg_list(
            flat_acfg_list)

    shortened_cfg_list = [
        #{shorten_to_alias_labels(key): val for key, val in _dict.items()}
        ut.map_dict_keys(shorten_to_alias_labels, _dict)
        for _dict in varied_acfg_list
    ]
    nonlbl_keys = ut.INTERNAL_CFGKEYS
    nonlbl_keys = [
        prefix + key for key in nonlbl_keys for prefix in ['', 'q', 'd']
    ]

    # hack for sorting by q/d stuff first

    def get_key_order(cfg):
        keys = [k for k in cfg.keys() if k not in nonlbl_keys]
        sortorder = [
            2 * k.startswith('q') + 1 * k.startswith('d') for k in keys
        ]
        return ut.sortedby(keys, sortorder)[::-1]

    cfglbl_list = [
        ut.get_cfg_lbl(cfg, name, nonlbl_keys, key_order=get_key_order(cfg))
        for cfg, name in zip(shortened_cfg_list, cfgname_list)
    ]

    if checkname:
        cfglbl_list = [x.lstrip(':') for x in cfglbl_list]
    return cfglbl_list
示例#10
0
def demo_refresh():
    r"""
    CommandLine:
        python -m ibeis.algo.graph.refresh demo_refresh \
                --num_pccs=40 --size=2 --show

    Example:
        >>> # ENABLE_DOCTEST
        >>> from ibeis.algo.graph.refresh import *  # NOQA
        >>> demo_refresh()
        >>> ut.show_if_requested()
    """
    from ibeis.algo.graph import demo
    demokw = ut.argparse_dict({'num_pccs': 50, 'size': 4})
    refreshkw = ut.argparse_funckw(RefreshCriteria)
    # make an inference object
    infr = demo.demodata_infr(size_std=0, **demokw)
    edges = list(infr.dummy_verif.find_candidate_edges(K=100))
    scores = np.array(infr.dummy_verif.predict_edges(edges))
    sortx = scores.argsort()[::-1]
    edges = ut.take(edges, sortx)
    scores = scores[sortx]
    ys = infr.match_state_df(edges)[POSTV].values
    y_remainsum = ys[::-1].cumsum()[::-1]
    # Do oracle reviews and wait to converge
    refresh = RefreshCriteria(**refreshkw)
    xdata = []
    pprob_any = []
    rfrac_any = []
    for count, (edge, y) in enumerate(zip(edges, ys)):
        refresh.add(y, user_id='user:oracle')
        rfrac_any.append(y_remainsum[count] / y_remainsum[0])
        pprob_any.append(refresh.prob_any_remain())
        xdata.append(count + 1)
        if refresh.check():
            break
    xdata = xdata
    ydatas = ut.odict([
        ('Est. probability any remain', pprob_any),
        ('Fraction remaining', rfrac_any),
    ])

    ut.quit_if_noshow()
    import plottool_ibeis as pt
    pt.qtensure()
    from ibeis.scripts.thesis import TMP_RC
    import matplotlib as mpl
    mpl.rcParams.update(TMP_RC)
    pt.multi_plot(
        xdata, ydatas, xlabel='# manual reviews', rcParams=TMP_RC, marker='',
        ylim=(0, 1), use_legend=False,
    )
    demokw = ut.map_keys({'num_pccs': '#PCC', 'size': 'PCC size'},
                         demokw)
    thresh = refreshkw.pop('thresh')
    refreshkw['span'] = refreshkw.pop('window')
    pt.relative_text((.02, .58 + .0), ut.get_cfg_lbl(demokw, sep=' ')[1:],
                     valign='bottom')
    pt.relative_text((.02, .68 + .0), ut.get_cfg_lbl(refreshkw, sep=' ')[1:],
                     valign='bottom')
    legend = pt.gca().legend()
    legend.get_frame().set_alpha(1.0)
    pt.plt.plot([xdata[0], xdata[-1]], [thresh, thresh], 'g--', label='thresh')