def new_neighbor_index(daid_list, vecs_list, fgws_list, flann_params, cachedir, cfgstr, force_rebuild=False, verbose=True, memtrack=None): r""" constructs neighbor index independent of ibeis Args: daid_list (list): vecs_list (list): fgws_list (list): flann_params (dict): flann_cachedir (None): nnindex_cfgstr (str): use_memcache (bool): Returns: nnindexer CommandLine: python -m ibeis.algo.hots.neighbor_index_cache --test-new_neighbor_index Example: >>> # SLOW_DOCTEST >>> from ibeis.algo.hots.neighbor_index_cache import * # NOQA >>> import ibeis >>> ibs = ibeis.opendb('testdb1') >>> daid_list = ibs.get_valid_aids(species=ibeis.const.TEST_SPECIES.ZEB_PLAIN) >>> qreq_ = ibs.new_query_request(daid_list, daid_list) >>> nnindex_cfgstr = build_nnindex_cfgstr(qreq_, daid_list) >>> verbose = True >>> nnindex_cfgstr = build_nnindex_cfgstr(qreq_, daid_list) >>> cfgstr = nnindex_cfgstr >>> cachedir = qreq_.ibs.get_flann_cachedir() >>> flann_params = qreq_.qparams.flann_params >>> # Get annot descriptors to index >>> vecs_list, fgws_list = get_support_data(qreq_, daid_list) >>> nnindexer = new_neighbor_index(daid_list, vecs_list, fgws_list, flann_params, cachedir, cfgstr, verbose=True) >>> result = ('nnindexer.ax2_aid = %s' % (str(nnindexer.ax2_aid),)) >>> print(result) nnindexer.ax2_aid = [1 2 3 4 5 6] """ nnindexer = NeighborIndex(flann_params, cfgstr) #if memtrack is not None: # memtrack.report('CREATEED NEIGHTOB INDEX') # Initialize neighbor with unindexed data nnindexer.init_support(daid_list, vecs_list, fgws_list, verbose=verbose) if memtrack is not None: memtrack.report('AFTER INIT SUPPORT') # Load or build the indexing structure nnindexer.ensure_indexer(cachedir, verbose=verbose, force_rebuild=force_rebuild, memtrack=memtrack) if memtrack is not None: memtrack.report('AFTER LOAD OR BUILD') return nnindexer
def background_flann_func(cachedir, daid_list, vecs_list, fgws_list, flann_params, cfgstr, uuid_map_fpath, daids_hashid, visual_uuid_list, min_reindex_thresh): r""" FIXME: Duplicate code """ print('[BG] Starting Background FLANN') # FIXME. dont use flann cache nnindexer = NeighborIndex(flann_params, cfgstr) # Initialize neighbor with unindexed data nnindexer.init_support(daid_list, vecs_list, fgws_list, verbose=True) # Load or build the indexing structure nnindexer.ensure_indexer(cachedir, verbose=True) if len(visual_uuid_list) > min_reindex_thresh: UUID_MAP_CACHE.write_uuid_map_dict(uuid_map_fpath, visual_uuid_list, daids_hashid) print('[BG] Finished Background FLANN')
def new_neighbor_index(daid_list, vecs_list, fgws_list, fxs_list, flann_params, cachedir, cfgstr, force_rebuild=False, verbose=True, memtrack=None, prog_hook=None): r""" constructs neighbor index independent of ibeis Args: daid_list (list): vecs_list (list): fgws_list (list): flann_params (dict): flann_cachedir (None): nnindex_cfgstr (str): use_memcache (bool): Returns: nnindexer CommandLine: python -m ibeis.algo.hots.neighbor_index_cache --test-new_neighbor_index Example: >>> # ENABLE_DOCTEST >>> from ibeis.algo.hots.neighbor_index_cache import * # NOQA >>> import ibeis >>> qreq_ = ibeis.testdata_qreq_(defaultdb='testdb1', a='default:species=zebra_plains', p='default:fgw_thresh=.999') >>> daid_list = qreq_.daids >>> nnindex_cfgstr = build_nnindex_cfgstr(qreq_, daid_list) >>> ut.exec_funckw(new_neighbor_index, globals()) >>> cfgstr = nnindex_cfgstr >>> cachedir = qreq_.ibs.get_flann_cachedir() >>> flann_params = qreq_.qparams.flann_params >>> # Get annot descriptors to index >>> vecs_list, fgws_list, fxs_list = get_support_data(qreq_, daid_list) >>> nnindexer = new_neighbor_index(daid_list, vecs_list, fgws_list, fxs_list, flann_params, cachedir, cfgstr, verbose=True) >>> result = ('nnindexer.ax2_aid = %s' % (str(nnindexer.ax2_aid),)) >>> print(result) nnindexer.ax2_aid = [1 2 3 4 5 6] """ nnindexer = NeighborIndex(flann_params, cfgstr) #if memtrack is not None: # memtrack.report('CREATEED NEIGHTOB INDEX') # Initialize neighbor with unindexed data nnindexer.init_support(daid_list, vecs_list, fgws_list, fxs_list, verbose=verbose) if memtrack is not None: memtrack.report('AFTER INIT SUPPORT') # Load or build the indexing structure nnindexer.ensure_indexer(cachedir, verbose=verbose, force_rebuild=force_rebuild, memtrack=memtrack, prog_hook=prog_hook) if memtrack is not None: memtrack.report('AFTER LOAD OR BUILD') return nnindexer
def background_flann_func(cachedir, daid_list, vecs_list, fgws_list, fxs_list, flann_params, cfgstr, uuid_map_fpath, daids_hashid, visual_uuid_list, min_reindex_thresh): r""" FIXME: Duplicate code """ print('[BG] Starting Background FLANN') # FIXME. dont use flann cache nnindexer = NeighborIndex(flann_params, cfgstr) # Initialize neighbor with unindexed data nnindexer.init_support(daid_list, vecs_list, fgws_list, fxs_list, verbose=True) # Load or build the indexing structure nnindexer.ensure_indexer(cachedir, verbose=True) if len(visual_uuid_list) > min_reindex_thresh: UUID_MAP_CACHE.write_uuid_map_dict(uuid_map_fpath, visual_uuid_list, daids_hashid) print('[BG] Finished Background FLANN')