def show_qres_top(ibs, cm, qreq_=None, **kwargs): """ Wrapper around show_qres. """ N = kwargs.get('N', DEFAULT_NTOP) #name_scoring = kwargs.get('name_scoring', False) #if isinstance(cm, chip_match.ChipMatch): top_aids = cm.get_top_aids(N) #else: # top_aids = cm.get_top_aids(num=N, ibs=ibs, name_scoring=name_scoring) aidstr = ibsfuncs.aidstr(cm.qaid) figtitle = kwargs.get('figtitle', '') if len(figtitle) > 0: figtitle = ' ' + figtitle kwargs['figtitle'] = ('q%s -- TOP %r' % (aidstr, N)) + figtitle return show_qres( ibs, cm, top_aids=top_aids, qreq_=qreq_, # dont use these. use annot mode instead #draw_kpts=False, #draw_ell=False, #all_kpts=False, **kwargs)
def show_qres_top(ibs, cm, qreq_=None, **kwargs): """ Wrapper around show_qres. """ N = kwargs.get('N', DEFAULT_NTOP) #name_scoring = kwargs.get('name_scoring', False) #if isinstance(cm, chip_match.ChipMatch): top_aids = cm.get_top_aids(N) #else: # top_aids = cm.get_top_aids(num=N, ibs=ibs, name_scoring=name_scoring) aidstr = ibsfuncs.aidstr(cm.qaid) figtitle = kwargs.get('figtitle', '') if len(figtitle) > 0: figtitle = ' ' + figtitle kwargs['figtitle'] = ('q%s -- TOP %r' % (aidstr, N)) + figtitle return show_qres(ibs, cm, top_aids=top_aids, qreq_=qreq_, # dont use these. use annot mode instead #draw_kpts=False, #draw_ell=False, #all_kpts=False, **kwargs)
def get_aidstrs(aid_list, **kwargs): if ut.isiterable(aid_list): return [ibsfuncs.aidstr(aid, **kwargs) for aid in aid_list] else: return ibsfuncs.aidstr(aid_list, **kwargs)
def show_qres_analysis(ibs, cm, qreq_=None, **kwargs): """ Wrapper around show_qres. KWARGS: aid_list - show matches against aid_list (default top 3) Args: ibs (IBEISController): ibeis controller object cm (ChipMatch): object of feature correspondences and scores qreq_ (QueryRequest): query request object with hyper-parameters(default = None) Kwargs: N, show_gt, show_query, aid_list, figtitle, viz_name_score, viz_name_score CommandLine: python -m ibeis.viz.viz_qres --exec-show_qres_analysis --show Example: >>> # ENABLE_DOCTEST >>> from ibeis.viz.viz_qres import * # NOQA >>> import ibeis >>> species = ibeis.const.TEST_SPECIES.ZEB_PLAIN >>> ibs = ibeis.opendb(defaultdb='PZ_MTEST') >>> daids = ibs.get_valid_aids(species=species) >>> qaids = ibs.get_valid_aids(species=species) >>> qres_list, qreq_ = ibs.query_chips( >>> [1], [2, 3, 4, 5, 6, 7, 8, 9], >>> cfgdict=dict(), return_request=True) >>> cm = qres_list[0] >>> kwargs = dict(show_query=False, viz_name_score=True, >>> show_timedelta=True, N=3, show_gf=True) >>> show_qres_analysis(ibs, cm, qreq_, **kwargs) >>> ut.show_if_requested() """ if ut.NOT_QUIET: print('[show_qres] cm.show_analysis()') # Parse arguments N = kwargs.get('N', DEFAULT_NTOP) show_gt = kwargs.pop('show_gt', True) show_gf = kwargs.pop('show_gf', False) show_query = kwargs.pop('show_query', True) aid_list = kwargs.pop('aid_list', None) figtitle = kwargs.pop('figtitle', None) #viz_name_score = kwargs.get('viz_name_score', qreq_ is not None) #viz_name_score = kwargs.get('viz_name_score', False) viz_name_score = kwargs.get('viz_name_score', True) failed_to_match = False # Debug printing #print('[analysis] noshow_gt = %r' % noshow_gt) #print('[analysis] show_query = %r' % show_query) #print('[analysis] aid_list = %r' % aid_list) if aid_list is None: # Compare to aid_list instead of using top ranks #print('[analysis] showing top aids') top_aids = cm.get_top_aids(N) if len(top_aids) == 0: failed_to_match = True print('WARNING! No matches found for this query') if figtitle is None: if len(top_aids) == 0: figtitle = 'WARNING: no matches found!' + ibsfuncs.aidstr( cm.qaid) else: topscore = cm.get_annot_scores(top_aids)[0] figtitle = ('q%s -- topscore=%r' % (ibsfuncs.aidstr(cm.qaid), topscore)) else: print('[analysis] showing a given list of aids') top_aids = aid_list if figtitle is None: figtitle = 'comparing to ' + ibsfuncs.aidstr(top_aids) + figtitle # Get any groundtruth if you are showing it showgt_aids = [] if show_gt: # Get the missed groundtruth annotations #if isinstance(cm, chip_match.ChipMatch): assert qreq_ is not None matchable_aids = qreq_.daids #matchable_aids = cm.daid_list #else: # matchable_aids = cm.daids #matchable_aids = ibs.get_recognition_database_aids() #matchable_aids = list(cm.aid2_fm.keys()) _gtaids = ibs.get_annot_groundtruth(cm.qaid, daid_list=matchable_aids) if viz_name_score: # Only look at the groundtruth if a name isnt in the top list _gtnids = ibs.get_annot_name_rowids(_gtaids) top_nids = ibs.get_annot_name_rowids(top_aids) _valids = ~np.in1d(_gtnids, top_nids) _gtaids = ut.compress(_gtaids, _valids) # No need to display highly ranked groundtruth. It will already show up _gtaids = np.setdiff1d(_gtaids, top_aids) # Sort missed grountruth by score _gtscores = cm.get_annot_scores(_gtaids) _gtaids = ut.sortedby(_gtaids, _gtscores, reverse=True) if viz_name_score: if len(_gtaids) > 1: _gtaids = _gtaids[0:1] else: if len(_gtaids) > 3: # Hack to not show too many unmatched groundtruths #_isexmp = ibs.get_annot_exemplar_flags(_gtaids) _gtaids = _gtaids[0:3] showgt_aids = _gtaids if show_gf: # Show only one top-scoring groundfalse example top_nids = ibs.get_annot_name_rowids(top_aids) is_groundfalse = top_nids != ibs.get_annot_name_rowids(cm.qaid) gf_idxs = np.nonzero(is_groundfalse)[0] if len(gf_idxs) > 0: best_gf_idx = gf_idxs[0] isvalid = ~is_groundfalse isvalid[best_gf_idx] = True # Filter so there is only one groundfalse top_aids = top_aids.compress(isvalid) else: # seems like there were no results. Must be bad feature detections # maybe too much spatial verification top_aids = [] if len(showgt_aids) != 0: # Hack to just include gtaids in normal list top_aids = np.append(top_aids, showgt_aids) showgt_aids = [] if viz_name_score: # Make sure that there is only one of each name in the list top_nids = ibs.get_annot_name_rowids(top_aids) top_aids = ut.compress(top_aids, ut.flag_unique_items(top_nids)) return show_qres(ibs, cm, gt_aids=showgt_aids, top_aids=top_aids, figtitle=figtitle, show_query=show_query, qreq_=qreq_, failed_to_match=failed_to_match, **kwargs)
def show_qres_analysis(ibs, cm, qreq_=None, **kwargs): """ Wrapper around show_qres. KWARGS: aid_list - show matches against aid_list (default top 3) Args: ibs (IBEISController): ibeis controller object cm (ChipMatch): object of feature correspondences and scores qreq_ (QueryRequest): query request object with hyper-parameters(default = None) Kwargs: N, show_gt, show_query, aid_list, figtitle, viz_name_score, viz_name_score CommandLine: python -m ibeis.viz.viz_qres --exec-show_qres_analysis --show Example: >>> # ENABLE_DOCTEST >>> from ibeis.viz.viz_qres import * # NOQA >>> import ibeis >>> species = ibeis.const.TEST_SPECIES.ZEB_PLAIN >>> ibs = ibeis.opendb(defaultdb='PZ_MTEST') >>> daids = ibs.get_valid_aids(species=species) >>> qaids = ibs.get_valid_aids(species=species) >>> qres_list, qreq_ = ibs.query_chips( >>> [1], [2, 3, 4, 5, 6, 7, 8, 9], >>> cfgdict=dict(), return_request=True) >>> cm = qres_list[0] >>> kwargs = dict(show_query=False, viz_name_score=True, >>> show_timedelta=True, N=3, show_gf=True) >>> show_qres_analysis(ibs, cm, qreq_, **kwargs) >>> ut.show_if_requested() """ if ut.NOT_QUIET: print('[show_qres] cm.show_analysis()') # Parse arguments N = kwargs.get('N', DEFAULT_NTOP) show_gt = kwargs.pop('show_gt', True) show_gf = kwargs.pop('show_gf', False) show_query = kwargs.pop('show_query', True) aid_list = kwargs.pop('aid_list', None) figtitle = kwargs.pop('figtitle', None) #viz_name_score = kwargs.get('viz_name_score', qreq_ is not None) #viz_name_score = kwargs.get('viz_name_score', False) viz_name_score = kwargs.get('viz_name_score', True) failed_to_match = False # Debug printing #print('[analysis] noshow_gt = %r' % noshow_gt) #print('[analysis] show_query = %r' % show_query) #print('[analysis] aid_list = %r' % aid_list) if aid_list is None: # Compare to aid_list instead of using top ranks #print('[analysis] showing top aids') top_aids = cm.get_top_aids(N) if len(top_aids) == 0: failed_to_match = True print('WARNING! No matches found for this query') if figtitle is None: if len(top_aids) == 0: figtitle = 'WARNING: no matches found!' + ibsfuncs.aidstr(cm.qaid) else: topscore = cm.get_annot_scores(top_aids)[0] figtitle = ('q%s -- topscore=%r' % (ibsfuncs.aidstr(cm.qaid), topscore)) else: print('[analysis] showing a given list of aids') top_aids = aid_list if figtitle is None: figtitle = 'comparing to ' + ibsfuncs.aidstr(top_aids) + figtitle # Get any groundtruth if you are showing it showgt_aids = [] if show_gt: # Get the missed groundtruth annotations #if isinstance(cm, chip_match.ChipMatch): assert qreq_ is not None matchable_aids = qreq_.daids #matchable_aids = cm.daid_list #else: # matchable_aids = cm.daids #matchable_aids = ibs.get_recognition_database_aids() #matchable_aids = list(cm.aid2_fm.keys()) _gtaids = ibs.get_annot_groundtruth(cm.qaid, daid_list=matchable_aids) if viz_name_score: # Only look at the groundtruth if a name isnt in the top list _gtnids = ibs.get_annot_name_rowids(_gtaids) top_nids = ibs.get_annot_name_rowids(top_aids) _valids = ~np.in1d(_gtnids, top_nids) _gtaids = ut.compress(_gtaids, _valids) # No need to display highly ranked groundtruth. It will already show up _gtaids = np.setdiff1d(_gtaids, top_aids) # Sort missed grountruth by score _gtscores = cm.get_annot_scores(_gtaids) _gtaids = ut.sortedby(_gtaids, _gtscores, reverse=True) if viz_name_score: if len(_gtaids) > 1: _gtaids = _gtaids[0:1] else: if len(_gtaids) > 3: # Hack to not show too many unmatched groundtruths #_isexmp = ibs.get_annot_exemplar_flags(_gtaids) _gtaids = _gtaids[0:3] showgt_aids = _gtaids if show_gf: # Show only one top-scoring groundfalse example top_nids = ibs.get_annot_name_rowids(top_aids) is_groundfalse = top_nids != ibs.get_annot_name_rowids(cm.qaid) gf_idxs = np.nonzero(is_groundfalse)[0] if len(gf_idxs) > 0: best_gf_idx = gf_idxs[0] isvalid = ~is_groundfalse isvalid[best_gf_idx] = True # Filter so there is only one groundfalse top_aids = top_aids.compress(isvalid) else: # seems like there were no results. Must be bad feature detections # maybe too much spatial verification top_aids = [] if len(showgt_aids) != 0: # Hack to just include gtaids in normal list top_aids = np.append(top_aids, showgt_aids) showgt_aids = [] if viz_name_score: # Make sure that there is only one of each name in the list top_nids = ibs.get_annot_name_rowids(top_aids) top_aids = ut.compress(top_aids, ut.flag_unique_items(top_nids)) return show_qres(ibs, cm, gt_aids=showgt_aids, top_aids=top_aids, figtitle=figtitle, show_query=show_query, qreq_=qreq_, failed_to_match=failed_to_match, **kwargs)