def MAKE_BIG_DB(): workdir = sysres.get_workdir() dbname = 'testdb_big' dbdir = join(workdir, dbname) utool.delete(dbdir) main_locals = ibeis.main(dbdir=dbdir, gui=False) ibs = main_locals['ibs'] # IBEIS Control gpath_list = grabdata.get_test_gpaths(ndata=1) imgdir = get_big_imgdir(workdir) gname_list = utool.list_images(imgdir, recursive=True) gpath_list = [join(imgdir, gname) for gname in gname_list] gpath_list = gpath_list assert all(map(exists, gpath_list)), 'some images dont exist' #nImages = len(gpath_list) #with utool.Timer('Add %d Images' % nImages): gid_list = ibs.add_images(gpath_list) #with utool.Timer('Convert %d Images to annotations' % nImages): aid_list = ibsfuncs.use_images_as_annotations(ibs, gid_list) #with utool.Timer('Compute %d chips' % nImages): cid_list = ibs.add_chips(aid_list) #with utool.Timer('Compute %d features' % nImages): fid_list = ibs.add_feats(cid_list) #with utool.Timer('Getting %d nFeats' % nImages): nFeats_list = ibs.get_num_feats(fid_list) print('Total number of features in the database: %r' % sum(nFeats_list)) return locals()
def make_testdb0(): """ makes testdb0 """ def get_test_gpaths(ndata=None, names=None, **kwargs): # Read ndata from args or command line """ DEPRICATE """ ndata_arg = ut.get_argval( '--ndata', type_=int, default=None, help_='use --ndata to specify bigger data') if ndata_arg is not None: ndata = ndata_arg imgdir = get_testdata_dir(**kwargs) gpath_list = sorted( list(ut.list_images(imgdir, full=True, recursive=True))) # Get only the gpaths of certain names if names is not None: gpath_list = [ gpath for gpath in gpath_list if ut.basename_noext(gpath) in names ] # Get a some number of test images if ndata is not None: gpath_cycle = cycle(gpath_list) if six.PY2: gpath_list = [gpath_cycle.next() for _ in range(ndata)] else: gpath_list = [next(gpath_cycle) for _ in range(ndata)] return gpath_list workdir = ibeis.sysres.get_workdir() TESTDB0 = join(workdir, 'testdb0') main_locals = ibeis.main(dbdir=TESTDB0, gui=False, allow_newdir=True) ibs = main_locals['ibs'] assert ibs is not None, str(main_locals) gpath_list = list(map(ut.unixpath, get_test_gpaths())) #print('[RESET] gpath_list=%r' % gpath_list) gid_list = ibs.add_images(gpath_list) # NOQA valid_gids = ibs.get_valid_gids() valid_aids = ibs.get_valid_aids() try: assert len( valid_aids ) == 0, 'there are more than 0 annotations in an empty database!' except Exception as ex: ut.printex(ex, key_list=['valid_aids']) raise gid_list = valid_gids[0:1] bbox_list = [(0, 0, 100, 100)] aid = ibs.add_annots(gid_list, bbox_list=bbox_list)[0] #print('[RESET] NEW RID=%r' % aid) aids = ibs.get_image_aids(gid_list)[0] try: assert aid in aids, ('bad annotation adder: aid = %r, aids = %r' % (aid, aids)) except Exception as ex: ut.printex(ex, key_list=['aid', 'aids']) raise
def make_testdb0(): """ makes testdb0 """ def get_test_gpaths(ndata=None, names=None, **kwargs): # Read ndata from args or command line """ DEPRICATE """ ndata_arg = ut.get_argval('--ndata', type_=int, default=None, help_='use --ndata to specify bigger data') if ndata_arg is not None: ndata = ndata_arg imgdir = get_testdata_dir(**kwargs) gpath_list = sorted(list(ut.list_images(imgdir, full=True, recursive=True))) # Get only the gpaths of certain names if names is not None: gpath_list = [gpath for gpath in gpath_list if ut.basename_noext(gpath) in names] # Get a some number of test images if ndata is not None: gpath_cycle = cycle(gpath_list) if six.PY2: gpath_list = [gpath_cycle.next() for _ in range(ndata)] else: gpath_list = [next(gpath_cycle) for _ in range(ndata)] return gpath_list workdir = ibeis.sysres.get_workdir() TESTDB0 = join(workdir, 'testdb0') main_locals = ibeis.main(dbdir=TESTDB0, gui=False, allow_newdir=True) ibs = main_locals['ibs'] assert ibs is not None, str(main_locals) gpath_list = list(map(ut.unixpath, get_test_gpaths())) #print('[RESET] gpath_list=%r' % gpath_list) gid_list = ibs.add_images(gpath_list) # NOQA valid_gids = ibs.get_valid_gids() valid_aids = ibs.get_valid_aids() try: assert len(valid_aids) == 0, 'there are more than 0 annotations in an empty database!' except Exception as ex: ut.printex(ex, key_list=['valid_aids']) raise gid_list = valid_gids[0:1] bbox_list = [(0, 0, 100, 100)] aid = ibs.add_annots(gid_list, bbox_list=bbox_list)[0] #print('[RESET] NEW RID=%r' % aid) aids = ibs.get_image_aids(gid_list)[0] try: assert aid in aids, ('bad annotation adder: aid = %r, aids = %r' % (aid, aids)) except Exception as ex: ut.printex(ex, key_list=['aid', 'aids']) raise
def test_clock_offset(): r""" CommandLine: python -m ibeis.gui.clock_offset_gui --test-test_clock_offset Example: >>> # DISABLE_DOCTEST >>> from ibeis.gui.clock_offset_gui import * # NOQA >>> # build test data >>> # execute function >>> result = test_clock_offset() >>> # verify results >>> print(result) """ import ibeis main_locals = ibeis.main(db='testdb1') ibs = main_locals['ibs'] gid_list = ibs.get_valid_gids() co = ClockOffsetWidget(ibs, gid_list, hack=True) co.show() ibeis.main_loop(main_locals)
def clock_offset_test(): r""" CommandLine: python -m ibeis.gui.clock_offset_gui --test-clock_offset_test Example: >>> # DISABLE_DOCTEST >>> from ibeis.gui.clock_offset_gui import * # NOQA >>> # build test data >>> # execute function >>> result = clock_offset_test() >>> # verify results >>> print(result) """ import ibeis main_locals = ibeis.main(db='testdb1') ibs = main_locals['ibs'] gid_list = ibs.get_valid_gids() co = ClockOffsetWidget(ibs, gid_list, hack=True) co.show() ibeis.main_loop(main_locals)
def make_testdb0(): main_locals = ibeis.main(dbdir=TESTDB0, gui=False, allow_newdir=True) ibs = main_locals['ibs'] assert ibs is not None, str(main_locals) gpath_list = map(utool.unixpath, grabdata.get_test_gpaths()) #print('[RESET] gpath_list=%r' % gpath_list) gid_list = ibs.add_images(gpath_list) # NOQA valid_gids = ibs.get_valid_gids() valid_aids = ibs.get_valid_aids() try: assert len(valid_aids) == 0, 'there are more than 0 annotations in an empty database!' except Exception as ex: utool.printex(ex, key_list=['valid_aids']) raise gid_list = valid_gids[0:1] bbox_list = [(0, 0, 100, 100)] aid = ibs.add_annots(gid_list, bbox_list=bbox_list)[0] #print('[RESET] NEW RID=%r' % aid) aids = ibs.get_image_aids(gid_list)[0] try: assert aid in aids, ('bad annotation adder: aid = %r, aids = %r' % (aid, aids)) except Exception as ex: utool.printex(ex, key_list=['aid', 'aids']) raise
aids_in_gids = ibs.get_image_aids(gid_list) # Rois in images aids_in_nids = ibs.get_name_aids(nid_list) # Rois in images img_uuid_list = ibs.get_image_uuids(gid_list) # Image uuids annotation_uuid_list = ibs.get_annot_uuids(aid_list) # Roi uuids # # # IBEIS Getter methods can take scalars as input too, # in this case the output is also a scalar # gid = gid_list[0] gpath = ibs.get_image_paths(gid) # Get an image path # Print locals to the screen print('locals() = ' + utool.dict_str(locals())) return locals() if __name__ == '__main__': multiprocessing.freeze_support() # for win32 main_locals = ibeis.main(defaultdb='testdb1', gui=False) ibs = main_locals['ibs'] # IBEIS Controller # Run the example example_locals = run_example(ibs) # Add local variables to main namespace exec(utool.execstr_dict(example_locals, 'example_locals')) execstr = ibeis.main_loop(main_locals) # Pass the --cmd flag to the program to run in IPython mode exec(execstr)
aids = aid_list[1:3] interact.ishow_image(ibs, gid, aids=aids, fnum=1) #---------------------- #print('Show Chip') interact.ishow_chip(ibs, aid, in_image=False, fnum=2) #interact.ishow_chip(ibs, aid, in_image=True, fnum=3) #---------------------- #print('Show Query') #aid1 = aid #qcid2_qres = ibs._query_chips4([qaid1], valid_aids) #qres = qcid2_qres.values()[0] #top_cids = qres.get_top_cids(ibs) #assert len(top_cids) > 0, 'there does not seem to be results' #cid2 = top_cids[0] # 294 #viz.show_matches(ibs, qres, cid2, fnum=4) #viz.show_qres(ibs, qres, fnum=5) return locals() if __name__ == '__main__': multiprocessing.freeze_support() # For windows import ibeis main_locals = ibeis.main(defaultdb='testdb0') ibs = main_locals['ibs'] # IBEIS Control test_locals = utool.run_test(TEST_INTERACT, ibs) #execstr = utool.execstr_dict(test_locals, 'test_locals') #exec(execstr)
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 main(): main_locals = ibeis.main() execstr = ibeis.main_loop(main_locals) return main_locals, execstr
gpath_list = grabdata.get_test_gpaths(ndata=None)[0:4] gid_list = ibs.add_images(gpath_list) bbox_list = [(0, 0, 100, 100)] * len(gid_list) name_list = ['a', 'b', 'a', 'd'] aid_list = ibs.add_annots(gid_list, bbox_list=bbox_list, name_list=name_list) cid_list = ibs.add_annot_chips(aid_list) assert len(cid_list) != 0, "No chips added" fid_list = ibs.add_chip_feat(cid_list) assert len(fid_list) != 0, "No features added" fid = fid_list[0] ibs.delete_features(fid) fid_list = ibs.get_valid_fids() assert fid not in fid_list, "FID not deleted" return locals() if __name__ == '__main__': multiprocessing.freeze_support() # For windows import ibeis main_locals = ibeis.main(defaultdb='testdb_empty', gui=False, allow_newdir=True, delete_ibsdir=True) ibs = main_locals['ibs'] # IBEIS Control back = main_locals['back'] # IBEIS GUI backend test_locals = utool.run_test(TEST_DELETE_FEATURE, ibs, back) exec(utool.execstr_dict(test_locals, 'test_locals')) exec(utool.ipython_execstr())
cid = ibs.get_annot_cids(aid, ensure=True) fid = ibs.get_annot_fids(aid, ensure=True) assert cid is not None, "cid should be computed" assert fid is not None, "fid should be computed" gthumbpath = ibs.get_image_thumbpath(gid) athumbpath = ibs.get_annot_chip_thumbpath(aid) ibs.delete_images(gid) all_gids = ibs.get_valid_gids() all_aids = ibs.get_valid_aids() all_cids = ibs.get_valid_cids() all_fids = ibs.get_valid_fids() assert gid not in all_gids, "gid still exists" assert aid not in all_aids, "rid %r still exists" % aid assert fid not in all_fids, "fid %r still exists" % fid assert cid not in all_cids, "cid %r still exists" % cid assert not utool.checkpath(gthumbpath), "Thumbnail still exists" assert not utool.checkpath(athumbpath), "ANNOTATION Thumbnail still exists" return locals() if __name__ == '__main__': multiprocessing.freeze_support() # For windows import ibeis main_locals = ibeis.main(defaultdb='testdb_empty', gui=False, allow_newdir=True, delete_ibsdir=True) ibs = main_locals['ibs'] # IBEIS Control back = main_locals['back'] # IBEIS GUI backend test_locals = utool.run_test(TEST_DELETE_IMAGE, ibs, back) exec(utool.execstr_dict(test_locals, 'test_locals')) exec(utool.ipython_execstr())
#list(extract_hesaff_sift_feats(cfpath_list, chunksize=16, **genkw)) #[parallel] executing 1049 gen_feat_worker tasks using 7 processes with chunksize=16 # * timed: 124.47361485097099 seconds #---------- #list(extract_hesaff_sift_feats(cfpath_list, chunksize=32, **genkw)) #[parallel] executing 1049 gen_feat_worker tasks using 7 processes with chunksize=32 # * timed: 126.47238857719219 seconds #---------- #list(extract_hesaff_sift_feats(cfpath_list, chunksize=64, **genkw)) #[parallel] executing 1049 gen_feat_worker tasks using 7 processes with chunksize=64 # * timed: 137.3404114996564 seconds print('[/TIME_GEN_PREPROC_FEAT]') return locals() if __name__ == '__main__': multiprocessing.freeze_support() # For windows import ibeis main_locals = ibeis.main(defaultdb='GZ_ALL', gui=False) ibs = main_locals['ibs'] time_locals = {} # Varying chunksize seems not to do much on windows :( #time_locals.update(TIME_GEN_PREPROC_IMG(ibs)) time_locals.update(TIME_GEN_PREPROC_FEAT(ibs)) execstr = utool.execstr_dict(time_locals, 'time_locals') exec(execstr) exec(utool.ipython_execstr())
orig_confidences = ibs.get_alr_confidence(alrid_list) new_confidences = list(range(len(alrid_list))) # ibs.print_alr_table() ibs.set_alr_confidence(alrid_list, new_confidences) # ibs.print_alr_table() new_confidences2 = ibs.get_alr_confidence(alrid_list) assert new_confidences == new_confidences2, "new_confidences == new_confidences2 failed" ibs.set_alr_confidence(alrid_list, orig_confidences) assert orig_confidences == ibs.get_alr_confidence(alrid_list), "alr confidences were not reset" """ test metadata """ # ibs.print_tables() # ibs.print_lblannot_table() # ibs.print_alr_table() return locals() if __name__ == "__main__": import multiprocessing multiprocessing.freeze_support() # For win32 import ibeis # Initialize database main_locals = ibeis.main(defaultdb="testdb1", gui=False) ibs = main_locals["ibs"] test_locals = utool.run_test(TEST_IBS_CONTROL, ibs) # execstr = utool.execstr_dict(test_locals, 'test_locals') # exec(execstr)
aid_list = ibs.add_annots(gids[0:1], bbox_list=bbox_list) vert_list = ibs.get_annot_verts(aid_list) bbox_list_new = geometry.bboxes_from_vert_list(vert_list) assert bbox_list_new == bbox_list, 'Original bbox does not match the returned one' bbox_list = [(0, 0, 100, 100)] aid_list = ibs.add_annots(gids[1:2], bbox_list=bbox_list) vert_list = ibs.get_annot_verts(aid_list) vert_list_new = geometry.verts_list_from_bboxes_list(bbox_list) assert vert_list_new == vert_list, 'Vertices and their bounding box do not match' vert_list = [((0, 50), (50, 100), (100, 50), (50, 0))] aid_list = ibs.add_annots(gids[2:3], vert_list=vert_list) bbox_list = ibs.get_annot_bboxes(aid_list) bbox_list_new = geometry.bboxes_from_vert_list(vert_list) assert bbox_list_new == bbox_list, 'Original bbox does not match the returned one' return locals() if __name__ == '__main__': multiprocessing.freeze_support() # For win32 import ibeis main_locals = ibeis.main(defaultdb='testdb0', gui=False, allow_newdir=False, delete_ibsdir=False) ibs = main_locals['ibs'] # IBEIS Control test_locals = utool.run_test(TEST_CONVERT_BBOX_POLY, ibs) #execstr = utool.execstr_dict(test_locals, 'test_locals') #execstr += '\n' + utool.ipython_execstr() #exec(execstr)
@profile def TIME_QUERY(ibs): print('[TIME_QUERY]') #valid_aids = ibs.get_valid_aids() # [0:20] valid_aids = ibs.get_valid_aids()[0:10] # [0:20] qaid_list = valid_aids daid_list = valid_aids # Query without using the query cache querykw = { 'use_bigcache': False, 'use_cache': False, } with utool.Timer('timing all vs all query'): qres_list = ibs.query_chips(qaid_list, daid_list, **querykw) print('[/TIME_QUERY]') return locals() if __name__ == '__main__': multiprocessing.freeze_support() # For windows import ibeis main_locals = ibeis.main(defaultdb='PZ_MOTHERS', gui=False) ibs = main_locals['ibs'] time_locals = TIME_QUERY(ibs) execstr = utool.execstr_dict(time_locals, 'time_locals') exec(execstr) exec(utool.ipython_execstr())
#!/usr/bin/env python2.7 # TODO: ADD COPYRIGHT TAG from __future__ import absolute_import, division, print_function import multiprocessing import utool print, print_, printDBG, rrr, profile = utool.inject(__name__, '[TEST_DELETE_ENC]') def TEST_DELETE_ENC(ibs, back): from ibeis.dev import ibsfuncs ibsfuncs.update_all_image_encounter(ibs) eid_list = ibs.get_valid_eids() assert len(eid_list) != 0, "All Image encounter not created" eid = eid_list[0] ibs.delete_encounters(eid) eid_list = ibs.get_valid_eids() assert eid not in eid_list, "eid=%r still exists" % (eid,) return locals() if __name__ == '__main__': multiprocessing.freeze_support() # For windows import ibeis main_locals = ibeis.main(defaultdb='testdb1', gui=False) ibs = main_locals['ibs'] # IBEIS Control back = main_locals['back'] # IBEIS GUI backend test_locals = utool.run_test(TEST_DELETE_ENC, ibs, back) exec(utool.execstr_dict(test_locals, 'test_locals')) exec(utool.ipython_execstr())
def run_ibeis(): r""" CommandLine: python -m ibeis python -m ibeis find_installed_tomcat python -m ibeis get_annot_groundtruth:1 """ #ut.set_process_title('IBEIS_main') #main_locals = ibeis.main() #ibeis.main_loop(main_locals) #ut.set_process_title('IBEIS_main') cmdline_varags = ut.get_cmdline_varargs() if len(cmdline_varags) > 0 and cmdline_varags[0] == 'rsync': from ibeis.scripts import rsync_ibeisdb rsync_ibeisdb.rsync_ibsdb_main() sys.exit(0) if ut.get_argflag('--devcmd'): # Hack to let devs mess around when using an installer version # TODO: add more hacks #import utool.tests.run_tests #utool.tests.run_tests.run_tests() ut.embed() # Run the tests of other modules elif ut.get_argflag('--run-utool-tests'): import utool.tests.run_tests retcode = utool.tests.run_tests.run_tests() print('... exiting') sys.exit(retcode) elif ut.get_argflag('--run-vtool-tests'): import vtool.tests.run_tests retcode = vtool.tests.run_tests.run_tests() print('... exiting') sys.exit(retcode) elif ut.get_argflag(('--run-ibeis-tests', '--run-tests')): from ibeis.tests import run_tests retcode = run_tests.run_tests() print('... exiting') sys.exit(retcode) if ut.get_argflag('-e'): """ ibeis -e print -a default -t default """ # Run dev script if -e given import ibeis.dev # NOQA ibeis.dev.devmain() print('... exiting') sys.exit(0) # Attempt to run a test using the funciton name alone # with the --tf flag import ibeis.tests.run_tests import ibeis.tests.reset_testdbs import ibeis.scripts.thesis ignore_prefix = [ #'ibeis.tests', 'ibeis.control.__SQLITE3__', '_autogen_explicit_controller' ] ignore_suffix = ['_grave'] func_to_module_dict = { 'demo_bayesnet': 'ibeis.unstable.demobayes', } ut.main_function_tester('ibeis', ignore_prefix, ignore_suffix, func_to_module_dict=func_to_module_dict) #if ut.get_argflag('-e'): # import ibeis # expt_kw = ut.get_arg_dict(ut.get_func_kwargs(ibeis.run_experiment), # prefix_list=['--', '-']) # ibeis.run_experiment(**expt_kw) # sys.exit(0) doctest_modname = ut.get_argval( ('--doctest-module', '--tmod', '-tm', '--testmod'), type_=str, default=None, help_='specify a module to doctest') if doctest_modname is not None: """ Allow any doctest to be run the main ibeis script python -m ibeis --tmod utool.util_str --test-align:0 python -m ibeis --tmod ibeis.algo.hots.pipeline --test-request_ibeis_query_L0:0 --show python -m ibeis --tf request_ibeis_query_L0:0 --show ./dist/ibeis/IBEISApp --tmod ibeis.algo.hots.pipeline --test-request_ibeis_query_L0:0 --show # NOQA ./dist/ibeis/IBEISApp --tmod utool.util_str --test-align:0 ./dist/IBEIS.app/Contents/MacOS/IBEISApp --tmod utool.util_str --test-align:0 ./dist/IBEIS.app/Contents/MacOS/IBEISApp --run-utool-tests ./dist/IBEIS.app/Contents/MacOS/IBEISApp --run-vtool-tests """ print('[ibeis] Testing module') mod_alias_list = {'exptdraw': 'ibeis.expt.experiment_drawing'} doctest_modname = mod_alias_list.get(doctest_modname, doctest_modname) module = ut.import_modname(doctest_modname) (nPass, nTotal, failed_list, error_report_list) = ut.doctest_funcs(module=module) retcode = 1 - (len(failed_list) == 0) #print(module) sys.exit(retcode) import ibeis main_locals = ibeis.main() execstr = ibeis.main_loop(main_locals) # <DEBUG CODE> if 'back' in main_locals and CMD: back = main_locals['back'] front = getattr(back, 'front', None) # NOQA #front = back.front #ui = front.ui ibs = main_locals['ibs'] # NOQA exec(execstr)
def run_ibeis(): r""" CommandLine: python -m ibeis python -m ibeis find_installed_tomcat python -m ibeis get_annot_groundtruth:1 """ #ut.set_process_title('IBEIS_main') #main_locals = ibeis.main() #ibeis.main_loop(main_locals) #ut.set_process_title('IBEIS_main') cmdline_varags = ut.get_cmdline_varargs() if len(cmdline_varags) > 0 and cmdline_varags[0] == 'rsync': from ibeis.scripts import rsync_ibeisdb rsync_ibeisdb.rsync_ibsdb_main() sys.exit(0) if ut.get_argflag('--devcmd'): # Hack to let devs mess around when using an installer version # TODO: add more hacks #import utool.tests.run_tests #utool.tests.run_tests.run_tests() ut.embed() # Run the tests of other modules elif ut.get_argflag('--run-utool-tests'): import utool.tests.run_tests retcode = utool.tests.run_tests.run_tests() print('... exiting') sys.exit(retcode) elif ut.get_argflag('--run-vtool-tests'): import vtool.tests.run_tests retcode = vtool.tests.run_tests.run_tests() print('... exiting') sys.exit(retcode) elif ut.get_argflag(('--run-ibeis-tests', '--run-tests')): from ibeis.tests import run_tests retcode = run_tests.run_tests() print('... exiting') sys.exit(retcode) if ut.get_argflag('-e'): """ ibeis -e print -a default -t default """ # Run dev script if -e given import ibeis.dev # NOQA ibeis.dev.devmain() print('... exiting') sys.exit(0) # Attempt to run a test using the funciton name alone # with the --tf flag import ibeis.tests.run_tests import ibeis.tests.reset_testdbs ignore_prefix = [ #'ibeis.tests', 'ibeis.control.__SQLITE3__', '_autogen_explicit_controller'] ignore_suffix = ['_grave'] func_to_module_dict = { 'demo_bayesnet': 'ibeis.algo.hots.demobayes', } ut.main_function_tester('ibeis', ignore_prefix, ignore_suffix, func_to_module_dict=func_to_module_dict) #if ut.get_argflag('-e'): # import ibeis # expt_kw = ut.get_arg_dict(ut.get_func_kwargs(ibeis.run_experiment), # prefix_list=['--', '-']) # ibeis.run_experiment(**expt_kw) # sys.exit(0) doctest_modname = ut.get_argval( ('--doctest-module', '--tmod', '-tm', '--testmod'), type_=str, default=None, help_='specify a module to doctest') if doctest_modname is not None: """ Allow any doctest to be run the main ibeis script python -m ibeis --tmod utool.util_str --test-align:0 python -m ibeis --tmod ibeis.algo.hots.pipeline --test-request_ibeis_query_L0:0 --show python -m ibeis --tf request_ibeis_query_L0:0 --show ./dist/ibeis/IBEISApp --tmod ibeis.algo.hots.pipeline --test-request_ibeis_query_L0:0 --show # NOQA ./dist/ibeis/IBEISApp --tmod utool.util_str --test-align:0 ./dist/IBEIS.app/Contents/MacOS/IBEISApp --tmod utool.util_str --test-align:0 ./dist/IBEIS.app/Contents/MacOS/IBEISApp --run-utool-tests ./dist/IBEIS.app/Contents/MacOS/IBEISApp --run-vtool-tests """ print('[ibeis] Testing module') mod_alias_list = { 'exptdraw': 'ibeis.expt.experiment_drawing' } doctest_modname = mod_alias_list.get(doctest_modname, doctest_modname) module = ut.import_modname(doctest_modname) (nPass, nTotal, failed_list, error_report_list) = ut.doctest_funcs(module=module) retcode = 1 - (len(failed_list) == 0) #print(module) sys.exit(retcode) import ibeis main_locals = ibeis.main() execstr = ibeis.main_loop(main_locals) # <DEBUG CODE> if 'back' in main_locals and CMD: #from ibeis.all_imports import * # NOQA back = main_locals['back'] front = getattr(back, 'front', None) # NOQA #front = back.front #ui = front.ui ibs = main_locals['ibs'] # NOQA exec(execstr)
# else: # dir_ = utool.truepath(join(sysres.get_workdir(), 'PZ_MOTHERS/images')) # gpath_list = utool.list_images(dir_, fullpath=True, recursive=True)[::4] print('[TEST] IMPORT IMAGES FROM FILE\n * gpath_list=%r' % gpath_list) gid_list = back.import_images(gpath_list=gpath_list) thumbtup_list = ibs.get_image_thumbtup(gid_list) imgpath_list = [tup[1] for tup in thumbtup_list] gpath_list2 = ibs.get_image_paths(gid_list) for path in gpath_list2: assert path in imgpath_list, "Imported Image not in db, path=%r" % path elif mode == 'DIR': dir_ = grabdata.get_testdata_dir() print('[TEST] IMPORT IMAGES FROM DIR\n * dir_=%r' % dir_) gid_list = back.import_images(dir_=dir_) else: raise AssertionError('unknown mode=%r' % mode) print('[TEST] * len(gid_list)=%r' % len(gid_list)) return locals() if __name__ == '__main__': multiprocessing.freeze_support() # For windows import ibeis main_locals = ibeis.main(defaultdb='testdb0', gui=True, allow_newdir=True) ibs = main_locals['ibs'] # IBEIS Control back = main_locals['back'] # IBEIS GUI backend test_locals = utool.run_test(TEST_GUI_IMPORT_IMAGES, ibs, back) execstr = utool.execstr_dict(test_locals, 'test_locals') exec(execstr)
aids = aid_list[1:3] interact.ishow_image(ibs, gid, aids=aids, fnum=1) #---------------------- #print('Show Chip') interact.ishow_chip(ibs, aid, in_image=False, fnum=2) #interact.ishow_chip(ibs, aid, in_image=True, fnum=3) #---------------------- #print('Show Query') #aid1 = aid #qcid2_qres = ibs.query_all([aid1]) #qres = qcid2_qres.values()[0] #top_cids = qres.get_top_cids(ibs) #assert len(top_cids) > 0, 'there does not seem to be results' #cid2 = top_cids[0] # 294 #viz.show_matches(ibs, qres, cid2, fnum=4) #viz.show_qres(ibs, qres, fnum=5) return locals() if __name__ == '__main__': multiprocessing.freeze_support() # For windows import ibeis main_locals = ibeis.main(defaultdb='testdb0') ibs = main_locals['ibs'] # IBEIS Control test_locals = utool.run_test(TEST_INTERACT, ibs) execstr = utool.execstr_dict(test_locals, 'test_locals') exec(execstr)
from os.path import join if __name__ == '__main__': multiprocessing.freeze_support() # for win32 # Create a directory for the demo database workdir = ibeis.get_workdir() demodir = join(workdir, 'demo') if utool.get_arg('--reset'): # Remove the previous demo if it exists utool.delete(demodir) # Start a new database there main_locals = ibeis.main(dbdir=demodir) # Get a handle to the GUIBackend Control back = main_locals['back'] # Get a directory with some images in it testurl = 'https://www.dropbox.com/s/s4gkjyxjgghr18c/testdata_detect.zip' testdir = utool.grab_zipped_url(testurl) execstr = ibeis.main_loop(main_locals) exec(execstr) script = """ back.import_images_from_dir(testdir) back.detect_grevys_quick()
} with utool.Timer('timing all vs all query'): qres_dict = ibs._query_chips(qaid_list, daid_list, **querykw) #for qaid in qaid_list: # qres = qres_dict[qaid] # top_aids = qres.get_top_aids(ibs) # top_aids = utool.safe_slice(top_aids, 3) # aid2 = top_aids[0] # fnum = df2.next_fnum() # df2.figure(fnum=fnum, doclf=True) # #viz_matches.show_matches(ibs, qres, aid2, fnum=fnum, in_image=True) # #viz.show_qres(ibs, qres, fnum=fnum, top_aids=top_aids, ensure=False) # interact.ishow_qres(ibs, qres, fnum=fnum, top_aids=top_aids, # ensure=False, annote_mode=1) # df2.set_figtitle('Query Result') # df2.adjust_subplots_safe(top=.8) print('[/TIME_QUERY]') return locals() if __name__ == '__main__': multiprocessing.freeze_support() # For windows import ibeis main_locals = ibeis.main(defaultdb='PZ_MOTHERS', gui=False) ibs = main_locals['ibs'] time_locals = TIME_QUERY(ibs) execstr = utool.execstr_dict(time_locals, 'time_locals') exec(execstr) exec(utool.ipython_execstr())
assert bbox_list[0] == (50, 50, 100, 100) except AssertionError as ex: utool.printex(ex, key_list=['bbox_list', 'aid_list']) raise back.reselect_annotation(bbox=[51, 52, 103, 104]) assert ibs.get_annot_bboxes(aid_list[0]) == (51, 52, 103, 104) back.compute_encounters() unixtime_list = [100, 23, 24] ibs.set_image_unixtime(gid_list, unixtime_list) back.compute_encounters() # Change some ANNOTATIONs #add_annot(gid_list[2], None) # user selection #add_annot(None, [42, 42, 8, 8]) # back selection # I'm not sure how I want to integrate that IPython stuff return locals() if __name__ == '__main__': multiprocessing.freeze_support() # For windows main_locals = ibeis.main(defaultdb='testdb0', gui=True) gpath_list = grabdata.get_test_gpaths(names=['lena', 'zebra', 'jeff']) ibs = main_locals['ibs'] # IBEIS Control back = main_locals['back'] # IBEIS GUI backend test_locals = utool.run_test(TEST_GUI_ALL, ibs, back, gpath_list) execstr = utool.execstr_dict(test_locals, 'test_locals') exec(execstr)
bbox_list_new = geometry.bboxes_from_vert_list(vert_list) assert bbox_list_new == bbox_list, 'Original bbox does not match the returned one' bbox_list = [(0, 0, 100, 100)] aid_list = ibs.add_annots(gids[1:2], bbox_list=bbox_list) vert_list = ibs.get_annot_verts(aid_list) vert_list_new = geometry.verts_list_from_bboxes_list(bbox_list) assert vert_list_new == vert_list, 'Vertices and their bounding box do not match' vert_list = [((0, 50), (50, 100), (100, 50), (50, 0))] aid_list = ibs.add_annots(gids[2:3], vert_list=vert_list) bbox_list = ibs.get_annot_bboxes(aid_list) bbox_list_new = geometry.bboxes_from_vert_list(vert_list) assert bbox_list_new == bbox_list, 'Original bbox does not match the returned one' return locals() if __name__ == '__main__': multiprocessing.freeze_support() # For win32 import ibeis main_locals = ibeis.main(defaultdb='testdb0', gui=False, allow_newdir=False, delete_ibsdir=False) ibs = main_locals['ibs'] # IBEIS Control test_locals = utool.run_test(TEST_CONVERT_BBOX_POLY, ibs) #execstr = utool.execstr_dict(test_locals, 'test_locals') #execstr += '\n' + utool.ipython_execstr() #exec(execstr)
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')
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: ./dev.py -t query -w """ multiprocessing.freeze_support() # for win32 # # # Run IBEIS Main, create controller, and possibly gui print('++dev') main_locals = ibeis.main(gui='--gui' in sys.argv) # # # Load snippet variables SNIPPITS = True 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: