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 main(gui=True, dbdir=None, defaultdb='cache', allow_newdir=False, db=None, delete_ibsdir=False, **kwargs): """ Program entry point Inits the system environment, an IBEISControl, and a GUI if requested Args: gui (bool): (default=True) If gui is False a gui instance will not be created dbdir (None): full directory of a database to load db (None): name of database to load relative to the workdir allow_newdir (bool): (default=False) if False an error is raised if a a new database is created defaultdb (str): codename of database to load if db and dbdir is None. a value of 'cache' will open the last database opened with the GUI. Returns: dict: main_locals """ set_newfile_permissions() from ibeis.init import main_commands from ibeis.init import sysres # Display a visible intro message msg1 = ''' _____ ....... _______ _____ _______ | |_____| |______ | |______ ..|.. |.....| |______s__|__ ______| ''' msg2 = ''' _____ ______ _______ _____ _______ | |_____] |______ | |______ __|__ |_____] |______ __|__ ______| ''' if NOT_QUIET: print(msg2 if '--myway' not in sys.argv else msg1) # Init the only two main system api handles ibs = None back = None if NOT_QUIET: print('[main] ibeis.main_module.main()') _preload() DIAGNOSTICS = NOT_QUIET if DIAGNOSTICS: import os import utool as ut import ibeis print('[main] MAIN DIAGNOSTICS') print('[main] * username = %r' % (ut.get_user_name())) print('[main] * ibeis.__version__ = %r' % (ibeis.__version__,)) print('[main] * computername = %r' % (ut.get_computer_name())) print('[main] * cwd = %r' % (os.getcwd(),)) print('[main] * sys.argv = %r' % (sys.argv,)) # Parse directory to be loaded from command line args # and explicit kwargs dbdir = sysres.get_args_dbdir(defaultdb, allow_newdir, db, dbdir, cache_priority=False) if delete_ibsdir is True: from ibeis.other import ibsfuncs assert allow_newdir, 'must be making new directory if you are deleting everything!' ibsfuncs.delete_ibeis_database(dbdir) # Execute preload commands main_commands.preload_commands(dbdir, **kwargs) # PRELOAD CMDS try: # Build IBEIS Control object ibs = _init_ibeis(dbdir) if gui and USE_GUI: back = _init_gui(activate=kwargs.get('activate', True)) back.connect_ibeis_control(ibs) except Exception as ex: print('[main()] IBEIS LOAD imageseted exception: %s %s' % (type(ex), ex)) raise main_commands.postload_commands(ibs, back) # POSTLOAD CMDS main_locals = {'ibs': ibs, 'back': back} return main_locals
def main(gui=True, dbdir=None, defaultdb='cache', allow_newdir=False, db=None, delete_ibsdir=False, **kwargs): """ Program entry point Inits the system environment, an IBEISControl, and a GUI if requested Args: gui (bool): (default=True) If gui is False a gui instance will not be created dbdir (None): full directory of a database to load db (None): name of database to load relative to the workdir allow_newdir (bool): (default=False) if False an error is raised if a a new database is created defaultdb (str): codename of database to load if db and dbdir is None. a value of 'cache' will open the last database opened with the GUI. Returns: dict: main_locals """ set_newfile_permissions() from ibeis.init import main_commands from ibeis.init import sysres # Display a visible intro message msg1 = ''' _____ ....... _______ _____ _______ | |_____| |______ | |______ ..|.. |.....| |______s__|__ ______| ''' msg2 = ''' _____ ______ _______ _____ _______ | |_____] |______ | |______ __|__ |_____] |______ __|__ ______| ''' if NOT_QUIET: print(msg2 if '--myway' not in sys.argv else msg1) # Init the only two main system api handles ibs = None back = None if NOT_QUIET: print('[main] ibeis.main_module.main()') _preload() DIAGNOSTICS = NOT_QUIET if DIAGNOSTICS: import os import utool as ut import ibeis print('[main] MAIN DIAGNOSTICS') print('[main] * username = %r' % (ut.get_user_name())) print('[main] * ibeis.__version__ = %r' % (ibeis.__version__, )) print('[main] * computername = %r' % (ut.get_computer_name())) print('[main] * cwd = %r' % (os.getcwd(), )) print('[main] * sys.argv = %r' % (sys.argv, )) # Parse directory to be loaded from command line args # and explicit kwargs dbdir = sysres.get_args_dbdir(defaultdb, allow_newdir, db, dbdir, cache_priority=False) if delete_ibsdir is True: from ibeis.other import ibsfuncs assert allow_newdir, 'must be making new directory if you are deleting everything!' ibsfuncs.delete_ibeis_database(dbdir) # Execute preload commands main_commands.preload_commands(dbdir, **kwargs) # PRELOAD CMDS try: # Build IBEIS Control object ibs = _init_ibeis(dbdir) if gui and USE_GUI: back = _init_gui(activate=kwargs.get('activate', True)) back.connect_ibeis_control(ibs) except Exception as ex: print('[main()] IBEIS LOAD imageseted exception: %s %s' % (type(ex), ex)) raise main_commands.postload_commands(ibs, back) # POSTLOAD CMDS main_locals = {'ibs': ibs, 'back': back} return main_locals