wbia.algo.detect package

Subpackages

Submodules

wbia.algo.detect.azure module

wbia.algo.detect.canonical module

Interface to Lightnet object proposals.

class wbia.algo.detect.canonical.Augmentations[source]

Bases: object

class wbia.algo.detect.canonical.ImageFilePathList(filepaths, targets=True, transform=None, target_transform=None)[source]

Bases: torch.utils.data.dataset.Dataset

class wbia.algo.detect.canonical.TrainAugmentations[source]

Bases: wbia.algo.detect.canonical.Augmentations

class wbia.algo.detect.canonical.ValidAugmentations[source]

Bases: wbia.algo.detect.canonical.Augmentations

wbia.algo.detect.canonical.finetune(model, dataloaders, optimizer, scheduler, device, num_epochs=128, under=1.0, over=1.0)[source]
wbia.algo.detect.canonical.test(gpath_list, canonical_weight_filepath=None, **kwargs)[source]
wbia.algo.detect.canonical.test_ensemble(filepath_list, weights_path_list, **kwargs)[source]
wbia.algo.detect.canonical.test_single(filepath_list, weights_path, batch_size=512)[source]
wbia.algo.detect.canonical.train(data_path, output_path, batch_size=32)[source]
wbia.algo.detect.canonical.visualize_augmentations(dataset, augmentation, tag, num=20)[source]

wbia.algo.detect.darknet module

Interface to Darknet object proposals.

wbia.algo.detect.darknet.detect(gpath_list, config_filepath, weight_filepath, class_filepath, sensitivity, verbose=False, use_gpu=True, use_gpu_id=0, **kwargs)[source]
Parameters

gpath_list (list of str) – the list of image paths that need proposal candidates

Kwargs (optional): refer to the Darknet documentation for configuration settings

Returns

iter

wbia.algo.detect.darknet.detect_gid_list(ibs, gid_list, downsample=True, verbose=False, **kwargs)[source]
Parameters
  • gid_list (list of int) – the list of IBEIS image_rowids that need detection

  • downsample (bool, optional) –

    a flag to indicate if the original image sizes should be used; defaults to True

    True: ibs.get_image_detectpaths() is used False: ibs.get_image_paths() is used

Kwargs (optional): refer to the Darknet documentation for configuration settings

Parameters
  • ibs (wbia.IBEISController) – image analysis api

  • gid_list (list of int) – the list of IBEIS image_rowids that need detection

  • downsample (bool, optional) – a flag to indicate if the original image sizes should be used; defaults to True

Kwargs:

detector, config_filepath, weights_filepath, verbose

Yields

tuple – (gid, gpath, result_list)

CommandLine:

python -m wbia.algo.detect.darknet detect_gid_list –show

Example

>>> # DISABLE_DOCTEST
>>> from wbia.algo.detect.darknet import *  # NOQA
>>> from wbia.core_images import LocalizerConfig
>>> import wbia
>>> ibs = wbia.opendb('testdb1')
>>> gid_list = ibs.get_valid_gids()
>>> config = {'verbose': True}
>>> downsample = False
>>> results_list = detect_gid_list(ibs, gid_list, downsample, **config)
>>> results_list = list(results_list)
>>> print('result lens = %r' % (map(len, list(results_list))))
>>> print('result[0] = %r' % (len(list(results_list[0][2]))))
>>> config = {'verbose': True}
>>> downsample = False
>>> results_list = detect_gid_list(ibs, gid_list, downsample, **config)
>>> results_list = list(results_list)
>>> print('result lens = %r' % (map(len, list(results_list))))
>>> print('result[0] = %r' % (len(list(results_list[0][2]))))
>>> ut.quit_if_noshow()
>>> import wbia.plottool as pt
>>> ut.show_if_requested()
Yields

results (list of dict)

wbia.algo.detect.densenet module

wbia.algo.detect.fasterrcnn module

Interface to Faster R-CNN object proposals.

wbia.algo.detect.fasterrcnn.detect(gpath_list, config_filepath, weight_filepath, class_filepath, sensitivity, verbose=False, use_gpu=True, use_gpu_id=0, **kwargs)[source]
Parameters

gpath_list (list of str) – the list of image paths that need proposal candidates

Kwargs (optional): refer to the Faster R-CNN documentation for configuration settings

Returns

iter

wbia.algo.detect.fasterrcnn.detect_gid_list(ibs, gid_list, downsample=True, verbose=False, **kwargs)[source]
Parameters
  • gid_list (list of int) – the list of IBEIS image_rowids that need detection

  • downsample (bool, optional) –

    a flag to indicate if the original image sizes should be used; defaults to True

    True: ibs.get_image_detectpaths() is used False: ibs.get_image_paths() is used

Kwargs (optional): refer to the Faster R-CNN documentation for configuration settings

Parameters
  • ibs (wbia.IBEISController) – image analysis api

  • gid_list (list of int) – the list of IBEIS image_rowids that need detection

  • downsample (bool, optional) – a flag to indicate if the original image sizes should be used; defaults to True

Kwargs:

detector, config_filepath, weights_filepath, verbose

Yields

tuple – (gid, gpath, result_list)

CommandLine:

python -m wbia.algo.detect.fasterrcnn detect_gid_list –show

Example

>>> # DISABLE_DOCTEST
>>> from wbia.algo.detect.fasterrcnn import *  # NOQA
>>> from wbia.core_images import LocalizerConfig
>>> import wbia
>>> ibs = wbia.opendb('testdb1')
>>> gid_list = ibs.get_valid_gids()
>>> config = {'verbose': True}
>>> downsample = False
>>> results_list = detect_gid_list(ibs, gid_list, downsample, **config)
>>> results_list = list(results_list)
>>> print('result lens = %r' % (map(len, list(results_list))))
>>> print('result[0] = %r' % (len(list(results_list[0][2]))))
>>> config = {'verbose': True}
>>> downsample = False
>>> results_list = detect_gid_list(ibs, gid_list, downsample, **config)
>>> results_list = list(results_list)
>>> print('result lens = %r' % (map(len, list(results_list))))
>>> print('result[0] = %r' % (len(list(results_list[0][2]))))
>>> ut.quit_if_noshow()
>>> import wbia.plottool as pt
>>> ut.show_if_requested()
Yields

results (list of dict)

wbia.algo.detect.grabmodels module

wbia.algo.detect.grabmodels.assert_models(modeldir='default', verbose=True)[source]
wbia.algo.detect.grabmodels.ensure_models(modeldir='default', verbose=True)[source]
Parameters

modeldir (str) –

CommandLine:

python -m wbia.algo.detect.grabmodels –test-ensure_models

Example

>>> # ENABLE_DOCTEST
>>> from wbia.algo.detect.grabmodels import *  # NOQA
>>> modeldir = 'default'
>>> result = ensure_models(modeldir)
>>> print(result)
wbia.algo.detect.grabmodels.get_species_trees_paths(species, modeldir='default')[source]
Parameters
  • species

  • modeldir (str) –

Returns

trees_path

Return type

?

CommandLine:

python -m wbia.algo.detect.grabmodels –test-get_species_trees_paths

Example

>>> # ENABLE_DOCTEST
>>> from wbia.algo.detect.grabmodels import *  # NOQA
>>> import wbia
>>> # build test data
>>> species = wbia.const.TEST_SPECIES.ZEB_PLAIN
>>> modeldir = 'default'
>>> # execute function
>>> trees_path = get_species_trees_paths(species, modeldir)
>>> # verify results
>>> result = str(trees_path)
>>> print(result)
wbia.algo.detect.grabmodels.iter_algo_modeldirs(modeldir='default', ensurebase=False)[source]
wbia.algo.detect.grabmodels.redownload_models(modeldir='default', verbose=True)[source]
Parameters
  • modeldir (str) – (default = ‘default’)

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

CommandLine:

python -m wbia.algo.detect.grabmodels –test-redownload_models

Example

>>> # SCRIPT
>>> from wbia.algo.detect.grabmodels import *  # NOQA
>>> result = redownload_models()

wbia.algo.detect.lightnet module

Interface to Lightnet object proposals.

wbia.algo.detect.lightnet.detect(gpath_list, config_filepath=None, weight_filepath=None, classes_filepath=None, sensitivity=0.0, verbose=False, flip=False, batch_size=192, **kwargs)[source]

Detect image filepaths with lightnet.

Parameters

gpath_list (list of str) – the list of image paths that need proposal candidates

Kwargs (optional): refer to the Lightnet documentation for configuration settings

Returns

iter

wbia.algo.detect.lightnet.detect_gid_list(ibs, gid_list, verbose=False, **kwargs)[source]

Detect gid_list with lightnet.

Parameters

gid_list (list of int) – the list of IBEIS image_rowids that need detection

Kwargs (optional): refer to the Lightnet documentation for configuration settings

Parameters
  • ibs (wbia.IBEISController) – image analysis api

  • gid_list (list of int) – the list of IBEIS image_rowids that need detection

Kwargs:

detector, config_filepath, weight_filepath, verbose

Yields

tuple – (gid, gpath, result_list)

wbia.algo.detect.orientation module

wbia.algo.detect.randomforest module

Interface to pyrf random forest object detection.

wbia.algo.detect.randomforest.detect(ibs, gpath_list, tree_path_list, **kwargs)[source]
Parameters
  • gpath_list (list of str) – the list of image paths that need detection

  • tree_path_list (list of str) – the list of trees to load for detection

Kwargs (optional): refer to the PyRF documentation for configuration settings

Returns

iter

wbia.algo.detect.randomforest.detect_gid_list(ibs, gid_list, tree_path_list, downsample=True, **kwargs)[source]
Parameters
  • gid_list (list of int) – the list of IBEIS image_rowids that need detection

  • tree_path_list (list of str) – the list of trees to load for detection

  • downsample (bool, optional) –

    a flag to indicate if the original image sizes should be used; defaults to True

    True: ibs.get_image_detectpaths() is used False: ibs.get_image_paths() is used

Kwargs (optional): refer to the PyRF documentation for configuration settings

Yields

results (list of dict)

wbia.algo.detect.randomforest.detect_gid_list_with_species(ibs, gid_list, species, downsample=True, **kwargs)[source]
Parameters
  • gid_list (list of int) – the list of IBEIS image_rowids that need detection

  • species (str) – the species that should be used to select the pre-trained random forest model

  • downsample (bool, optional) –

    a flag to indicate if the original image sizes should be used; defaults to True

    True: ibs.get_image_detectpaths() is used False: ibs.get_image_paths() is used

Kwargs (optional): refer to the PyRF documentation for configuration settings

Returns

iter

CommandLine:

python -m wbia.algo.detect.randomforest –test-detect_gid_list_with_species

Example

>>> # DISABLE_DOCTEST
>>> from wbia.algo.detect.randomforest import *  # NOQA
>>> from wbia.algo.detect.randomforest import _get_models  # NOQA
>>> import wbia
>>> # build test data
>>> ibs = wbia.opendb('testdb1')
>>> species = wbia.const.TEST_SPECIES.ZEB_PLAIN
>>> gid_list = ibs.get_valid_gids()
>>> downsample = True
>>> kwargs = {}
>>> # execute function
>>> result = detect_gid_list_with_species(ibs, gid_list, species, downsample)
>>> # verify results
>>> print(result)
wbia.algo.detect.randomforest.detect_gpath_list_with_species(ibs, gpath_list, species, **kwargs)[source]
Parameters
  • gpath_list (list of str) – the list of image paths that need detection

  • species (str) – the species that should be used to select the pre-trained random forest model

  • downsample (bool, optional) –

    a flag to indicate if the original image sizes should be used; defaults to True

    True: ibs.get_image_detectpaths() is used False: ibs.get_image_paths() is used

Kwargs (optional): refer to the PyRF documentation for configuration settings

Yields

iter

wbia.algo.detect.randomforest.train_gid_list(ibs, gid_list, trees_path=None, species=None, setup=True, teardown=False, **kwargs)[source]
Parameters
  • gid_list (list of int) – the list of IBEIS image_rowids that need detection

  • trees_path (str) – the path that the trees will be saved into (along with temporary training inventory folders that are deleted once training is finished)

  • species (str) – the species that should be used to assign to the newly trained trees

Kwargs (optional): refer to the PyRF documentation for configuration settings

Returns

None

wbia.algo.detect.randomforest.train_gpath_list(ibs, train_pos_cpath_list, train_neg_cpath_list, trees_path=None, **kwargs)[source]
Parameters
  • train_pos_cpath_list (list of str) – the list of positive image paths for training

  • train_neg_cpath_list (list of str) – the list of negative image paths for training

  • trees_path (str) – the path that the trees will be saved into (along with temporary training inventory folders that are deleted once training is finished)

  • species (str, optional) – the species that should be used to assign to the newly trained trees

Kwargs (optional): refer to the PyRF documentation for configuration settings

Returns

None

wbia.algo.detect.rf module

Interface to Darknet object proposals.

wbia.algo.detect.rf.classify(vector_list, weight_filepath, verbose=False, **kwargs)[source]
Parameters

thumbail_list (list of str) – the list of image thumbnails that need classifying

Returns

iter

wbia.algo.detect.rf.classify_helper(weight_filepath, vector_list, index_list=None, verbose=False)[source]

wbia.algo.detect.selectivesearch module

Interface to Selective Search object proposals.

wbia.algo.detect.selectivesearch.detect(gpath_list, matlab_command='selective_search', verbose=False, **kwargs)[source]
Parameters

gpath_list (list of str) – the list of image paths that need proposal candidates

Kwargs (optional): refer to the Selective Search documentation for configuration settings

Returns

iter

wbia.algo.detect.selectivesearch.detect_gid_list(ibs, gid_list, downsample=True, verbose=False, **kwargs)[source]
Parameters
  • gid_list (list of int) – the list of IBEIS image_rowids that need detection

  • downsample (bool, optional) –

    a flag to indicate if the original image sizes should be used; defaults to True

    True: ibs.get_image_detectpaths() is used False: ibs.get_image_paths() is used

Kwargs (optional): refer to the Selective Search documentation for configuration settings

Parameters
  • ibs (wbia.IBEISController) – image analysis api

  • gid_list (list of int) – the list of IBEIS image_rowids that need detection

  • downsample (bool, optional) – a flag to indicate if the original image sizes should be used; defaults to True

Kwargs:

detector, config_filepath, weights_filepath, verbose

Yields

tuple – (gid, gpath, result_list)

CommandLine:

python -m wbia.algo.detect.selectivesearch detect_gid_list –show

Example

>>> # DISABLE_DOCTEST
>>> from wbia.algo.detect.selectivesearch import *  # NOQA
>>> from wbia.core_images import LocalizerConfig
>>> import wbia
>>> ibs = wbia.opendb('testdb1')
>>> gid_list = ibs.get_valid_gids()
>>> config = {'matlab_command': 'selective_search', 'verbose': True}
>>> downsample = False
>>> results_list = detect_gid_list(ibs, gid_list, downsample, **config)
>>> results_list = list(results_list)
>>> print('result lens = %r' % (map(len, list(results_list))))
>>> print('result[0] = %r' % (len(list(results_list[0][2]))))
>>> config = {'matlab_command': 'selective_search_rcnn', 'verbose': True}
>>> downsample = False
>>> results_list = detect_gid_list(ibs, gid_list, downsample, **config)
>>> results_list = list(results_list)
>>> print('result lens = %r' % (map(len, list(results_list))))
>>> print('result[0] = %r' % (len(list(results_list[0][2]))))
>>> ut.quit_if_noshow()
>>> import wbia.plottool as pt
>>> ut.show_if_requested()
Yields

results (list of dict)

wbia.algo.detect.ssd module

Interface to SSD object proposals.

wbia.algo.detect.ssd.detect(gpath_list, config_filepath, weight_filepath, class_filepath, sensitivity, verbose=False, use_gpu=True, use_gpu_id=0, **kwargs)[source]
Parameters

gpath_list (list of str) – the list of image paths that need proposal candidates

Kwargs (optional): refer to the SSD documentation for configuration settings

Returns

iter

wbia.algo.detect.ssd.detect_gid_list(ibs, gid_list, downsample=True, verbose=False, **kwargs)[source]
Parameters
  • gid_list (list of int) – the list of IBEIS image_rowids that need detection

  • downsample (bool, optional) –

    a flag to indicate if the original image sizes should be used; defaults to True

    True: ibs.get_image_detectpaths() is used False: ibs.get_image_paths() is used

Kwargs (optional): refer to the SSD documentation for configuration settings

Parameters
  • ibs (wbia.IBEISController) – image analysis api

  • gid_list (list of int) – the list of IBEIS image_rowids that need detection

  • downsample (bool, optional) – a flag to indicate if the original image sizes should be used; defaults to True

Kwargs:

detector, config_filepath, weights_filepath, verbose

Yields

tuple – (gid, gpath, result_list)

CommandLine:

python -m wbia.algo.detect.ssd detect_gid_list –show

Example

>>> # DISABLE_DOCTEST
>>> from wbia.algo.detect.ssd import *  # NOQA
>>> from wbia.core_images import LocalizerConfig
>>> import wbia
>>> ibs = wbia.opendb('testdb1')
>>> gid_list = ibs.get_valid_gids()
>>> config = {'verbose': True}
>>> downsample = False
>>> results_list = detect_gid_list(ibs, gid_list, downsample, **config)
>>> results_list = list(results_list)
>>> print('result lens = %r' % (map(len, list(results_list))))
>>> print('result[0] = %r' % (len(list(results_list[0][2]))))
>>> config = {'verbose': True}
>>> downsample = False
>>> results_list = detect_gid_list(ibs, gid_list, downsample, **config)
>>> results_list = list(results_list)
>>> print('result lens = %r' % (map(len, list(results_list))))
>>> print('result[0] = %r' % (len(list(results_list[0][2]))))
>>> ut.quit_if_noshow()
>>> import wbia.plottool as pt
>>> ut.show_if_requested()
Yields

results (list of dict)

wbia.algo.detect.svm module

Interface to Darknet object proposals.

wbia.algo.detect.svm.classify(vector_list, weight_filepath, verbose=False, **kwargs)[source]
Parameters

thumbail_list (list of str) – the list of image thumbnails that need classifying

Returns

iter

wbia.algo.detect.svm.classify_helper(weight_filepath, vector_list, index_list=None, verbose=False)[source]

wbia.algo.detect.yolo module

Interface to pydarknet yolo object detection.

wbia.algo.detect.yolo.detect(gpath_list, detector=None, config_filepath=None, weights_filepath=None, **kwargs)[source]
Parameters

gpath_list (list of str) – the list of image paths that need detection

Kwargs (optional): refer to the PyDarknet documentation for configuration settings

Returns

iter

Example

>>> # DISABLE_DOCTEST
>>> from wbia.algo.detect.yolo import *  # NOQA
>>> from wbia.core_images import LocalizerConfig
>>> import wbia
>>> ibs = wbia.opendb(defaultdb='WS_ALL')
>>> gid_list = ibs.images()._rowids[0:1]
>>> gpath_list = ibs.get_image_paths(gid_list)
>>> dpath = '/media/raid/work/WS_ALL/localizer_backup/'
>>> weights_filepath = join(dpath, 'detect.yolo.2.39000.weights')
>>> config_filepath = join(dpath, 'detect.yolo.2.cfg')
>>> config = LocalizerConfig(
>>>     weights_filepath=weights_filepath,
>>>     config_filepath=config_filepath,
>>> )
>>> kwargs = config.asdict()
>>> ut.delete_dict_keys(kwargs, ['weights_filepath', 'config_filepath'])
>>> ut.delete_dict_keys(kwargs, ['thumbnail_cfg', 'species', 'algo'])
wbia.algo.detect.yolo.detect_gid_list(ibs, gid_list, downsample=False, **kwargs)[source]
Parameters
  • gid_list (list of int) – the list of IBEIS image_rowids that need detection

  • downsample (bool, optional) –

    a flag to indicate if the original image sizes should be used; defaults to True

    True: ibs.get_image_detectpaths() is used False: ibs.get_image_paths() is used

Kwargs (optional): refer to the PyDarknet documentation for configuration settings

Parameters
  • ibs (wbia.IBEISController) – image analysis api

  • gid_list (list of int) – the list of IBEIS image_rowids that need detection

  • downsample (bool, optional) – a flag to indicate if the original image sizes should be used; defaults to True

Kwargs:

detector, config_filepath, weights_filepath, verbose

Yields

tuple – (gid, gpath, result_list)

CommandLine:

python -m wbia.algo.detect.yolo detect_gid_list –show

Example

>>> # DISABLE_DOCTEST
>>> from wbia.algo.detect.yolo import *  # NOQA
>>> from wbia.core_images import LocalizerConfig
>>> import wbia
>>> ibs = wbia.opendb(defaultdb='WS_ALL')
>>> gid_list = ibs.images()._rowids[0:1]
>>> kwargs = config = LocalizerConfig(**{
>>>     'weights_filepath': '/media/raid/work/WS_ALL/localizer_backup/detect.yolo.2.39000.weights',
>>>     'config_filepath': '/media/raid/work/WS_ALL/localizer_backup/detect.yolo.2.cfg',
>>> })
>>> exec(ut.execstr_dict(config), globals())
>>> #classes_fpath = '/media/raid/work/WS_ALL/localizer_backup/detect.yolo.2.cfg.classes'
>>> downsample = False
>>> (gid, gpath, result_list) = detect_gid_list(ibs, gid_list, downsample, **config)
>>> result = ('(gid, gpath, result_list) = %s' % (ut.repr2((gid, gpath, result_list)),))
>>> print(result)
>>> ut.quit_if_noshow()
>>> import wbia.plottool as pt
>>> ut.show_if_requested()
Yields

results (list of dict)

Module contents

wbia.algo.detect.IMPORT_TUPLES = [('grabmodels', None), ('randomforest', None), ('yolo', None), ('assigner', None)]

Regen Command: cd /Users/bluemellophone/code/wbia/wbia/algo/detect makeinit.py –modname=wbia.algo.detect

wbia.algo.detect.reassign_submodule_attributes(verbose=True)[source]

why reloading all the modules doesnt do this I don’t know

wbia.algo.detect.reload_subs(verbose=True)[source]

Reloads wbia.algo.detect and submodules

wbia.algo.detect.rrrr(verbose=True)

Reloads wbia.algo.detect and submodules