wbia.init package

Submodules

wbia.init.filter_annots module

Todo

  • cross validation

  • encounter vs database (time filtering)

wbia.init.filter_annots.annot_crossval(ibs, aid_list, n_qaids_per_name=1, n_daids_per_name=1, rng=None, debug=True, n_splits=None, confusors=True)[source]

Stratified sampling per name size

Parameters

n_splits (int) – number of query/database splits to create. note, some names may not be big enough to split this many times.

CommandLine:

python -m wbia.init.filter_annots annot_crossval

Example

>>> # ENABLE_DOCTEST
>>> from wbia.init.filter_annots import *  # NOQA
>>> import wbia
>>> ibs = wbia.opendb(defaultdb='PZ_MTEST')
>>> aid_list = ibs.get_valid_aids()
>>> n_qaids_per_name = 2
>>> n_daids_per_name = 3
>>> rng = 0
>>> debug = True
>>> n_splits = None
>>> expanded_aids_list = annot_crossval(
>>>     ibs, aid_list, n_qaids_per_name, n_daids_per_name, rng, debug,
>>>     n_splits, confusors=False)
>>> result = ('expanded_aids_list = %s' % (ut.repr2(expanded_aids_list, nl=2),))
>>> print(result)
wbia.init.filter_annots.crossval_helper(nid_to_sample_pool, perquery, perdatab, n_need, n_splits=None, rng=None, rebalance=True)[source]

does sampling based on some grouping (or no grouping) of annots

perquery = 2 perdatab = 2

nid_to_sample_pool = {

1: [1, 2, 3, 4], 2: [6, 7, 8, 9],

}

wbia.init.filter_annots.encounter_crossval(ibs, aids, qenc_per_name=1, denc_per_name=1, enc_labels=None, confusors=True, rng=None, annots_per_enc=None, rebalance=True, n_splits=None, early=False)[source]

Constructs a list of [ (qaids, daids) ] where there are qenc_per_name and denc_per_name for each individual in the datasets respectively. enc_labels specifies custom encounter labels.

CommandLine:

python -m wbia.init.filter_annots encounter_crossval

Example

>>> # ENABLE_DOCTEST
>>> from wbia.init.filter_annots import *  # NOQA
>>> from wbia.init import main_helpers
>>> import wbia
>>> #ibs, aids = wbia.testdata_aids(
>>> #    defaultdb='WWF_Lynx_Copy',
>>> #    a='default:minqual=good,require_timestamp=True,view=left')
>>> ibs, aids = wbia.testdata_aids(defaultdb='PZ_MTEST',
>>>                                 a='default:require_timestamp=True')
>>> main_helpers.monkeypatch_encounters(ibs, aids, days=50)
>>> qenc_per_name = 2
>>> denc_per_name = 2
>>> confusors = False
>>> print('denc_per_name = %r' % (denc_per_name,))
>>> print('qenc_per_name = %r' % (qenc_per_name,))
>>> rng = 0
>>> n_splits = 5
>>> expanded_aids = encounter_crossval(ibs, aids, n_splits=n_splits,
>>>                                    qenc_per_name=qenc_per_name,
>>>                                    denc_per_name=denc_per_name,
>>>                                    confusors=confusors, rng=rng)
>>> # ensure stats agree
>>> cfgargs = dict(per_vp=False, per_multiple=False, combo_dists=False,
>>>                per_name=False, per_enc=True, use_hist=False)
>>> for qaids, daids in expanded_aids:
>>>     stats = ibs.get_annotconfig_stats(qaids, daids, **cfgargs)
>>>     del stats['confusor_daid_stats']
>>>     print(ut.repr2(stats, strvals=True, strkeys=True, nl=2))
>>>     denc_stats = stats['matchable_daid_stats']['denc_per_name']
>>>     qenc_stats = stats['qaid_stats']['qenc_per_name']
>>>     assert denc_stats['min'] == denc_stats['max']
>>>     assert denc_stats['min'] == denc_per_name
>>>     assert qenc_stats['min'] == qenc_stats['max']
>>>     assert qenc_stats['min'] == qenc_per_name
>>> # Restore state
>>> main_helpers.unmonkeypatch_encounters(ibs)
>>> #qaids, daids = expanded_aids[0]
>>> #stats = ibs.get_annotconfig_stats(qaids, daids, use_hist=True)
>>> #print(ut.repr2(stats, strvals=True, strkeys=True, nl=2))
wbia.init.filter_annots.ensure_flatiterable(input_)[source]
wbia.init.filter_annots.ensure_flatlistlike(input_)[source]
wbia.init.filter_annots.expand_acfgs(ibs, aidcfg, verbose=None, use_cache=None, hack_exclude_keys=None, initial_aids=None, save_cache=True)[source]

Main multi-expansion function. Expands an annot config dict into qaids and daids. New version of this function based on a configuration dictionary built from command line argumetns

Parameters
  • ibs (IBEISController) – wbia controller object

  • aidcfg (dict) – configuration of the annotation filter

  • verbose (bool) – verbosity flag(default = False)

  • use_cache (bool) – turns on disk based caching(default = None)

  • hack_exclude_keys (None) – (default = None)

  • initial_aids (None) – (default = None)

Returns

expanded_aids=(qaid_list, daid_list) - expanded list of aids

that meet the criteria of the aidcfg filter

Return type

tuple

Todo

The database should be created first in most circumstances, then the queries should be filtered to meet the database restrictions? I’m not sure Sometimes you need to set the query aids constant, but sometimes you need to set the data aids constant. Seems to depend.

This function very much needs the idea of filter chains

OkNewIdea:
3 filters:
  • Common sampling - takes care of things like min time delta,

  • species, quality viewpoint etc.

  • query sampling

  • database sampling

Basic idea is
  • Sample large pool

  • Partition pool into query and database

Requires:
  • base sampling params

  • partition1 params

  • partition2 params

  • inter partition params?

CommandLine:

python -m wbia.dev -e print_acfg -a timectrl:qsize=10,dsize=10 –db PZ_MTEST –veryverbtd –nocache-aid python -m wbia.dev -e print_acfg -a timectrl:qminqual=good,qsize=10,dsize=10 –db PZ_MTEST –veryverbtd –nocache-aid

python -m wbia.dev -e print_acfg -a timectrl –db PZ_MTEST –verbtd –nocache-aid python -m wbia.dev -e print_acfg -a timectrl –db PZ_Master1 –verbtd –nocache-aid python -m wbia.dev -e print_acfg -a timequalctrl –db PZ_Master1 –verbtd –nocache-aid

python -m wbia.dev -e rank_cmc -a controlled:qsize=10,dsize=10,dper_name=2 -t default –db PZ_MTEST python -m wbia.dev -e rank_cmc -a controlled:qsize=10,dsize=20,dper_name=2 -t default –db PZ_MTEST python -m wbia.dev -e print -a controlled:qsize=10,dsize=10 -t default –db PZ_MTEST –verbtd –nocache-aid

python -m wbia.dev -e latexsum -t candinvar -a viewpoint_compare –db NNP_Master3 –acfginfo utprof.py -m wbia.dev -e print -t candk -a varysize –db PZ_MTEST –acfginfo utprof.py -m wbia.dev -e latexsum -t candk -a controlled –db PZ_Master0 –acfginfo

python -m wbia –tf get_annotcfg_list:0 –db NNP_Master3 -a viewpoint_compare –nocache-aid –verbtd

python -m wbia –tf get_annotcfg_list –db PZ_Master1

-a timectrl:qhas_any=(needswork,correctable,mildviewpoint),qhas_none=(viewpoint,photobomb,error:viewpoint,quality) –acfginfo –veryverbtd –veryverbtd

python -m wbia –tf draw_rank_cmc –db PZ_Master1 –show -t best

-a timectrl:qhas_any=(needswork,correctable,mildviewpoint),qhas_none=(viewpoint,photobomb,error:viewpoint,quality) –acfginfo –veryverbtd

python -m wbia –tf get_annotcfg_list –db Oxford -a default:qhas_any=(query,),dpername=2,exclude_reference=True –acfginfo –verbtd –veryverbtd –nocache-aid

CommandLine:

python -m wbia.init.filter_annots –exec-expand_acfgs –show

Example

>>> # ENABLE_DOCTEST
>>> from wbia.init.filter_annots import *  # NOQA
>>> import wbia
>>> from wbia.expt import annotation_configs
>>> ibs = wbia.opendb(defaultdb='testdb1')
>>> aidcfg = copy.deepcopy(annotation_configs.default)
>>> aidcfg['qcfg']['species'] = 'primary'
>>> initial_aids = None
>>> expanded_aids = expand_acfgs(ibs, aidcfg, initial_aids=initial_aids)
>>> result = ut.repr3(expanded_aids, nl=1, nobr=True)
>>> print(result)
[1, 2, 3, 4, 5, 6],
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13],
wbia.init.filter_annots.expand_acfgs_consistently(ibs, acfg_combo, initial_aids=None, use_cache=None, verbose=None, base=0)[source]

Expands a set of configurations such that they are comparable

CommandLine:
python -m wbia –tf parse_acfg_combo_list

-a varysize

wbia –tf get_annotcfg_list –db PZ_Master1 -a varysize #wbia –tf get_annotcfg_list –db lynx -a default:hack_imageset=True wbia –tf get_annotcfg_list –db PZ_Master1 -a varysize:qsize=None wbia –tf get_annotcfg_list –db PZ_Master0 –nofilter-dups -a varysize wbia –tf get_annotcfg_list –db PZ_MTEST -a varysize –nofilter-dups wbia –tf get_annotcfg_list –db PZ_Master0 –verbtd

–nofilter-dups -a varysize

wbia –tf get_annotcfg_list –db PZ_Master1 -a viewpoint_compare

–verbtd –nofilter-dups

wbia –tf get_annotcfg_list -a timectrl –db GZ_Master1 –verbtd

–nofilter-dups

Example

>>> # ENABLE_DOCTEST
>>> from wbia.init.filter_annots import *  # NOQA
>>> from wbia.init import main_helpers
>>> from wbia.expt import annotation_configs
>>> from wbia.expt.experiment_helpers import parse_acfg_combo_list
>>> import wbia
>>> ibs = wbia.opendb('PZ_MTEST')
>>> #acfg_name_list = ['timectrl:dpername=[1,2]']
>>> acfg_name_list = ['default:crossval_enc=True,require_timestamp=True']
>>> aids = ibs.get_valid_aids()
>>> main_helpers.monkeypatch_encounters(ibs, aids, days=50)
>>> acfg_combo_list = parse_acfg_combo_list(acfg_name_list)
>>> acfg_combo = acfg_combo_list[0]
>>> initial_aids = None
>>> use_cache = False
>>> verbose = False
>>> expanded_aids_combo_list = expand_acfgs_consistently(
>>>     ibs, acfg_combo, initial_aids=initial_aids, use_cache=use_cache,
>>>     verbose=verbose)
>>> # Restore state
>>> main_helpers.unmonkeypatch_encounters(ibs)
>>> ut.assert_eq(len(expanded_aids_combo_list), 5)
wbia.init.filter_annots.expand_single_acfg(ibs, aidcfg, verbose=None)[source]

for main_helpers

wbia.init.filter_annots.expand_species(ibs, species, avail_aids=None)[source]
wbia.init.filter_annots.filter_annots_general(ibs, aid_list=None, filter_kw={}, verbose=False, **kwargs)[source]
Parameters
  • ibs (IBEISController) – wbia controller object

  • aid_list (list) – list of annotation rowids

  • filter_kw

Kwargs:

has_none_annotmatch, any_match_annotmatch, has_all, is_known, any_match_annot, logic_annot, none_match_annotmatch, max_num_annotmatch, any_startswith_annot, has_any, require_quality, species, any_match, view_ext, has_any_annotmatch, view_pername, max_num_annot, min_timedelta, any_startswith, max_numfeat, any_startswith_annotmatch, been_adjusted, any_endswith_annot, require_viewpoint, logic, has_any_annot, min_num_annotmatch, min_num, min_num_annot, has_all_annot, has_none, min_pername, any_endswith_annotmatch, any_endswith, require_timestamp, none_match, contributor_contains, has_all_annotmatch, logic_annotmatch, min_numfeat, none_match_annot, view_ext1, view_ext2, max_num, has_none_annot, minqual, view

CommandLine:

python -m wbia –tf filter_annots_general python -m wbia –tf filter_annots_general –db PZ_Master1

–has_any=[needswork,correctable,mildviewpoint] –has_none=[viewpoint,photobomb,error:viewpoint,quality] –show

python -m wbia –tf filter_annots_general –db=GZ_Master1

–max-numfeat=300 –show –minqual=junk –species=None

python -m wbia –tf filter_annots_general –db=lynx

–been_adjusted=True

Example

>>> # DISABLE_DOCTEST
>>> from wbia.init.filter_annots import *  # NOQA
>>> import wbia
>>> filter_kw = ut.argparse_dict(get_default_annot_filter_form(),
>>>                              type_hint=ut.ddict(list, has_any=list,
>>>                                                 has_none=list,
>>>                                                 logic=str))
>>> print('filter_kw = %s' % (ut.repr2(filter_kw),))
>>> ibs = wbia.opendb(defaultdb='testdb1')
>>> aid_list = ibs.get_valid_aids()
>>> #filter_kw = dict(is_known=True, min_num=1, has_any='viewpoint')
>>> #filter_kw = dict(is_known=True, min_num=1, any_match='.*error.*')
>>> aid_list_ = filter_annots_general(ibs, aid_list, filter_kw)
>>> print('len(aid_list_) = %r' % (len(aid_list_),))
>>> all_tags = ut.flatten(ibs.get_annot_all_tags(aid_list_))
>>> filtered_tag_hist = ut.dict_hist(all_tags)
>>> ut.print_dict(filtered_tag_hist, key_order_metric='val')
>>> ut.print_dict(ibs.get_annot_stats_dict(aid_list_), 'annot_stats')
>>> ut.quit_if_noshow()
>>> import wbia.viz.interact
>>> wbia.viz.interact.interact_chip.interact_multichips(ibs, aid_list_)
>>> ut.show_if_requested()
wbia.init.filter_annots.filter_annots_independent(ibs, avail_aids, aidcfg, prefix='', verbose=False, withpre=False)[source]

Filtering that doesn’t have to do with a reference set of aids

TODO make filterflags version

Parameters
  • ibs (IBEISController) – wbia controller object

  • avail_aids (list) –

  • aidcfg (dict) –

  • prefix (str) – (default = ‘’)

  • verbose (bool) – verbosity flag(default = False)

Returns

avail_aids

Return type

list

CommandLine:

python -m wbia –tf filter_annots_independent –veryverbtd

Example

>>> # DISABLE_DOCTEST
>>> from wbia.init.filter_annots import *  # NOQA
>>> import wbia
>>> from wbia.expt import annotation_configs
>>> ibs = wbia.opendb(defaultdb='PZ_MTEST')
>>> avail_aids = input_aids = ibs.get_valid_aids()
>>> aidcfg = annotation_configs.default['dcfg']
>>> aidcfg['require_timestamp'] = True
>>> aidcfg['require_quality'] = False
>>> aidcfg['is_known'] = True
>>> prefix = ''
>>> verbose = True
>>> avail_aids = filter_annots_independent(ibs, avail_aids, aidcfg,
>>>                                        prefix, verbose)
>>> result = ('avail_aids = %s' % (str(avail_aids),))
>>> print(result)
Ignore:

# Testing tag features python -m wbia –tf draw_rank_cmc –db PZ_Master1 –show -t best

-a timectrl:qhas_any=(needswork,correctable,mildviewpoint),qhas_none=(viewpoint,photobomb,error:viewpoint,quality) —acfginfo –veryverbtd

wbia.init.filter_annots.filter_annots_intragroup(ibs, avail_aids, aidcfg, prefix='', verbose=False, withpre=False)[source]

This filters annots using information about the relationships between the annotations in the avail_aids group. This function is not independent and a second consecutive call may yield new results. Thus, the order in which this filter is applied matters.

CommandLine:
wbia –tf get_annotcfg_list

-a default:qsame_imageset=True,been_adjusted=True,excluderef=True –db lynx –veryverbtd –nocache-aid

Ignore:
>>> aidcfg['min_timedelta'] = 60 * 60 * 24
>>> aidcfg['min_pername'] = 3
wbia.init.filter_annots.filterannots_by_tags(ibs, aid_list, filter_kw)[source]
Parameters
  • ibs (IBEISController) – wbia controller object

  • aid_list (list) – list of annotation rowids

CommandLine:

python -m wbia –tf filterannots_by_tags utprof.py -m wbia –tf filterannots_by_tags

SeeAlso:

filter_annotmatch_by_tags

Example

>>> # DISABLE_DOCTEST
>>> from wbia.init.filter_annots import *  # NOQA
>>> import wbia
>>> ibs = wbia.opendb(defaultdb='PZ_Master1')
>>> aid_list = ibs.get_valid_aids()
>>> has_any = ut.get_argval('--tags', type_=list,
>>>                         default=['SceneryMatch', 'Photobomb'])
>>> min_num = ut.get_argval('--min_num', type_=int, default=1)
>>> filter_kw = dict(has_any=has_any, min_num=1)
>>> aid_list_ = filterannots_by_tags(ibs, aid_list, filter_kw)
>>> print('aid_list_ = %r' % (aid_list_,))
>>> ut.quit_if_noshow()
>>> pass
>>> # TODO: show special annot group in GUI
wbia.init.filter_annots.get_acfg_cacheinfo(ibs, aidcfg)[source]

Returns location and name of the ~~annot~~ data cache

wbia.init.filter_annots.get_annot_tag_filterflags(ibs, aid_list, filter_kw, request_defaultkw=False)[source]

Filters annotations by tags including those that is belongs to in a pair

wbia.init.filter_annots.get_default_annot_filter_form()[source]

Returns dictionary containing defaults for all valid filter parameters

CommandLine:

python -m wbia –tf get_default_annot_filter_form

Example

>>> # ENABLE_DOCTEST
>>> from wbia.init.filter_annots import *  # NOQA
>>> filter_kw = get_default_annot_filter_form()
>>> print(ut.repr2(filter_kw, align=True))
>>> print(', '.join(filter_kw.keys()))
wbia.init.filter_annots.get_reference_preference_order(ibs, gt_ref_grouped_aids, gt_avl_grouped_aids, prop_getter, cmp_func, aggfn, rng, verbose=False)[source]

Orders preference for sampling based on some metric

wbia.init.filter_annots.hack_extra(ibs, expanded_aids)[source]
wbia.init.filter_annots.hack_remove_label_errors(ibs, expanded_aids, verbose=None)[source]
wbia.init.filter_annots.multi_sampled_seaturtle_queries()[source]
wbia.init.filter_annots.sample_annots(ibs, avail_aids, aidcfg, prefix='', verbose=False)[source]

Sampling preserves input sample structure and thust does not always return exact values

CommandLine:

python -m wbia –tf sample_annots –veryverbtd

python -m wbia –tf get_annotcfg_list –db seaturtles

-a default:qhas_any=(left,right),sample_occur=True,exclude_reference=True,sample_offset=0,num_names=1 –acfginfo

Example

>>> # DISABLE_DOCTEST
>>> from wbia.init.filter_annots import *  # NOQA
>>> import wbia
>>> from wbia.expt import annotation_configs
>>> ibs = wbia.opendb(defaultdb='PZ_MTEST')
>>> avail_aids = input_aids = ibs.get_valid_aids()
>>> aidcfg = copy.deepcopy(annotation_configs.default['dcfg'])
>>> aidcfg['sample_per_name'] = 3
>>> aidcfg['sample_size'] = 10
>>> aidcfg['min_pername'] = 2
>>> prefix = ''
>>> verbose = True
>>> avail_aids = filter_annots_independent(ibs, avail_aids, aidcfg,
>>>                                        prefix, verbose)
>>> avail_aids = sample_annots(ibs, avail_aids, aidcfg,
>>>                            prefix, avail_aids)
>>> result = ('avail_aids = %s' % (str(avail_aids),))
>>> print(result)

Example

>>> # DISABLE_DOCTEST
>>> from wbia.init.filter_annots import *  # NOQA
>>> import wbia
>>> from wbia.expt import annotation_configs
>>> db = 'seaturtles'  # 'testdb1'
>>> ibs = wbia.opendb(defaultdb=db)
>>> aidcfg = copy.deepcopy(annotation_configs.default)['qcfg']
>>> aidcfg['sample_occur'] = True
>>> initial_aids = ibs.get_valid_aids()
>>> withpre, verbose, prefix = True, 2, ''
>>> avail_aids = filter_annots_independent(
>>>     ibs, initial_aids, {'has_any': ['left', 'right']}, prefix, verbose)
>>> qaids = sample_annots(ibs, avail_aids, aidcfg, prefix, verbose)
>>> avail_aids = initial_aids
>>> ref_aids = qaids
>>> dcfg = dict(exclude_reference=True, sample_occur=True)
>>> daids = sample_annots_wrt_ref(ibs, initial_aids, dcfg, qaids, prefix, verbose)
>>> ibs.print_annotconfig_stats(qaids, daids, enc_per_name=True, per_enc=True)
wbia.init.filter_annots.sample_annots_general(ibs, aid_list=None, filter_kw={}, verbose=False, **kwargs)[source]

filter + sampling

wbia.init.filter_annots.sample_annots_wrt_ref(ibs, avail_aids, aidcfg, ref_aids, prefix='', verbose=False)[source]

Sampling when a reference set is given

wbia.init.filter_annots.subindex_annots(ibs, avail_aids, aidcfg, ref_aids=None, prefix='', verbose=False)[source]

Returns exact subindex of annotations

wbia.init.filter_annots.time_filter_annots()[source]
python -m wbia.init.filter_annots time_filter_annots

–db PZ_Master1 -a ctrl:qmingt=2 –profile

Example

>>> # DISABLE_DOCTEST
>>> from wbia.init.filter_annots import *  # NOQA
>>> result = time_filter_annots()
wbia.init.filter_annots.verb_context(filtertype, aidcfg, verbose)[source]

closure helper

wbia.init.main_commands module

wbia.init.main_helpers module

This module defines helper functions to access common input needed to test many functions. These functions give a rich command line interface to specifically select subsets of annotations, pipeline configurations, and other filters.

TODO: standardize function signatures

wbia.init.main_helpers.monkeypatch_encounters(ibs, aids, cache=None, **kwargs)[source]

Hacks in a temporary custom definition of encounters for this controller

50 days for PZ_MTEST kwargs = dict(days=50)

if False:

name_mindeltas = [] for name in annots.group_items(annots.nids).values():

times = name.image_unixtimes_asfloat deltas = [ut.unixtime_to_timedelta(np.abs(t1 - t2))

for t1, t2 in ut.combinations(times, 2)]

if deltas:

name_mindeltas.append(min(deltas))

logger.info(ut.repr3(ut.lmap(ut.get_timedelta_str,

sorted(name_mindeltas))))

wbia.init.main_helpers.testdata_aids(defaultdb=None, a=None, adefault='default', ibs=None, return_acfg=False, verbose=None, default_aids=None, default_set='qcfg')[source]

Grabs default testdata for functions, but is command line overrideable

CommandLine:

python -m wbia testdata_aids –verbtd –db PZ_ViewPoints python -m wbia testdata_aids –verbtd –db NNP_Master3 -a is_known=True,view_pername=’#primary>0&#primary1>=1’ python -m wbia testdata_aids –verbtd –db PZ_Master1 -a default:is_known=True,view_pername=’#primary>0&#primary1>=1’ python -m wbia testdata_aids –verbtd –db PZ_Master1 -a default:species=primary,minqual=ok –verbtd python -m wbia.other.dbinfo –test-latex_dbstats –dblist python -m wbia testdata_aids –show

Example

>>> # ENABLE_DOCTEST
>>> from wbia.init.main_helpers import *  # NOQA
>>> from wbia.expt import annotation_configs
>>> import wbia
>>> #ibs = wbia.opendb(defaultdb='PZ_ViewPoints')
>>> ibs = wbia.opendb(defaultdb='testdb1')
>>> a = None
>>> adefault = 'default:is_known=True'
>>> aids, aidcfg = testdata_aids(ibs=ibs, a=a, adefault=adefault, return_acfg=True)
>>> print('\n RESULT:')
>>> annotation_configs.print_acfg(aidcfg, aids, ibs, per_name_vpedge=None)
wbia.init.main_helpers.testdata_cm(defaultdb=None, default_qaids=None, default_daids=None, t=None, p=None, a=None)[source]
CommandLine:

python -m wbia.init.main_helpers –test-testdata_cm python -m wbia.init.main_helpers –test-testdata_cm –show

Example

>>> # ENABLE_DOCTEST
>>> from wbia.init.main_helpers import *  # NOQA
>>> cm, qreq_ = testdata_cm()
>>> cm.print_csv(ibs=qreq_.ibs)
>>> ut.quit_if_noshow()
>>> cm.show_single_annotmatch(qreq_, 2)
>>> ut.show_if_requested()
wbia.init.main_helpers.testdata_cmlist(defaultdb=None, default_qaids=None, default_daids=None, t=None, p=None, a=None, verbose=None)[source]
Returns

cm_list, qreq_

Return type

list, wbia.QueryRequest

wbia.init.main_helpers.testdata_expanded_aids(defaultdb=None, a=None, ibs=None, default_qaids=None, default_daids=None, qaid_override=None, daid_override=None, return_annot_info=False, verbose=None, use_cache=None)[source]
Parameters
  • default_qaids (list) – (default = [1])

  • default_daids (str) – (default = ‘all’)

  • defaultdb (str) – (default = ‘testdb1’)

  • ibs (IBEISController) – wbia controller object(default = None)

  • verbose (bool) – verbosity flag(default = False)

  • return_annot_info (bool) – (default = False)

Returns

Return type

ibs, qaid_list, daid_list, annot_info

CommandLine:

python -m wbia.init.main_helpers testdata_expanded_aids python -m wbia.init.main_helpers testdata_expanded_aids –db PZ_MTEST –acfg default:index=0:25 –verbose-testdata python -m wbia.init.main_helpers testdata_expanded_aids –db PZ_MTEST –qaid 3 python -m wbia.init.main_helpers testdata_expanded_aids –db GZ_ALL –acfg ctrl –verbose-testdata

Example

>>> # ENABLE_DOCTEST
>>> from wbia.init.main_helpers import *  # NOQA
>>> import wbia
>>> from wbia.expt import annotation_configs
>>> ibs, qaid_list, daid_list, aidcfg = testdata_expanded_aids(return_annot_info=True)
>>> print('Printing annot config')
>>> annotation_configs.print_acfg(aidcfg)
>>> print('Printing annotconfig stats')
>>> ibs.print_annotconfig_stats(qaid_list, daid_list)
>>> print('Combined annotconfig stats')
>>> ibs.print_annot_stats(qaid_list + daid_list, viewcode_isect=True)
>>> print('qaid_list = %r' % (qaid_list,))
wbia.init.main_helpers.testdata_expts(defaultdb='testdb1', default_acfgstr_name_list=['default:qindex=0:10:4,dindex=0:20'], default_test_cfg_name_list=['default'], a=None, t=None, p=None, qaid_override=None, daid_override=None, initial_aids=None, use_cache=None, dbdir=None, ibs=None)[source]

Use this if you want data from an experiment. Command line interface to quickly get testdata for test_results.

Command line flags can be used to specify db, aidcfg, pipecfg, qaid override, daid override (and maybe initial aids).

CommandLine:

python -m wbia.init.main_helpers testdata_expts

Example

>>> # DISABLE_DOCTEST
>>> from wbia.other.dbinfo import *  # NOQA
>>> import wbia
>>> ibs, testres = wbia.testdata_expts(defaultdb='pz_mtest',
>>>                                     a='timectrl:qsize=2',
>>>                                     t='invar:ai=[false],ri=false',
>>>                                     use_cache=false)
>>> print('testres = %r' % (testres,))
wbia.init.main_helpers.testdata_filtcfg(default=None)[source]
wbia.init.main_helpers.testdata_pipecfg(p=None, t=None, ibs=None, verbose=None)[source]
Returns

pcfgdict

Return type

dict

CommandLine:

python -m wbia testdata_pipecfg python -m wbia testdata_pipecfg -t default:AI=False

Ignore:

from jedi.evaluate import docstrings script = jedi.Script(ut.readfrom(main_helpers.__file__)) mod = script._get_module() func = mod.names_dict[‘testdata_pipecfg’][0].parent docstrings.find_return_types(script._evaluator, func)

Example

>>> # ENABLE_DOCTEST
>>> from wbia.init.main_helpers import *  # NOQA
>>> pcfgdict = testdata_pipecfg()
>>> result = ('pcfgdict = %s' % (ut.repr2(pcfgdict),))
>>> print(result)
wbia.init.main_helpers.testdata_qreq_(p=None, a=None, t=None, default_qaids=None, default_daids=None, custom_nid_lookup=None, verbose=None, **kwargs)[source]
Parameters
  • p (None) – (default = None)

  • a (None) – (default = None)

  • t (None) – (default = None)

  • default_qaids (None) – (default = None)

  • default_daids (None) – (default = None)

Kwargs:

defaultdb, ibs, qaid_override, daid_override, return_annot_info, verbose, use_cache

Returns

qreq_ - query request object with hyper-parameters

Return type

wbia.QueryRequest

CommandLine:

python -m wbia testdata_qreq_ –show –qaid 3

Example

>>> # ENABLE_DOCTEST
>>> from wbia.init.main_helpers import *  # NOQA
>>> kwargs = {}
>>> p = None
>>> a = None
>>> qreq_ = testdata_qreq_(p)
>>> result = ('qreq_ = %s' % (str(qreq_),))
wbia.init.main_helpers.unmonkeypatch_encounters(ibs)[source]

wbia.init.sysres module

sysres.py == system_resources Module for dealing with system resoureces in the context of IBEIS but without the need for an actual IBEIS Controller

wbia.init.sysres.copy_wbiadb(source_dbdir, dest_dbdir)[source]
wbia.init.sysres.db_to_dbdir(db, allow_newdir=False, extra_workdirs=[])[source]

Implicitly gets dbdir. Searches for db inside of workdir

wbia.init.sysres.delete_dbdir(dbname)[source]
wbia.init.sysres.ensure_db_from_url(zipped_db_url)[source]

SeeAlso wbia.init.sysres

wbia.init.sysres.ensure_nauts()[source]

Ensures that you have the NAUT_test dataset

wbia.init.sysres.ensure_pz_mtest()[source]

Ensures that you have the PZ_MTEST dataset

CommandLine:

python -m wbia.init.sysres –exec-ensure_pz_mtest python -m wbia –tf ensure_pz_mtest

Ignore:

from wbia.sysres import delete_dbdir delete_dbdir(‘PZ_MTEST’)

Example

>>> # SCRIPT
>>> from wbia.init.sysres import *  # NOQA
>>> ensure_pz_mtest()
wbia.init.sysres.ensure_pz_mtest_batchworkflow_test()[source]
CommandLine:

python -m wbia.init.sysres –test-ensure_pz_mtest_batchworkflow_test python -m wbia.init.sysres –test-ensure_pz_mtest_batchworkflow_test –reset python -m wbia.init.sysres –test-ensure_pz_mtest_batchworkflow_test –reset

Example

>>> # SCRIPT
>>> from wbia.init.sysres import *  # NOQA
>>> ensure_pz_mtest_batchworkflow_test()
wbia.init.sysres.ensure_pz_mtest_mergesplit_test()[source]

Make a test database for MERGE and SPLIT cases

CommandLine:

python -m wbia.init.sysres –test-ensure_pz_mtest_mergesplit_test

Example

>>> # SCRIPT
>>> from wbia.init.sysres import *  # NOQA
>>> ensure_pz_mtest_mergesplit_test()
wbia.init.sysres.ensure_testdb2()[source]
wbia.init.sysres.ensure_testdb_assigner()[source]
wbia.init.sysres.ensure_testdb_curvrank()[source]
wbia.init.sysres.ensure_testdb_identification_example()[source]
wbia.init.sysres.ensure_testdb_kaggle7()[source]
wbia.init.sysres.ensure_testdb_orientation()[source]
wbia.init.sysres.ensure_wd_peter2()[source]
wbia.init.sysres.ensure_wilddogs()[source]

Ensures that you have the NAUT_test dataset

wbia.init.sysres.get_args_dbdir(defaultdb=None, allow_newdir=False, db=None, dbdir=None)[source]

Machinery for finding a database directory using the following priorities. The function first defaults to the specified function arguments. If those are not specified, then command line arguments are used. In all other circumstances the defaultdb is used. If defaultdb=’cache’ then the most recently used database directory is returned.

Parameters
  • defaultdb (None) – database return if none other is specified

  • allow_newdir (bool) – raises error if True and directory not found

  • db (None) – specification using workdir priority

  • dbdir (None) – specification using normal directory priority

  • cache_priority (bool) – (default = False)

Returns

dbdir

Return type

str

CommandLine:

python -m wbia.init.sysres get_args_dbdir

Example

>>> # ENABLE_DOCTEST
>>> from wbia.init.sysres import *  # NOQA
>>> dir1 = get_args_dbdir(None, False, 'testdb1', None)
>>> print('dir1 = %r' % (dir1,))
>>> dir2 = get_args_dbdir(None, False, dir1, None)
>>> print('dir2 = %r' % (dir2,))
>>> ut.assert_raises(ValueError, get_args_dbdir)
>>> print('dir3 = %r' % (dir2,))
wbia.init.sysres.get_available_databases(workdir=None)

Lists the available valid wbia databases inside of a work directory

Parameters

workdir (None) –

Returns

ibsdb_list - wbia controller object

Return type

IBEISController

CommandLine:

python -m wbia.init.sysres –test-get_ibsdb_list

Example

>>> # ENABLE_DOCTEST
>>> from wbia.init.sysres import *  # NOQA
>>> workdir = None
>>> ibsdb_list = get_ibsdb_list(workdir)
>>> result = str('\n'.join(ibsdb_list))
>>> print(result)
wbia.init.sysres.get_dbalias_dict()[source]
wbia.init.sysres.get_default_dbdir()[source]
wbia.init.sysres.get_global_distinctiveness_modeldir(ensure=True)[source]
wbia.init.sysres.get_ibsdb_list(workdir=None)[source]

Lists the available valid wbia databases inside of a work directory

Parameters

workdir (None) –

Returns

ibsdb_list - wbia controller object

Return type

IBEISController

CommandLine:

python -m wbia.init.sysres –test-get_ibsdb_list

Example

>>> # ENABLE_DOCTEST
>>> from wbia.init.sysres import *  # NOQA
>>> workdir = None
>>> ibsdb_list = get_ibsdb_list(workdir)
>>> result = str('\n'.join(ibsdb_list))
>>> print(result)
wbia.init.sysres.get_logdir_global()[source]
wbia.init.sysres.get_rawdir()[source]

Returns the standard raw data directory

wbia.init.sysres.get_wbia_db_uri(db_dir: Optional[str] = None)[source]

Central location to acquire the database URI value.

Parameters

db_dir (str) – colloquial “dbdir” (default: None)

The db_dir argument is only to be used in testing. This function is monkeypatched by the testing environment (see wbia.conftest for that code). The monkeypatching is done because two or more instances of a controller (i.e. IBEISController) could be running in the same test. In that scenario more than one URI may need to be defined, which is not the case in production and why the body of this function is kept fairly simple. We ask the caller to supply the db_dir value in order to match up the corresponding URI.

wbia.init.sysres.get_wbia_resource_dir()[source]
wbia.init.sysres.get_workdir(allow_gui=True)[source]

Returns the work directory set for this computer. If allow_gui is true, a dialog will ask a user to specify the workdir if it does not exist.

python -c “import wbia; print(wbia.get_workdir())”

Parameters

allow_gui (bool) – (default = True)

Returns

work_dir

Return type

str

CommandLine:

python -m wbia.init.sysres get_workdir

Example

>>> # ENABLE_DOCTEST
>>> from wbia.init.sysres import *  # NOQA
>>> allow_gui = True
>>> work_dir = get_workdir(allow_gui)
>>> result = ('work_dir = %s' % (str(work_dir),))
>>> print(result)
wbia.init.sysres.guiselect_workdir()[source]

Prompts the user to specify a work directory

wbia.init.sysres.is_wbiadb(path)[source]

Checks to see if path contains the IBEIS internal dir

wbia.init.sysres.list_dbs(workdir=None)

Lists the available valid wbia databases inside of a work directory

Parameters

workdir (None) –

Returns

ibsdb_list - wbia controller object

Return type

IBEISController

CommandLine:

python -m wbia.init.sysres –test-get_ibsdb_list

Example

>>> # ENABLE_DOCTEST
>>> from wbia.init.sysres import *  # NOQA
>>> workdir = None
>>> ibsdb_list = get_ibsdb_list(workdir)
>>> result = str('\n'.join(ibsdb_list))
>>> print(result)
wbia.init.sysres.lookup_dbdir(db, allow_newdir=False, extra_workdirs=[])

Implicitly gets dbdir. Searches for db inside of workdir

wbia.init.sysres.reset_mtest_graph()[source]

Resets the annotmatch and stating table

CommandLine:

python -m wbia reset_mtest_graph

Example

>>> # SCRIPT
>>> from wbia.init.sysres import *  # NOQA
>>> reset_mtest_graph()
wbia.init.sysres.set_default_dbdir(dbdir)[source]
wbia.init.sysres.set_logdir(log_dir)[source]
wbia.init.sysres.set_workdir(work_dir=None, allow_gui=True)[source]

Sets the workdirectory for this computer

Parameters
  • work_dir (None) – (default = None)

  • allow_gui (bool) – (default = True)

CommandLine:

python -c “import wbia; wbia.sysres.set_workdir(‘/raid/work2’)” python -c “import wbia; wbia.sysres.set_workdir(‘/raid/work’)”

python -m wbia.init.sysres set_workdir

Example

>>> # SCRIPT
>>> from wbia.init.sysres import *  # NOQA
>>> print('current_work_dir = %s' % (str(get_workdir(False)),))
>>> work_dir = ut.get_argval('--workdir', type_=str, default=None)
>>> allow_gui = True
>>> result = set_workdir(work_dir, allow_gui)

Module contents