def old_test_single_annot_distinctiveness_params(ibs, aid): r""" CommandLine: python -m ibeis.model.hots.distinctiveness_normalizer --test-old_test_single_annot_distinctiveness_params --show python -m ibeis.model.hots.distinctiveness_normalizer --test-old_test_single_annot_distinctiveness_params --show --db GZ_ALL Example: >>> # DISABLE_DOCTEST >>> from ibeis.model.hots.distinctiveness_normalizer import * # NOQA >>> import plottool as pt >>> import ibeis >>> # build test data >>> ibs = ibeis.opendb(ut.get_argval('--db', type_=str, default='PZ_MTEST')) >>> aid = ut.get_argval('--aid', type_=int, default=1) >>> # execute function >>> old_test_single_annot_distinctiveness_params(ibs, aid) >>> pt.show_if_requested() """ #### # TODO: Also paramatarize the downweighting based on the keypoint size #### # HACK IN ABILITY TO SET CONFIG from ibeis.dev.main_commands import postload_commands postload_commands(ibs, None) from vtool import coverage_image import plottool as pt from plottool import interact_impaint #cfglbl_list = cfgdict_list #ut.all_dict_combinations_lbls(varied_dict) # Get info to find distinctivness of species_text = ibs.get_annot_species(aid) vecs = ibs.get_annot_vecs(aid) kpts = ibs.get_annot_kpts(aid) print(kpts) chip = ibs.get_annot_chips(aid) chipsize = ibs.get_annot_chipsizes(aid) # Paramater space to search # TODO: use slicing to control the params being varied # Use GridSearch class to modify paramaters as you go. gauss_patch_varydict = { 'gauss_shape': [(7, 7), (19, 19), (41, 41), (5, 5), (3, 3)], 'gauss_sigma_frac': [.2, .5, .7, .95], } cov_blur_varydict = { 'cov_blur_on': [True, False], 'cov_blur_ksize': [(5, 5,), (7, 7), (17, 17)], 'cov_blur_sigma': [5.0, 1.2], } dstncvs_varydict = { 'dcvs_power': [.01, .1, .5, 1.0], 'dcvs_clip_max': [.05, .1, .2, .5], 'dcvs_K': [2, 3, 5], } size_penalty_varydict = { 'remove_affine_information': [False, True], 'constant_scaling': [False, True], 'size_penalty_on': [True, False], 'size_penalty_power': [.5, .1, 1.0], 'size_penalty_scale': [.1, 1.0], } keyval_iter = ut.iflatten([ dstncvs_varydict.items(), gauss_patch_varydict.items(), cov_blur_varydict.items(), size_penalty_varydict.items(), ]) # Dont vary most paramaters, specify how much of their list can be used param_slice_dict = { 'dcvs_power' : slice(0, 2), 'dcvs_K' : slice(0, 2), 'dcvs_clip_max' : slice(0, 2), 'dcvs_clip_max' : slice(0, 2), #'gauss_shape' : slice(0, 3), 'gauss_sigma_frac' : slice(0, 2), 'remove_affine_information' : slice(0, 2), 'constant_scaling' : slice(0, 2), 'size_penalty_on' : slice(0, 2), #'cov_blur_on' : slice(0, 2), #'cov_blur_ksize' : slice(0, 2), #'cov_blur_sigma' : slice(0, 1), #'size_penalty_power' : slice(0, 2), #'size_penalty_scale' : slice(0, 2), } varied_dict = { key: val[param_slice_dict.get(key, slice(0, 1))] for key, val in keyval_iter } def constrain_config(cfg): """ encode what makes a configuration feasible """ if cfg['cov_blur_on'] is False: cfg['cov_blur_ksize'] = None cfg['cov_blur_sigma'] = None if cfg['constant_scaling'] is True: cfg['remove_affine_information'] = True cfg['size_penalty_on'] = False if cfg['remove_affine_information'] is True: cfg['gauss_shape'] = (41, 41) if cfg['size_penalty_on'] is False: cfg['size_penalty_power'] = None cfg['size_penalty_scale'] = None print('Varied Dict: ') print(ut.dict_str(varied_dict)) cfgdict_list, cfglbl_list = ut.make_constrained_cfg_and_lbl_list(varied_dict, constrain_config) # Get groundtruthish distinctivness map # for objective function GT_IS_DSTNCVS = 255 GT_NOT_DSTNCVS = 100 GT_UNKNOWN = 0 label_colors = [GT_IS_DSTNCVS, GT_NOT_DSTNCVS, GT_UNKNOWN] gtmask = interact_impaint.cached_impaint(chip, 'dstncvnss', label_colors=label_colors, aug=True, refine=ut.get_argflag('--refine')) true_dstncvs_mask = gtmask == GT_IS_DSTNCVS false_dstncvs_mask = gtmask == GT_NOT_DSTNCVS true_dstncvs_mask_sum = true_dstncvs_mask.sum() false_dstncvs_mask_sum = false_dstncvs_mask.sum() def distinctiveness_objective_function(dstncvs_mask): true_mask = true_dstncvs_mask * dstncvs_mask false_mask = false_dstncvs_mask * dstncvs_mask true_score = true_mask.sum() / true_dstncvs_mask_sum false_score = false_mask.sum() / false_dstncvs_mask_sum score = true_score * (1 - false_score) return score # Load distinctivness normalizer with ut.Timer('Loading Distinctivness Normalizer for %s' % (species_text)): dstcvnss_normer = request_species_distinctiveness_normalizer(species_text) # Get distinctivness over all params dstncvs_list = [dstcvnss_normer.get_distinctiveness(vecs, **cfgdict) for cfgdict in ut.ProgressIter(cfgdict_list, lbl='get dstcvns')] # Then compute the distinctinvess coverage map #gauss_shape = kwargs.get('gauss_shape', (19, 19)) #sigma_frac = kwargs.get('sigma_frac', .3) dstncvs_mask_list = [ coverage_image.make_coverage_mask( kpts, chipsize, fx2_score=dstncvs, mode='max', return_patch=False, **cfg) for cfg, dstncvs in ut.ProgressIter(zip(cfgdict_list, dstncvs_list), lbl='Warping Image') ] score_list = [distinctiveness_objective_function(dstncvs_mask) for dstncvs_mask in dstncvs_mask_list] fnum = 1 def show_covimg_result(img, fnum=None, pnum=None): pt.imshow(255 * img, fnum=fnum, pnum=pnum) ut.interact_gridsearch_result_images( show_covimg_result, cfgdict_list, cfglbl_list, dstncvs_mask_list, score_list=score_list, fnum=fnum, figtitle='dstncvs gridsearch') # Show subcomponents of grid search gauss_patch_cfgdict_list, gauss_patch_cfglbl_list = ut.get_cfgdict_lbl_list_subset(cfgdict_list, gauss_patch_varydict) patch_list = [coverage_image.get_gaussian_weight_patch(**cfgdict) for cfgdict in ut.ProgressIter(gauss_patch_cfgdict_list, lbl='patch cfg')] ut.interact_gridsearch_result_images( show_covimg_result, gauss_patch_cfgdict_list, gauss_patch_cfglbl_list, patch_list, fnum=fnum + 1, figtitle='gaussian patches') patch = patch_list[0] # Show the first mask in more depth dstncvs = dstncvs_list[0] dstncvs_mask = dstncvs_mask_list[0] coverage_image.show_coverage_map(chip, dstncvs_mask, patch, kpts, fnum=fnum + 2, ell_alpha=.2, show_mask_kpts=False) pt.imshow(gtmask, fnum=fnum + 3, pnum=(1, 2, 1), title='ground truth distinctiveness') pt.imshow(chip, fnum=fnum + 3, pnum=(1, 2, 2)) pt.present()
def devmain(): """ The Developer Script A command line interface to almost everything -w # wait / show the gui / figures are visible --cmd # ipython shell to play with variables -t # run list of tests Examples: """ helpstr = ut.codeblock( ''' Dev is meant to be run as an interactive script. The dev.py script runs any test you regiter with @devcmd in any combination of configurations specified by a Config object. Dev caches information in order to get quicker results. # FIXME: Provide quicker results # FIXME: len(line) ''') INTRO_TITLE = 'The dev.py Script' #INTRO_TEXT = ''.join((ut.bubbletext(INTRO_TITLE, font='cybermedium'), helpstr)) INTRO_TEXT = ut.bubbletext(INTRO_TITLE, font='cybermedium') INTRO_STR = ut.msgblock('dev.py Intro', INTRO_TEXT) EXAMPLE_STR = ut.msgblock('dev.py Examples', ut.codeblock(EXAMPLE_TEXT)) if ut.NOT_QUIET: print(INTRO_STR) if ut.get_argflag(('--help', '--verbose')): print(EXAMPLE_STR) CMD = ut.get_argflag('--cmd') NOGUI = not ut.get_argflag('--gui') if len(sys.argv) == 1: print('Run dev.py with arguments!') sys.exit(1) # Run Precommands run_devprecmds() # # # Run IBEIS Main, create controller, and possibly gui print('++dev') main_locals = ibeis.main(gui=ut.get_argflag('--gui')) #utool.set_process_title('IBEIS_dev') # # # Load snippet variables SNIPPITS = True and CMD if SNIPPITS: snippet_locals = dev_snippets(main_locals) snippet_execstr = utool.execstr_dict(snippet_locals, 'snippet_locals') exec(snippet_execstr) # # # Development code RUN_DEV = True # RUN_DEV = '__IPYTHON__' in vars() if RUN_DEV: dev_locals = run_dev(main_locals['ibs']) dev_execstr = utool.execstr_dict(dev_locals, 'dev_locals') exec(dev_execstr) command = ut.get_argval('--eval', type_=str, default=None) if command is not None: result = eval(command, globals(), locals()) print('result = %r' % (result,)) #ibs.search_annot_notes('360') # # # Main Loop (IPython interaction, or some exec loop) #if '--nopresent' not in sys.argv or '--noshow' in sys.argv: ut.show_if_requested() if ut.get_argflag(('--show', '--wshow')): pt.present() main_execstr = ibeis.main_loop(main_locals, ipy=(NOGUI or CMD)) exec(main_execstr) # # # Memory profile if ut.get_argflag('--memprof'): utool.print_resource_usage() utool.memory_profile() print('exiting dev')
# # gf_rank = np.nonzero(is_negative)[0][0:num_false] # # tn_nscores.extend(sorted_nscores[gf_rank]) # # tp_nscores = np.array(tp_nscores).astype(np.float64) # # tn_nscores = np.array(tn_nscores).astype(np.float64) # # return tp_nscores, tn_nscores # #tp_nscores, tn_nscores = get_labeled_name_scores(ibs, qres_list) #from ibeis.model.hots import score_normalization #tp_support, tn_support, tp_support_labels, tn_support_labels = score_normalization.get_ibeis_score_training_data(ibs, qaid_list, qres_list) #ut.embed() #x_data, y_data = results_all.get_stem_data(ibs, qaid2_qres) #pt.plots.plot_stems(x_data, y_data) #pt.present() #pt.show() #locals_ = viz_allres_annotation_scores(allres) if __name__ == '__main__': """ CommandLine: python -c "import utool, ibeis.expt.results_all; utool.doctest_funcs(ibeis.expt.results_all, allexamples=True)" python -c "import utool, ibeis.expt.results_all; utool.doctest_funcs(ibeis.expt.results_all)" python -m ibeis.expt.results_all --allexamples python -m ibeis.expt.results_all --test-learn_score_normalization --enableall """ import multiprocessing multiprocessing.freeze_support() # for win32 import utool as ut # NOQA ut.doctest_funcs() import plottool as pt # NOQA exec(pt.present())
def test_single_annot_distinctiveness_params(ibs, aid): r""" CommandLine: python -m ibeis.algo.hots.distinctiveness_normalizer --test-test_single_annot_distinctiveness_params --show python -m ibeis.algo.hots.distinctiveness_normalizer --test-test_single_annot_distinctiveness_params --show --db GZ_ALL Example: >>> # DISABLE_DOCTEST >>> from ibeis.algo.hots.distinctiveness_normalizer import * # NOQA >>> import plottool as pt >>> import ibeis >>> # build test data >>> ibs = ibeis.opendb(ut.get_argval('--db', type_=str, default='PZ_MTEST')) >>> aid = ut.get_argval('--aid', type_=int, default=1) >>> # execute function >>> test_single_annot_distinctiveness_params(ibs, aid) >>> pt.show_if_requested() """ #### # TODO: Also paramatarize the downweighting based on the keypoint size #### # HACK IN ABILITY TO SET CONFIG from ibeis.init.main_commands import postload_commands from ibeis.algo import Config postload_commands(ibs, None) import plottool as pt #cfglbl_list = cfgdict_list #ut.all_dict_combinations_lbls(varied_dict) # Get info to find distinctivness of species_text = ibs.get_annot_species(aid) # FIXME; qreq_ params for config rowid vecs = ibs.get_annot_vecs(aid) kpts = ibs.get_annot_kpts(aid) chip = ibs.get_annot_chips(aid) # Paramater space to search # TODO: use slicing to control the params being varied # Use GridSearch class to modify paramaters as you go. varied_dict = Config.DCVS_DEFAULT.get_varydict() print('Varied Dict: ') print(ut.dict_str(varied_dict)) cfgdict_list, cfglbl_list = ut.make_constrained_cfg_and_lbl_list(varied_dict) # Get groundtruthish distinctivness map # for objective function # Load distinctivness normalizer with ut.Timer('Loading Distinctivness Normalizer for %s' % (species_text)): dstcvnss_normer = request_species_distinctiveness_normalizer(species_text) # Get distinctivness over all params dstncvs_list = [dstcvnss_normer.get_distinctiveness(vecs, **cfgdict) for cfgdict in ut.ProgIter(cfgdict_list, lbl='get dstcvns')] #fgweights = ibs.get_annot_fgweights([aid])[0] #dstncvs_list = [x * fgweights for x in dstncvs_list] fnum = 1 import functools show_func = functools.partial(show_chip_distinctiveness_plot, chip, kpts) ut.interact_gridsearch_result_images( show_func, cfgdict_list, cfglbl_list, dstncvs_list, score_list=None, fnum=fnum, figtitle='dstncvs gridsearch') pt.present()
def devfunc(ibs, qaid_list): """ Function for developing something """ print('[dev] devfunc') import ibeis # NOQA from ibeis.algo import Config # NOQA #from ibeis.algo.Config import * # NOQA feat_cfg = Config.FeatureConfig() #feat_cfg.printme3() print('\ncfgstr..') print(feat_cfg.get_cfgstr()) print(utool.dict_str(feat_cfg.get_hesaff_params())) from ibeis import viz aid = 1 ibs.cfg.feat_cfg.threshold = 16.0 / 3.0 kpts = ibs.get_annot_kpts(aid) print('len(kpts) = %r' % len(kpts)) from ibeis.expt import experiment_configs #varyparams_list = [ # #{ # # 'threshold': [16.0 / 3.0, 32.0 / 3.0], # 8.0 / 3.0 # # 'numberOfScales': [3, 2, 1], # # 'maxIterations': [16, 32], # # 'convergenceThreshold': [.05, .1], # # 'initialSigma': [1.6, 1.2], # #}, # { # #'threshold': [16.0 / 3.0, 32.0 / 3.0], # 8.0 / 3.0 # 'numberOfScales': [1], # #'maxIterations': [16, 32], # #'convergenceThreshold': [.05, .1], # #'initialSigma': [6.0, 3.0, 2.0, 1.6, 1.2, 1.1], # 'initialSigma': [3.2, 1.6, 0.8], # 'edgeEigenValueRatio': [10, 5, 3], # }, #] varyparams_list = [experiment_configs.featparams] # low threshold = more keypoints # low initialSigma = more keypoints nKpts_list = [] cfgstr_list = [] alldictcomb = utool.flatten([utool.util_dict.all_dict_combinations(varyparams) for varyparams in featparams_list]) NUM_PASSES = 1 if not utool.get_argflag('--show') else 2 for count in range(NUM_PASSES): for aid in qaid_list: #for dict_ in utool.progiter(alldictcomb, lbl='feature param comb: ', total=len(alldictcomb)): for dict_ in alldictcomb: for key_, val_ in six.iteritems(dict_): ibs.cfg.feat_cfg[key_] = val_ cfgstr_ = ibs.cfg.feat_cfg.get_cfgstr() cfgstr = utool.packstr(cfgstr_, textwidth=80, breakchars=',', newline_prefix='', break_words=False, wordsep=',') if count == 0: kpts = ibs.get_annot_kpts(aid) #print('___________') #print('len(kpts) = %r' % len(kpts)) #print(cfgstr) nKpts_list.append(len(kpts)) cfgstr_list.append(cfgstr_) if count == 1: title_suffix = (' len(kpts) = %r \n' % len(kpts)) + cfgstr viz.show_chip(ibs, aid, fnum=pt.next_fnum(), title_suffix=title_suffix, darken=.4, ell_linewidth=2, ell_alpha=.8) if count == 0: nKpts_list = np.array(nKpts_list) cfgstr_list = np.array(cfgstr_list) print(get_sortbystr(cfgstr_list, nKpts_list, 'cfg', 'nKpts')) pt.present() locals_ = locals() return locals_
def devmain(): """ The Developer Script A command line interface to almost everything -w # wait / show the gui / figures are visible --cmd # ipython shell to play with variables -t # run list of tests Examples: """ helpstr = ut.codeblock(''' Dev is meant to be run as an interactive script. The dev.py script runs any test you regiter with @devcmd in any combination of configurations specified by a Config object. Dev caches information in order to get quicker results. # FIXME: Provide quicker results # FIXME: len(line) ''') INTRO_TITLE = 'The dev.py Script' #INTRO_TEXT = ''.join((ut.bubbletext(INTRO_TITLE, font='cybermedium'), helpstr)) INTRO_TEXT = ut.bubbletext(INTRO_TITLE, font='cybermedium') INTRO_STR = ut.msgblock('dev.py Intro', INTRO_TEXT) EXAMPLE_STR = ut.msgblock('dev.py Examples', ut.codeblock(EXAMPLE_TEXT)) if ut.NOT_QUIET: print(INTRO_STR) if ut.get_argflag(('--help', '--verbose')): print(EXAMPLE_STR) CMD = ut.get_argflag('--cmd') NOGUI = not ut.get_argflag('--gui') if len(sys.argv) == 1: print('Run dev.py with arguments!') sys.exit(1) # Run Precommands run_devprecmds() # # # Run IBEIS Main, create controller, and possibly gui print('++dev') main_locals = ibeis.main(gui=ut.get_argflag('--gui')) #utool.set_process_title('IBEIS_dev') # # # Load snippet variables SNIPPITS = True and CMD if SNIPPITS: snippet_locals = dev_snippets(main_locals) snippet_execstr = utool.execstr_dict(snippet_locals, 'snippet_locals') exec(snippet_execstr) # # # Development code RUN_DEV = True # RUN_DEV = '__IPYTHON__' in vars() if RUN_DEV: dev_locals = run_dev(main_locals['ibs']) dev_execstr = utool.execstr_dict(dev_locals, 'dev_locals') exec(dev_execstr) command = ut.get_argval('--eval', type_=str, default=None) if command is not None: result = eval(command, globals(), locals()) print('result = %r' % (result, )) #ibs.search_annot_notes('360') # # # Main Loop (IPython interaction, or some exec loop) #if '--nopresent' not in sys.argv or '--noshow' in sys.argv: ut.show_if_requested() if ut.get_argflag(('--show', '--wshow')): pt.present() main_execstr = ibeis.main_loop(main_locals, ipy=(NOGUI or CMD)) exec(main_execstr) # # # Memory profile if ut.get_argflag('--memprof'): utool.print_resource_usage() utool.memory_profile() print('exiting dev')
def devfunc(ibs, qaid_list): """ Function for developing something """ print('[dev] devfunc') import ibeis # NOQA from ibeis.algo import Config # NOQA #from ibeis.algo.Config import * # NOQA feat_cfg = Config.FeatureConfig() #feat_cfg.printme3() print('\ncfgstr..') print(feat_cfg.get_cfgstr()) print(utool.dict_str(feat_cfg.get_hesaff_params())) from ibeis import viz aid = 1 ibs.cfg.feat_cfg.threshold = 16.0 / 3.0 kpts = ibs.get_annot_kpts(aid) print('len(kpts) = %r' % len(kpts)) from ibeis.expt import experiment_configs #varyparams_list = [ # #{ # # 'threshold': [16.0 / 3.0, 32.0 / 3.0], # 8.0 / 3.0 # # 'numberOfScales': [3, 2, 1], # # 'maxIterations': [16, 32], # # 'convergenceThreshold': [.05, .1], # # 'initialSigma': [1.6, 1.2], # #}, # { # #'threshold': [16.0 / 3.0, 32.0 / 3.0], # 8.0 / 3.0 # 'numberOfScales': [1], # #'maxIterations': [16, 32], # #'convergenceThreshold': [.05, .1], # #'initialSigma': [6.0, 3.0, 2.0, 1.6, 1.2, 1.1], # 'initialSigma': [3.2, 1.6, 0.8], # 'edgeEigenValueRatio': [10, 5, 3], # }, #] varyparams_list = [experiment_configs.featparams] # low threshold = more keypoints # low initialSigma = more keypoints nKpts_list = [] cfgstr_list = [] alldictcomb = utool.flatten([ utool.util_dict.all_dict_combinations(varyparams) for varyparams in featparams_list ]) NUM_PASSES = 1 if not utool.get_argflag('--show') else 2 for count in range(NUM_PASSES): for aid in qaid_list: #for dict_ in utool.progiter(alldictcomb, lbl='feature param comb: ', total=len(alldictcomb)): for dict_ in alldictcomb: for key_, val_ in six.iteritems(dict_): ibs.cfg.feat_cfg[key_] = val_ cfgstr_ = ibs.cfg.feat_cfg.get_cfgstr() cfgstr = utool.packstr(cfgstr_, textwidth=80, breakchars=',', newline_prefix='', break_words=False, wordsep=',') if count == 0: kpts = ibs.get_annot_kpts(aid) #print('___________') #print('len(kpts) = %r' % len(kpts)) #print(cfgstr) nKpts_list.append(len(kpts)) cfgstr_list.append(cfgstr_) if count == 1: title_suffix = (' len(kpts) = %r \n' % len(kpts)) + cfgstr viz.show_chip(ibs, aid, fnum=pt.next_fnum(), title_suffix=title_suffix, darken=.4, ell_linewidth=2, ell_alpha=.8) if count == 0: nKpts_list = np.array(nKpts_list) cfgstr_list = np.array(cfgstr_list) print(get_sortbystr(cfgstr_list, nKpts_list, 'cfg', 'nKpts')) pt.present() locals_ = locals() return locals_
def param_interaction(): r""" CommandLine: python -m vtool.test_constrained_matching --test-param_interaction Notes: python -m vtool.test_constrained_matching --test-param_interaction setparam normalizer_mode=nearby setparam normalizer_mode=far setparam ratio_thresh=.625 setparam ratio_thresh=.5 setparam ratio_thresh2=.625 normalizer_mode=plus Example: >>> # DISABLE_DOCTEST >>> from vtool.test_constrained_matching import * # NOQA >>> # build test data >>> # execute function >>> testtup = param_interaction() >>> # verify results >>> result = str(testtup) >>> print(result) """ import plottool as pt USE_IBEIS = False and ut.is_developer() if USE_IBEIS: from ibeis.algo.hots import devcases index = 2 fpath1, fpath2, fpath3 = devcases.get_dev_test_fpaths(index) testtup1 = testdata_matcher(fpath1, fpath2) testtup2 = testdata_matcher(fpath1, fpath3) else: testtup1 = testdata_matcher('easy1.png', 'easy2.png') testtup2 = testdata_matcher('easy1.png', 'hard3.png') testtup_list = [testtup1, testtup2] simp_list = [SimpleMatcher(testtup) for testtup in testtup_list] varied_dict = dict([ ('sver_xy_thresh', .1), ('ratio_thresh', .625), ('search_K', 7), ('ratio_thresh2', .625), ('sver_xy_thresh2', .01), ('normalizer_mode', ['nearby', 'far', 'plus'][1]), ('match_xy_thresh', .1), ]) cfgdict_list = ut.all_dict_combinations(varied_dict) tried_configs = [] # DEFINE CUSTOM INTRACTIONS custom_actions, valid_vizmodes, viz_index_, offset_fnum_ = make_custom_interactions(simp_list) # /DEFINE CUSTOM INTRACTIONS for cfgdict in ut.InteractiveIter(cfgdict_list, #default_action='reload', custom_actions=custom_actions, wraparound=True): for simp in simp_list: simp.run_matching(cfgdict=cfgdict) vizkey = valid_vizmodes[viz_index_[0]].replace('visualize_', '') print('vizkey = %r' % (vizkey,)) for fnum_, simp in enumerate(simp_list): fnum = fnum_ + offset_fnum_[0] simp.visualize(vizkey, fnum=fnum) tried_configs.append(cfgdict.copy()) print('Current Config = ') print(ut.dict_str(cfgdict)) pt.present() pt.update()
def param_interaction(): r""" CommandLine: python -m vtool.test_constrained_matching --test-param_interaction Notes: python -m vtool.test_constrained_matching --test-param_interaction setparam normalizer_mode=nearby setparam normalizer_mode=far setparam ratio_thresh=.625 setparam ratio_thresh=.5 setparam ratio_thresh2=.625 normalizer_mode=plus Example: >>> # DISABLE_DOCTEST >>> from vtool.test_constrained_matching import * # NOQA >>> # build test data >>> # execute function >>> testtup = param_interaction() >>> # verify results >>> result = str(testtup) >>> print(result) """ import plottool as pt USE_IBEIS = False and ut.is_developer() if USE_IBEIS: from ibeis.algo.hots import devcases index = 2 fpath1, fpath2, fpath3 = devcases.get_dev_test_fpaths(index) testtup1 = testdata_matcher(fpath1, fpath2) testtup2 = testdata_matcher(fpath1, fpath3) else: testtup1 = testdata_matcher('easy1.png', 'easy2.png') testtup2 = testdata_matcher('easy1.png', 'hard3.png') testtup_list = [testtup1, testtup2] simp_list = [SimpleMatcher(testtup) for testtup in testtup_list] varied_dict = dict([ ('sver_xy_thresh', .1), ('ratio_thresh', .625), ('search_K', 7), ('ratio_thresh2', .625), ('sver_xy_thresh2', .01), ('normalizer_mode', ['nearby', 'far', 'plus'][1]), ('match_xy_thresh', .1), ]) cfgdict_list = ut.all_dict_combinations(varied_dict) tried_configs = [] # DEFINE CUSTOM INTRACTIONS custom_actions, valid_vizmodes, viz_index_, offset_fnum_ = make_custom_interactions( simp_list) # /DEFINE CUSTOM INTRACTIONS for cfgdict in ut.InteractiveIter( cfgdict_list, #default_action='reload', custom_actions=custom_actions, wraparound=True): for simp in simp_list: simp.run_matching(cfgdict=cfgdict) vizkey = valid_vizmodes[viz_index_[0]].replace('visualize_', '') print('vizkey = %r' % (vizkey, )) for fnum_, simp in enumerate(simp_list): fnum = fnum_ + offset_fnum_[0] simp.visualize(vizkey, fnum=fnum) tried_configs.append(cfgdict.copy()) print('Current Config = ') print(ut.dict_str(cfgdict)) pt.present() pt.update()
# # #num_false = min(sum(is_negative), 100000) # # gf_rank = np.nonzero(is_negative)[0][0:num_false] # # tn_nscores.extend(sorted_nscores[gf_rank]) # # tp_nscores = np.array(tp_nscores).astype(np.float64) # # tn_nscores = np.array(tn_nscores).astype(np.float64) # # return tp_nscores, tn_nscores # #tp_nscores, tn_nscores = get_labeled_name_scores(ibs, qres_list) #from ibeis.model.hots import score_normalization #tp_support, tn_support, tp_support_labels, tn_support_labels = score_normalization.get_ibeis_score_training_data(ibs, qaid_list, qres_list) #ut.embed() #x_data, y_data = results_all.get_stem_data(ibs, qaid2_qres) #pt.plots.plot_stems(x_data, y_data) #pt.present() #pt.show() #locals_ = viz_allres_annotation_scores(allres) if __name__ == '__main__': """ CommandLine: python -c "import utool, ibeis.expt.results_all; utool.doctest_funcs(ibeis.expt.results_all, allexamples=True)" python -c "import utool, ibeis.expt.results_all; utool.doctest_funcs(ibeis.expt.results_all)" python -m ibeis.expt.results_all --allexamples python -m ibeis.expt.results_all --test-learn_score_normalization --enableall """ import multiprocessing multiprocessing.freeze_support() # for win32 import utool as ut # NOQA ut.doctest_funcs() import plottool as pt # NOQA exec(pt.present())