Exemple #1
0
def generate_incremental_queries(ibs, qaid_list, incinfo=None):
    r"""
    qt entry point. generates query results for the qt harness to process.

    Args:
        ibs (IBEISController):  ibeis controller object
        qaid_list (list):

    CommandLine:
        python -m ibeis.algo.hots.automated_matcher --test-generate_incremental_queries

    Example:
        >>> # DISABLE_DOCTEST
        >>> from ibeis.algo.hots.automated_matcher import *  # NOQA
        >>> ibs, qaid_chunk = testdata_automatch()
        >>> generate_incremental_queries(ibs, qaid_list)
    """
    # Execute each query as a test
    chunksize = 1
    #aids_chunk1_iter = ut.ichunks(aid_list1, chunksize)
    qaid_chunk_iter = ut.ProgChunks(qaid_list, chunksize, lbl='TEST QUERY')

    ibs = ibs
    for count, qaid_chunk in enumerate(qaid_chunk_iter):
        #sys.stdout.write('\n')
        print('\n==== EXECUTING QUERY %d ====' % (count,))
        print('generator_stack_depth = %r' % ut.get_current_stack_depth())
        for item in generate_subquery_steps(ibs, qaid_chunk, incinfo=incinfo):
            yield item
Exemple #2
0
def test_generate_incremental_queries(ibs_gt, ibs, aid_list1, aid1_to_aid2,
                                      num_initial=0, incinfo=None):
    """
    TODO: move this somewhere else
    Testing function

    Adds and queries new annotations one at a time with oracle guidance
    ibs1 is ibs_gt, ibs2 is ibs
    """
    print('begin test interactive iter')
    # Transfer some amount of initial data
    print('Transfer %d initial test annotations' % (num_initial,))
    if num_initial > 0:
        aid_sublist1 = aid_list1[0:num_initial]
        aid_sublist2 = ut.dict_take_list(aid1_to_aid2, aid_sublist1)
        #aid_sublist2 = ah.add_annot_chunk(ibs_gt, ibs, aid_sublist1, aid1_to_aid2)
        # Add names from old databse. add all initial as exemplars
        name_list = ibs_gt.get_annot_names(aid_sublist1)
        ibs.set_annot_names(aid_sublist2, name_list)
        ibs.set_annot_exemplar_flags(aid_sublist2, [True] * len(aid_sublist2))
        aid_list1 = aid_list1[num_initial:]
    # Print info
    WITHINFO = ut.get_argflag('--withinfo')
    if WITHINFO:
        print('+-------')
        print('Printing ibs_gt and ibs info before start')
        print('--------')
        print('\nibs info:')
        print(ibs.get_dbinfo_str())
        print('--------')
        print('\nibs_gt info')
        #print(ibs_gt.get_dbinfo_str())
        print('L________')
    # Setup metadata tuple (in the presence of groundtruth, keeps records of
    # accuracy and give information to the oracle decision maker)
    metatup = Metatup(ibs_gt, aid1_to_aid2)
    assert incinfo is not None
    incinfo['metatup'] = metatup
    incinfo['interactive'] = False
    # Begin incremental iteration
    chunksize = 1
    aids_chunk1_iter = ut.ProgChunks(aid_list1, chunksize, lbl='TEST QUERY')
    for count, aids_chunk1 in enumerate(aids_chunk1_iter):
        with ut.Timer('teststep'):
            #sys.stdout.write('\n')
            print('\n==== EXECUTING TESTSTEP %d ====' % (count,))
            print('generator_stack_depth = %r' % ut.get_current_stack_depth())
            #incinfo['interactive'] = (interact_after is not None and count >= interact_after)
            #---
            # ensure new annot is added (most likely it will have been preadded)
            #qaid_chunk = ah.add_annot_chunk(ibs_gt, ibs, aids_chunk1, aid1_to_aid2)
            #---
            # Assume annot has alredy been added
            # Get mapping
            qaid_chunk = ut.dict_take_list(aid1_to_aid2, aids_chunk1)
            #---
            for item in generate_subquery_steps(ibs, qaid_chunk, incinfo=incinfo):
                yield item
                #(ibs, cm, qreq_, incinfo) = item
                # Yeild results for qt interface to call down into user or
                # oracle code and make a decision
    print('ending interactive iter')
    ah.check_results(ibs_gt, ibs, aid1_to_aid2, aid_list1, incinfo)