def oracle_review(sim): queue_params = { 'pos_diameter': None, 'neg_diameter': None, } infr = sim.infr prev = infr.verbose infr.verbose = 0 # rng = np.random.RandomState(0) infr = sim.infr primary_truth = sim.primary_truth review_edges = infr.generate_reviews(**queue_params) max_reviews = 1000 for count, (aid1, aid2) in enumerate(ut.ProgIter(review_edges)): state = primary_truth.loc[(aid1, aid2)].idxmax() tags = [] infr.add_feedback(aid1, aid2, state, tags, apply=True, rectify=False, user_id='oracle', confidence='absolutely_sure') if count > max_reviews: break infr.verbose = prev sim.results['max_reviews'] = max_reviews n_clusters, n_inconsistent = infr.relabel_using_reviews(rectify=False) assert n_inconsistent == 0, 'should not create any inconsistencies' sim.results['n_user_clusters'] = n_clusters # infr.apply_review_inference() curr_decisions = infr.edge_attr_df('decision') curr_truth = primary_truth.loc[curr_decisions.index].idxmax(axis=1) n_user_mistakes = curr_decisions != curr_truth sim.results['n_user_mistakes'] = sum(n_user_mistakes) gt_clusters = ut.group_pairs(infr.gen_node_attrs('orig_name_label')) curr_clusters = ut.group_pairs(infr.gen_node_attrs('name_label')) compare_results = compare_groups(list(gt_clusters.values()), list(curr_clusters.values())) sim.results.update(ut.map_vals(len, compare_results)) common_per_num = ut.group_items(compare_results['common'], map(len, compare_results['common'])) sumafter = 3 greater = [i for i in common_per_num.keys() if i > sumafter] common_per_num['>%s' % sumafter] = ut.flatten( ut.take(common_per_num, greater)) ut.delete_keys(common_per_num, greater) for k, v in common_per_num.items(): sim.results['common@' + str(k)] = len(v) sim.results['n_names_common'] = len(compare_results['common'])
def print_dataset_info(data, labels, key): labelhist = {key: len(val) for key, val in ut.group_items(labels, labels).items()} stats_dict = ut.get_stats(data.ravel()) ut.delete_keys(stats_dict, ['shape', 'nMax', 'nMin']) print('[dataset] Dataset Info: ') print('[dataset] * Data:') print('[dataset] %s_data(shape=%r, dtype=%r)' % (key, data.shape, data.dtype)) print('[dataset] %s_memory(data) = %r' % (key, ut.get_object_size_str(data),)) print('[dataset] %s_stats(data) = %s' % (key, ut.repr2(stats_dict, precision=2),)) print('[dataset] * Labels:') print('[dataset] %s_labels(shape=%r, dtype=%r)' % (key, labels.shape, labels.dtype)) print('[dataset] %s_label histogram = %s' % (key, ut.repr2(labelhist)))
def check_baseline_results(sim): import networkx as nx infr = sim.infr n_names_possible = 0 real_groups = ut.group_pairs(infr.gen_node_attrs('orig_name_label')) possible_clusters = [] for nid, nodes in real_groups.items(): if len(nodes) == 1: possible_clusters.append(nodes) n_names_possible += 1 continue cc_cand_edges = list(ut.nx_edges_between(infr.graph, nodes)) cc = ut.nx_from_node_edge(nodes, cc_cand_edges) mst = nx.minimum_spanning_tree(cc) ccs = list(nx.connected_components(mst)) possible_clusters.extend(ccs) n_names_possible += (len(ccs)) sumafter = 3 best_possible_compare_results = compare_groups( list(real_groups.values()), list(possible_clusters)) possible_per_num = ut.map_vals( len, ut.group_items(best_possible_compare_results['common'], map(len, best_possible_compare_results['common']))) greater = [i for i in possible_per_num.keys() if i > sumafter] possible_per_num['>%s' % sumafter] = sum( ut.take(possible_per_num, greater)) ut.delete_keys(possible_per_num, greater) for k, v in possible_per_num.items(): sim.results['possible@' + str(k)] = v sim.results['possible'] = len(best_possible_compare_results['common']) # Measure the number of real names in the test (per number of annots) real_per_num = ut.dict_hist(map(len, real_groups.values())) greater = [i for i in real_per_num.keys() if i > sumafter] real_per_num['>%s' % sumafter] = sum(ut.take(real_per_num, greater)) ut.delete_keys(real_per_num, greater) for k, v in real_per_num.items(): sim.results['real@' + str(k)] = v sim.results['n_names_possible'] = n_names_possible sim.results['n_names_real'] = len(real_groups) sim.results['real'] = len(real_groups)
def _read_raw_entries(bibman): parser = bparser.BibTexParser() ut.delete_keys(parser.alt_dict, ['url', 'urls']) parser.ignore_nonstandard_types = False text = ut.readfrom(bibman.fpath) # ensure good format flag = 0 for x in re.finditer('^.*}\n[^}\n]', text, flags=re.MULTILINE): lineno = x.string[:x.start()].count('\n') + 1 print('DID YOU FORGET A COMMA ON lineno = {!r}'.format(lineno)) print(x.group()) flag += 1 assert not flag, 'fix formating' database = parser.parse(text) entries = database.entries raw_entries = database.get_entry_dict() raw_entries = ut.order_dict_by(raw_entries, [e['ID'] for e in entries]) bibman.raw_text = text bibman.raw_entries = raw_entries
def compress_aidcfg(acfg, filter_nones=False, filter_empty=False, force_noncommon=[]): r""" Idea is to add a third subconfig named `common` that is the intersection of `qcfg` and `dcfg`. Args: acfg (dict): Returns: dict: acfg CommandLine: #python -m ibeis --tf compress_aidcfg python -m ibeis.expt.annotation_configs --exec-compress_aidcfg --show Example: >>> # DISABLE_DOCTEST >>> from ibeis.expt.annotation_configs import * # NOQA >>> acfg = default >>> acfg = compress_aidcfg(acfg) >>> result = ('acfg = %s' % (ut.repr2(acfg),)) >>> print(default) >>> print(result) """ import copy if 'qcfg' not in acfg or 'dcfg' not in acfg: return acfg acfg = copy.deepcopy(acfg) common_cfg = ut.dict_intersection(acfg['qcfg'], acfg['dcfg']) ut.delete_keys(common_cfg, force_noncommon) ut.delete_keys(acfg['qcfg'], common_cfg.keys()) ut.delete_keys(acfg['dcfg'], common_cfg.keys()) acfg['common'] = common_cfg if filter_nones: acfg['common'] = ut.dict_filter_nones(acfg['common']) acfg['qcfg'] = ut.dict_filter_nones(acfg['qcfg']) acfg['dcfg'] = ut.dict_filter_nones(acfg['dcfg']) if filter_empty: if len(acfg['common']) == 0: del acfg['common'] if len(acfg['qcfg']) == 0: del acfg['qcfg'] if len(acfg['dcfg']) == 0: del acfg['dcfg'] return acfg
def compress_aidcfg(acfg, filter_nones=False, filter_empty=False, force_noncommon=[]): r""" Args: acfg (dict): Returns: dict: acfg CommandLine: #python -m ibeis --tf compress_aidcfg python -m ibeis.expt.annotation_configs --exec-compress_aidcfg --show Example: >>> # DISABLE_DOCTEST >>> from ibeis.expt.annotation_configs import * # NOQA >>> acfg = default >>> acfg = compress_aidcfg(acfg) >>> result = ('acfg = %s' % (ut.dict_str(acfg),)) >>> print(default) >>> print(result) """ import copy if 'qcfg' not in acfg or 'dcfg' not in acfg: return acfg acfg = copy.deepcopy(acfg) common_cfg = ut.dict_intersection(acfg['qcfg'], acfg['dcfg']) ut.delete_keys(common_cfg, force_noncommon) ut.delete_keys(acfg['qcfg'], common_cfg.keys()) ut.delete_keys(acfg['dcfg'], common_cfg.keys()) acfg['common'] = common_cfg if filter_nones: acfg['common'] = ut.dict_filter_nones(acfg['common']) acfg['qcfg'] = ut.dict_filter_nones(acfg['qcfg']) acfg['dcfg'] = ut.dict_filter_nones(acfg['dcfg']) if filter_empty: if len(acfg['common']) == 0: del acfg['common'] if len(acfg['qcfg']) == 0: del acfg['qcfg'] if len(acfg['dcfg']) == 0: del acfg['dcfg'] return acfg
def show_matches2(ibs, aid1, aid2, fm=None, fs=None, fm_norm=None, sel_fm=[], H1=None, H2=None, qreq_=None, **kwargs): """ TODO: DEPRICATE and use special case of show_name_matches Integrate ChipMatch Used in: Found 1 line(s) in '/home/joncrall/code/ibeis_cnn/ibeis_cnn/ingest_ibeis.py': ingest_ibeis.py : 827 | >>> ibeis.viz.viz_matches.show_matches2(ibs, aid1, aid2, fm=None, kpts1=kpts1, kpts2=kpts2) ---------------------- Found 4 line(s) in '/home/joncrall/code/ibeis/ibeis/viz/viz_matches.py': viz_matches.py : 423 |def show_matches2(ibs, aid1, aid2, fm=None, fs=None, fm_norm=None, sel_fm=[], viz_matches.py : 430 | python -m ibeis.viz.viz_matches --exec-show_matches2 --show viz_matches.py : 431 | python -m ibeis --tf ChipMatch.ishow_single_annotmatch show_matches2 --show viz_matches.py : 515 | return show_matches2(ibs, aid1, aid2, fm, fs, qreq_=qreq_, **kwargs) ---------------------- Found 1 line(s) in '/home/joncrall/code/ibeis/ibeis/viz/interact/interact_matches.py': interact_matches.py : 372 | tup = viz.viz_matches.show_matches2(ibs, self.qaid, self.daid, ---------------------- Found 1 line(s) in '/home/joncrall/code/ibeis/ibeis/algo/hots/vsone_pipeline.py': vsone_pipeline.py : 1339 | viz_matches.show_matches2(ibs, qaid, daid, fm=fm, fs=fs, fm_norm=fm_norm, ori=True, ---------------------- Found 2 line(s) in '/home/joncrall/code/ibeis/ibeis/algo/hots/chip_match.py': chip_match.py : 204 | viz_matches.show_matches2(qreq_.ibs, cm.qaid, daid, qreq_=qreq_, chip_match.py : 219 | ibeis.viz.viz_matches.show_matches2 ---------------------- Found 1 line(s) in '/home/joncrall/code/ibeis/ibeis/algo/hots/scoring.py': scoring.py : 562 | viz.viz_matches.show_matches2(qreq_.ibs, qaid, daid, fm, fs, CommandLine: python -m ibeis.viz.viz_matches --exec-show_matches2 --show python -m ibeis --tf ChipMatch.ishow_single_annotmatch show_matches2 --show Example: >>> # DISABLE_DOCTEST >>> from ibeis.algo.hots.chip_match import * # NOQA >>> import ibeis >>> cm, qreq_ = ibeis.testdata_cm(defaultdb='PZ_MTEST', default_qaids=[18]) >>> cm.score_nsum(qreq_) >>> daid = cm.get_top_aids()[0] >>> cm.show_single_annotmatch(qreq_, daid) >>> ut.show_if_requested() """ if qreq_ is None: print('[viz_matches] WARNING: qreq_ is None') kwargs = kwargs.copy() in_image = kwargs.get('in_image', False) draw_fmatches = kwargs.pop('draw_fmatches', True) # Read query and result info (chips, names, ...) rchip1, rchip2, kpts1, kpts2 = _get_annot_pair_info( ibs, aid1, aid2, qreq_, draw_fmatches, **kwargs) ut.delete_keys(kwargs, ['kpts1', 'kpts2']) if fm is None: assert len(kpts1) == len( kpts2), 'keypoints should be in correspondence' import numpy as np fm = np.vstack((np.arange(len(kpts1)), np.arange(len(kpts1)))).T # Build annotation strings / colors lbl1 = 'q' + vh.get_aidstrs(aid1) lbl2 = vh.get_aidstrs(aid2) if in_image: # HACK! lbl1 = None lbl2 = None # Draws the chips and keypoint matches try: ax, xywh1, xywh2 = pt.show_chipmatch2(rchip1, rchip2, kpts1, kpts2, fm, fs=fs, fm_norm=fm_norm, H1=H1, H2=H2, lbl1=lbl1, lbl2=lbl2, sel_fm=sel_fm, **kwargs) except Exception as ex: ut.printex(ex, 'consider qr.remove_corrupted_queries', '[viz_matches]') print('') raise # Moved the code into show_chipmatch #if len(sel_fm) > 0: # # Draw any selected matches # sm_kw = dict(rect=True, colors=pt.BLUE) # pt.plot_fmatch(xywh1, xywh2, kpts1, kpts2, sel_fm, **sm_kw) (x1, y1, w1, h1) = xywh1 (x2, y2, w2, h2) = xywh2 offset1 = (x1, y1) offset2 = (x2, y2) annotate_matches2(ibs, aid1, aid2, fm, fs, xywh2=xywh2, xywh1=xywh1, offset1=offset1, offset2=offset2, **kwargs) return ax, xywh1, xywh2
def main(bib_fpath=None): r""" intro point to fixbib script CommmandLine: fixbib python -m fixtex bib python -m fixtex bib --dryrun python -m fixtex bib --dryrun --debug """ if bib_fpath is None: bib_fpath = 'My Library.bib' # DEBUG = ub.argflag('--debug') # Read in text and ensure ascii format dirty_text = ut.readfrom(bib_fpath) from fixtex.fix_tex import find_used_citations, testdata_fpaths if exists('custom_extra.bib'): extra_parser = bparser.BibTexParser(ignore_nonstandard_types=False) parser = bparser.BibTexParser() ut.delete_keys(parser.alt_dict, ['url', 'urls']) print('Parsing extra bibtex file') extra_text = ut.readfrom('custom_extra.bib') extra_database = extra_parser.parse(extra_text, partial=False) print('Finished parsing extra') extra_dict = extra_database.get_entry_dict() else: extra_dict = None #udata = dirty_text.decode("utf-8") #dirty_text = udata.encode("ascii", "ignore") #dirty_text = udata # parser = bparser.BibTexParser() # bib_database = parser.parse(dirty_text) # d = bib_database.get_entry_dict() print('BIBTEXPARSER LOAD') parser = bparser.BibTexParser(ignore_nonstandard_types=False, common_strings=True) ut.delete_keys(parser.alt_dict, ['url', 'urls']) print('Parsing bibtex file') bib_database = parser.parse(dirty_text, partial=False) print('Finished parsing') bibtex_dict = bib_database.get_entry_dict() old_keys = list(bibtex_dict.keys()) new_keys = [] for key in ub.ProgIter(old_keys, label='fixing keys'): new_key = key new_key = new_key.replace(':', '') new_key = new_key.replace('-', '_') new_key = re.sub('__*', '_', new_key) new_keys.append(new_key) # assert len(ut.find_duplicate_items(new_keys)) == 0, 'new keys created conflict' assert len(ub.find_duplicates(new_keys)) == 0, 'new keys created conflict' for key, new_key in zip(old_keys, new_keys): if key != new_key: entry = bibtex_dict[key] entry['ID'] = new_key bibtex_dict[new_key] = entry del bibtex_dict[key] # The bibtext is now clean. Print it to stdout #print(clean_text) verbose = None if verbose is None: verbose = 1 # Find citations from the tex documents key_list = None if key_list is None: cacher = ub.Cacher('texcite1', enabled=0) data = cacher.tryload() if data is None: fpaths = testdata_fpaths() key_list, inverse = find_used_citations(fpaths, return_inverse=True) # ignore = ['JP', '?', 'hendrick'] # for item in ignore: # try: # key_list.remove(item) # except ValueError: # pass if verbose: print('Found %d citations used in the document' % (len(key_list), )) data = key_list, inverse cacher.save(data) key_list, inverse = data # else: # key_list = None unknown_pubkeys = [] debug_author = ub.argval('--debug-author', default=None) # ./fix_bib.py --debug_author=Kappes if verbose: print('Fixing %d/%d bibtex entries' % (len(key_list), len(bibtex_dict))) # debug = True debug = False if debug_author is not None: debug = False known_keys = list(bibtex_dict.keys()) missing_keys = set(key_list) - set(known_keys) if extra_dict is not None: missing_keys.difference_update(set(extra_dict.keys())) if missing_keys: print('The library is missing keys found in tex files %s' % (ub.repr2(missing_keys), )) # Search for possible typos: candidate_typos = {} sedlines = [] for key in missing_keys: candidates = ut.closet_words(key, known_keys, num=3, subset=True) if len(candidates) > 1: top = candidates[0] if ut.edit_distance(key, top) == 1: # "sed -i -e 's/{}/{}/g' *.tex".format(key, top) import os replpaths = ' '.join( [relpath(p, os.getcwd()) for p in inverse[key]]) sedlines.append("sed -i -e 's/{}/{}/g' {}".format( key, top, replpaths)) candidate_typos[key] = candidates print('Cannot find key = %r' % (key, )) print('Did you mean? %r' % (candidates, )) print('Quick fixes') print('\n'.join(sedlines)) # group by file just = max([0] + list(map(len, missing_keys))) missing_fpaths = [inverse[key] for key in missing_keys] for fpath in sorted(set(ub.flatten(missing_fpaths))): # ut.fix_embed_globals() subkeys = [k for k in missing_keys if fpath in inverse[k]] print('') ut.cprint('--- Missing Keys ---', 'blue') ut.cprint('fpath = %r' % (fpath, ), 'blue') ut.cprint('{} | {}'.format('Missing'.ljust(just), 'Did you mean?'), 'blue') for key in subkeys: print('{} | {}'.format(ut.highlight_text(key.ljust(just), 'red'), ' '.join(candidate_typos[key]))) # for key in list(bibtex_dict.keys()): if extra_dict is not None: # Extra database takes precidence over regular key_list = list(ut.unique(key_list + list(extra_dict.keys()))) for k, v in extra_dict.items(): bibtex_dict[k] = v full = ub.argflag('--full') for key in key_list: try: entry = bibtex_dict[key] except KeyError: continue self = BibTexCleaner(key, entry, full=full) if debug_author is not None: debug = debug_author in entry.get('author', '') if debug: ut.cprint(' --- ENTRY ---', 'yellow') print(ub.repr2(entry, nl=1)) entry = self.fix() # self.clip_abstract() # self.shorten_keys() # self.fix_authors() # self.fix_year() # old_pubval = self.fix_pubkey() # if old_pubval: # unknown_pubkeys.append(old_pubval) # self.fix_arxiv() # self.fix_general() # self.fix_paper_types() if debug: print(ub.repr2(entry, nl=1)) ut.cprint(' --- END ENTRY ---', 'yellow') bibtex_dict[key] = entry unwanted_keys = set(bibtex_dict.keys()) - set(key_list) if verbose: print('Removing unwanted %d entries' % (len(unwanted_keys))) ut.delete_dict_keys(bibtex_dict, unwanted_keys) if 0: d1 = bibtex_dict.copy() full = True for key, entry in d1.items(): self = BibTexCleaner(key, entry, full=full) pub = self.publication() if pub is None: print(self.entry['ENTRYTYPE']) old = self.fix_pubkey() x1 = self._pubval() x2 = self.standard_pubval(full=full) # if x2 is not None and len(x2) > 5: # print(ub.repr2(self.entry)) if x1 != x2: print('x2 = %r' % (x2, )) print('x1 = %r' % (x1, )) print(ub.repr2(self.entry)) # if 'CVPR' in self.entry.get('booktitle', ''): # if 'CVPR' != self.entry.get('booktitle', ''): # break if old: print('old = %r' % (old, )) d1[key] = self.entry if full: d1 = bibtex_dict.copy() import numpy as np import pandas as pd df = pd.DataFrame.from_dict(d1, orient='index') paged_items = df[~pd.isnull(df['pub_accro'])] has_pages = ~pd.isnull(paged_items['pages']) print('have pages {} / {}'.format(has_pages.sum(), len(has_pages))) print(ub.repr2(paged_items[~has_pages]['title'].values.tolist())) entrytypes = dict(list(df.groupby('pub_type'))) if False: # entrytypes['misc'] g = entrytypes['online'] g = g[g.columns[~np.all(pd.isnull(g), axis=0)]] entrytypes['book'] entrytypes['thesis'] g = entrytypes['article'] g = entrytypes['incollection'] g = entrytypes['conference'] def lookup_pub(e): if e == 'article': return 'journal', 'journal' elif e == 'incollection': return 'booksection', 'booktitle' elif e == 'conference': return 'conference', 'booktitle' return None, None for e, g in entrytypes.items(): print('e = %r' % (e, )) g = g[g.columns[~np.all(pd.isnull(g), axis=0)]] if 'pub_full' in g.columns: place_title = g['pub_full'].tolist() print(ub.repr2(ub.dict_hist(place_title))) else: print('Unknown publications') if 'report' in entrytypes: g = entrytypes['report'] missing = g[pd.isnull(g['title'])] if len(missing): print('Missing Title') print(ub.repr2(missing[['title', 'author']].values.tolist())) if 'journal' in entrytypes: g = entrytypes['journal'] g = g[g.columns[~np.all(pd.isnull(g), axis=0)]] missing = g[pd.isnull(g['journal'])] if len(missing): print('Missing Journal') print(ub.repr2(missing[['title', 'author']].values.tolist())) if 'conference' in entrytypes: g = entrytypes['conference'] g = g[g.columns[~np.all(pd.isnull(g), axis=0)]] missing = g[pd.isnull(g['booktitle'])] if len(missing): print('Missing Booktitle') print(ub.repr2(missing[['title', 'author']].values.tolist())) if 'incollection' in entrytypes: g = entrytypes['incollection'] g = g[g.columns[~np.all(pd.isnull(g), axis=0)]] missing = g[pd.isnull(g['booktitle'])] if len(missing): print('Missing Booktitle') print(ub.repr2(missing[['title', 'author']].values.tolist())) if 'thesis' in entrytypes: g = entrytypes['thesis'] g = g[g.columns[~np.all(pd.isnull(g), axis=0)]] missing = g[pd.isnull(g['institution'])] if len(missing): print('Missing Institution') print(ub.repr2(missing[['title', 'author']].values.tolist())) # import utool # utool.embed() # Overwrite BibDatabase structure bib_database._entries_dict = bibtex_dict bib_database.entries = list(bibtex_dict.values()) #conftitle_to_types_set_hist = {key: set(val) for key, val in conftitle_to_types_hist.items()} #print(ub.repr2(conftitle_to_types_set_hist)) print('Unknown conference keys:') print(ub.repr2(sorted(unknown_pubkeys))) print('len(unknown_pubkeys) = %r' % (len(unknown_pubkeys), )) writer = BibTexWriter() writer.contents = ['comments', 'entries'] writer.indent = ' ' writer.order_entries_by = ('type', 'author', 'year') new_bibtex_str = bibtexparser.dumps(bib_database, writer) # Need to check #jegou_aggregating_2012 # Fix the Journal Abreviations # References: # https://www.ieee.org/documents/trans_journal_names.pdf # Write out clean bibfile in ascii format clean_bib_fpath = ub.augpath(bib_fpath.replace(' ', '_'), suffix='_clean') if not ub.argflag('--dryrun'): ut.writeto(clean_bib_fpath, new_bibtex_str)
def show_matches2(ibs, aid1, aid2, fm=None, fs=None, fm_norm=None, sel_fm=[], H1=None, H2=None, qreq_=None, **kwargs): """ TODO: DEPRICATE and use special case of show_name_matches Integrate ChipMatch Used in: Found 1 line(s) in '/home/joncrall/code/ibeis_cnn/ibeis_cnn/ingest_ibeis.py': ingest_ibeis.py : 827 | >>> ibeis.viz.viz_matches.show_matches2(ibs, aid1, aid2, fm=None, kpts1=kpts1, kpts2=kpts2) ---------------------- Found 4 line(s) in '/home/joncrall/code/ibeis/ibeis/viz/viz_matches.py': viz_matches.py : 423 |def show_matches2(ibs, aid1, aid2, fm=None, fs=None, fm_norm=None, sel_fm=[], viz_matches.py : 430 | python -m ibeis.viz.viz_matches --exec-show_matches2 --show viz_matches.py : 431 | python -m ibeis --tf ChipMatch.ishow_single_annotmatch show_matches2 --show viz_matches.py : 515 | return show_matches2(ibs, aid1, aid2, fm, fs, qreq_=qreq_, **kwargs) ---------------------- Found 1 line(s) in '/home/joncrall/code/ibeis/ibeis/viz/interact/interact_matches.py': interact_matches.py : 372 | tup = viz.viz_matches.show_matches2(ibs, self.qaid, self.daid, ---------------------- Found 1 line(s) in '/home/joncrall/code/ibeis/ibeis/algo/hots/vsone_pipeline.py': vsone_pipeline.py : 1339 | viz_matches.show_matches2(ibs, qaid, daid, fm=fm, fs=fs, fm_norm=fm_norm, ori=True, ---------------------- Found 2 line(s) in '/home/joncrall/code/ibeis/ibeis/algo/hots/chip_match.py': chip_match.py : 204 | viz_matches.show_matches2(qreq_.ibs, cm.qaid, daid, qreq_=qreq_, chip_match.py : 219 | ibeis.viz.viz_matches.show_matches2 ---------------------- Found 1 line(s) in '/home/joncrall/code/ibeis/ibeis/algo/hots/scoring.py': scoring.py : 562 | viz.viz_matches.show_matches2(qreq_.ibs, qaid, daid, fm, fs, CommandLine: python -m ibeis.viz.viz_matches --exec-show_matches2 --show python -m ibeis --tf ChipMatch.ishow_single_annotmatch show_matches2 --show Example: >>> # DISABLE_DOCTEST >>> from ibeis.algo.hots.chip_match import * # NOQA >>> import ibeis >>> cm, qreq_ = ibeis.testdata_cm(defaultdb='PZ_MTEST', default_qaids=[18]) >>> cm.score_nsum(qreq_) >>> daid = cm.get_top_aids()[0] >>> cm.show_single_annotmatch(qreq_, daid) >>> ut.show_if_requested() """ if qreq_ is None: print('[viz_matches] WARNING: qreq_ is None') kwargs = kwargs.copy() in_image = kwargs.get('in_image', False) draw_fmatches = kwargs.pop('draw_fmatches', True) # Read query and result info (chips, names, ...) rchip1, rchip2, kpts1, kpts2 = _get_annot_pair_info(ibs, aid1, aid2, qreq_, draw_fmatches, **kwargs) ut.delete_keys(kwargs, ['kpts1', 'kpts2']) if fm is None: assert len(kpts1) == len(kpts2), 'keypoints should be in correspondence' import numpy as np fm = np.vstack((np.arange(len(kpts1)), np.arange(len(kpts1)))).T # Build annotation strings / colors lbl1 = 'q' + vh.get_aidstrs(aid1) lbl2 = vh.get_aidstrs(aid2) if in_image: # HACK! lbl1 = None lbl2 = None # Draws the chips and keypoint matches try: ax, xywh1, xywh2 = pt.show_chipmatch2(rchip1, rchip2, kpts1, kpts2, fm, fs=fs, fm_norm=fm_norm, H1=H1, H2=H2, lbl1=lbl1, lbl2=lbl2, sel_fm=sel_fm, **kwargs) except Exception as ex: ut.printex(ex, 'consider qr.remove_corrupted_queries', '[viz_matches]') print('') raise # Moved the code into show_chipmatch #if len(sel_fm) > 0: # # Draw any selected matches # sm_kw = dict(rect=True, colors=pt.BLUE) # pt.plot_fmatch(xywh1, xywh2, kpts1, kpts2, sel_fm, **sm_kw) (x1, y1, w1, h1) = xywh1 (x2, y2, w2, h2) = xywh2 offset1 = (x1, y1) offset2 = (x2, y2) annotate_matches2(ibs, aid1, aid2, fm, fs, xywh2=xywh2, xywh1=xywh1, offset1=offset1, offset2=offset2, **kwargs) return ax, xywh1, xywh2