def run_until_exemplar_decision_signal(ibs, cm, qreq_, incinfo=None): """ DECISION STEP 3) Either the system or the user decides if the query should be added to the database as an exemplar. """ qaid = cm.qaid exemplar_confidence_thresh = ut.get_sys_maxfloat() exmplr_suggestion = automatch_suggestor.get_system_exemplar_suggestion( ibs, qaid) (autoexemplar_msg, exemplar_decision, exemplar_condience) = exmplr_suggestion print('autoexemplar_msg=') print(autoexemplar_msg) # HACK: Disable asking users a about exemplars need_user_input = False and ( incinfo.get('interactive', False) and exemplar_condience < exemplar_confidence_thresh) if need_user_input: user_dialogs.wait_for_user_exemplar_decision(autoexemplar_msg, exemplar_decision, exemplar_condience) else: # May need to execute callback whereas whatever the interaction was # would issue it otherwise exec_exemplar_decision_and_continue(exemplar_decision, ibs, cm, qreq_, incinfo=incinfo)
def run_until_exemplar_decision_signal(ibs, cm, qreq_, incinfo=None): """ DECISION STEP 3) Either the system or the user decides if the query should be added to the database as an exemplar. """ qaid = cm.qaid exemplar_confidence_thresh = ut.get_sys_maxfloat() exmplr_suggestion = automatch_suggestor.get_system_exemplar_suggestion(ibs, qaid) (autoexemplar_msg, exemplar_decision, exemplar_condience) = exmplr_suggestion print('autoexemplar_msg=') print(autoexemplar_msg) # HACK: Disable asking users a about exemplars need_user_input = False and (incinfo.get('interactive', False) and exemplar_condience < exemplar_confidence_thresh) if need_user_input: user_dialogs.wait_for_user_exemplar_decision( autoexemplar_msg, exemplar_decision, exemplar_condience) else: # May need to execute callback whereas whatever the interaction was # would issue it otherwise exec_exemplar_decision_and_continue(exemplar_decision, ibs, cm, qreq_, incinfo=incinfo)
def get_system_name_suggestion(ibs, choicetup): """ Suggests a decision based on the current choices Args: ibs (IBEISController): qaid (int): query annotation id cm (QueryResult): object of feature correspondences and scores metatup (None): Returns: tuple: (autoname_msg, autoname_func) CommandLine: python -m ibeis.algo.hots.automated_matcher --test-test_incremental_queries:0 python -m ibeis.algo.hots.automated_matcher --test-test_incremental_queries:1 python -m ibeis.algo.hots.automated_matcher --test-get_system_name_suggestion Example: >>> # DISABLE_DOCTEST >>> from ibeis.algo.hots.automatch_suggestor import * # NOQA >>> import ibeis >>> # build test data >>> cm, qreq_ = ibeis.testdata_cm() >>> ibs = qreq_.ibs >>> choicetup = get_qres_name_choices(ibs, cm) >>> (autoname_msg, name, name_confidence) = get_system_name_suggestion(ibs, choicetup) >>> # verify results >>> result = str((autoname_msg, name, name_confidence)) >>> print(result) """ threshold = ut.get_sys_maxfloat() (sorted_nids, sorted_nscore, sorted_rawscore, sorted_aids, sorted_ascores) = choicetup autoname_msg_list = [] if len(sorted_nids) == 0: autoname_msg_list.append('Unable to find any matches') # if we can't find any matches then we must be sure it is a # new name. A false negative here can only be fixed with a merge name_confidence = 1.0 nid, score, rank = None, None, None else: name_confidence = 0 candidate_indexes = np.where(sorted_nscore > threshold)[0] if len(candidate_indexes) == 0: rank = None autoname_msg_list.append('No candidates above threshold') else: sortx = sorted_nscore[candidate_indexes].argsort()[::-1] rank = sortx[0] multiple_candidates = len(candidate_indexes) > 1 if multiple_candidates: autoname_msg_list.append('Multiple candidates above threshold') else: autoname_msg_list.append('Single candidate above threshold') # Get system suggested nid and message if rank is not None: score = sorted_nscore[rank] nid = sorted_nids[rank] rawscore = sorted_rawscore[rank][0] msg_fmtstr = 'suggesting nid=%r, score=%.2f, rank=%r, rawscore=%.2f' msg = msg_fmtstr % (nid, score, rank, rawscore) autoname_msg_list.append(msg) else: nid, score, rawscore = None, None, None autoname_msg_list.append('suggesting new name') autoname_msg = '\n'.join(autoname_msg_list) name = ibs.get_name_texts(nid) if nid is not None else None if name is None: chosen_names = [] else: chosen_names = [name] system_name_suggest_tup = (autoname_msg, chosen_names, name_confidence,) return system_name_suggest_tup
def get_system_name_suggestion(ibs, choicetup): """ Suggests a decision based on the current choices Args: ibs (IBEISController): qaid (int): query annotation id cm (QueryResult): object of feature correspondences and scores metatup (None): Returns: tuple: (autoname_msg, autoname_func) CommandLine: python -m ibeis.algo.hots.automated_matcher --test-test_incremental_queries:0 python -m ibeis.algo.hots.automated_matcher --test-test_incremental_queries:1 python -m ibeis.algo.hots.automated_matcher --test-get_system_name_suggestion Example: >>> # DISABLE_DOCTEST >>> from ibeis.algo.hots.automatch_suggestor import * # NOQA >>> import ibeis >>> # build test data >>> cm, qreq_ = ibeis.testdata_cm() >>> ibs = qreq_.ibs >>> choicetup = get_qres_name_choices(ibs, cm) >>> (autoname_msg, name, name_confidence) = get_system_name_suggestion(ibs, choicetup) >>> # verify results >>> result = str((autoname_msg, name, name_confidence)) >>> print(result) """ threshold = ut.get_sys_maxfloat() (sorted_nids, sorted_nscore, sorted_rawscore, sorted_aids, sorted_ascores) = choicetup autoname_msg_list = [] if len(sorted_nids) == 0: autoname_msg_list.append('Unable to find any matches') # if we can't find any matches then we must be sure it is a # new name. A false negative here can only be fixed with a merge name_confidence = 1.0 nid, score, rank = None, None, None else: name_confidence = 0 candidate_indexes = np.where(sorted_nscore > threshold)[0] if len(candidate_indexes) == 0: rank = None autoname_msg_list.append('No candidates above threshold') else: sortx = sorted_nscore[candidate_indexes].argsort()[::-1] rank = sortx[0] multiple_candidates = len(candidate_indexes) > 1 if multiple_candidates: autoname_msg_list.append('Multiple candidates above threshold') else: autoname_msg_list.append('Single candidate above threshold') # Get system suggested nid and message if rank is not None: score = sorted_nscore[rank] nid = sorted_nids[rank] rawscore = sorted_rawscore[rank][0] msg_fmtstr = 'suggesting nid=%r, score=%.2f, rank=%r, rawscore=%.2f' msg = msg_fmtstr % (nid, score, rank, rawscore) autoname_msg_list.append(msg) else: nid, score, rawscore = None, None, None autoname_msg_list.append('suggesting new name') autoname_msg = '\n'.join(autoname_msg_list) name = ibs.get_name_texts(nid) if nid is not None else None if name is None: chosen_names = [] else: chosen_names = [name] system_name_suggest_tup = ( autoname_msg, chosen_names, name_confidence, ) return system_name_suggest_tup