Ejemplo n.º 1
0
# -*- coding: utf-8 -*-
from __future__ import absolute_import, division, print_function
import utool as ut
import numpy as np
from six.moves import zip, map, filter, range  # NOQA
from functools import partial  # NOQA
from ibeis.control import controller_inject
print, rrr, profile = ut.inject2(__name__, '[annotmatch_funcs]')

# Create dectorator to inject functions in this module into the IBEISController
CLASS_INJECT_KEY, register_ibs_method = controller_inject.make_ibs_register_decorator(
    __name__)


def setup_pzmtest_subgraph():
    import ibeis
    ibs = ibeis.opendb(db='PZ_MTEST')
    nids = ibs.get_valid_nids()
    aids_list = ibs.get_name_aids(nids)

    import itertools
    unflat_edges = (list(itertools.product(aids, aids)) for aids in aids_list)
    aid_pairs = [tup for tup in ut.iflatten(unflat_edges) if tup[0] != tup[1]]
    aids1 = ut.get_list_column(aid_pairs, 0)
    aids2 = ut.get_list_column(aid_pairs, 1)

    rng = np.random.RandomState(0)
    flags = rng.rand(len(aids1)) > .878
    aids1 = ut.compress(aids1, flags)
    aids2 = ut.compress(aids2, flags)
Ejemplo n.º 2
0
# -*- coding: utf-8 -*-
from __future__ import absolute_import, division, print_function, unicode_literals
from PIL import Image
from os.path import splitext, basename
import warnings  # NOQA
import vtool.exif as vtexif
import utool as ut
#import numpy as np  # NOQA
#import hashlib
#import uuid
(print, rrr, profile) = ut.inject2(__name__, '[preproc_img]', DEBUG=False)


#@profile
def parse_exif(pil_img):
    """ Image EXIF helper

    Cyth::
        cdef:
            Image pil_img
            dict exif_dict
            long lat
            long lon
            long exiftime
    """
    exif_dict = vtexif.get_exif_dict(pil_img)
    # TODO: More tags
    # (mainly the orientation tag)
    lat, lon = vtexif.get_lat_lon(exif_dict)
    time = vtexif.get_unixtime(exif_dict)
    return time, lat, lon
Ejemplo n.º 3
0
# -*- coding: utf-8 -*-
# flake8: noqa
from __future__ import absolute_import, division, print_function
import utool
(print, rrr, profile) = utool.inject2(__name__, '[web]')

from ibeis.web import apis_detect
from ibeis.web import apis_engine
from ibeis.web import apis_json
from ibeis.web import apis_query
from ibeis.web import apis
from ibeis.web import app
from ibeis.web import appfuncs
from ibeis.web import routes_ajax
from ibeis.web import routes_csv
from ibeis.web import routes_submit
from ibeis.web import routes
Ejemplo n.º 4
0
# -*- coding: utf-8 -*-
"""
python -c "import utool as ut; ut.write_modscript_alias('Tgen.sh', 'ibeis.templates.template_generator')"
sh Tgen.sh --key feat --Tcfg with_setters=False with_getters=True  with_adders=True --modfname manual_feat_funcs
sh Tgen.sh --key feat --Tcfg with_deleters=True --autogen_modname manual_feat_funcs
"""
from __future__ import absolute_import, division, print_function
import six  # NOQA
from ibeis.control.accessor_decors import (getter_1to1, getter_1toM, deleter)
import utool as ut
from ibeis.control import controller_inject
print, rrr, profile = ut.inject2(__name__, '[manual_feats]')


CLASS_INJECT_KEY, register_ibs_method = controller_inject.make_ibs_register_decorator(__name__)

NEW_DEPC = True

ANNOT_ROWID   = 'annot_rowid'
CHIP_ROWID    = 'chip_rowid'
FEAT_VECS     = 'feature_vecs'
FEAT_KPTS     = 'feature_keypoints'
FEAT_NUM_FEAT = 'feature_num_feats'

CONFIG_ROWID      = 'config_rowid'
FEAT_ROWID        = 'feature_rowid'


# ----------------
# ROOT LEAF FUNCTIONS
# ----------------
Ejemplo n.º 5
0
# -*- coding: utf-8 -*-
from __future__ import absolute_import, division, print_function, unicode_literals
import six
from six.moves import zip, map
import numpy as np
import vtool as vt
import utool as ut
from ibeis.control import controller_inject
print, rrr, profile = ut.inject2(__name__, '[tag_funcs]')


# Create dectorator to inject functions in this module into the IBEISController
CLASS_INJECT_KEY, register_ibs_method = controller_inject.make_ibs_register_decorator(
    __name__)


# TODO : make a annot_tags file


ANNOTMATCH_PROPS_STANDARD = [
    #'SceneryMatch',
    #'Photobomb',
    #'Hard',
    #'NonDistinct',
]

ANNOTMATCH_PROPS_OTHER = [
    'SceneryMatch',
    'Photobomb',
    'Hard',
    'NonDistinct',
Ejemplo n.º 6
0
# -*- coding: utf-8 -*-
# Autogenerated on 13:37:34 2015/12/30
# flake8: noqa
from __future__ import absolute_import, division, print_function, unicode_literals
from ibeis.algo import Config
from ibeis.algo import detect
from ibeis.algo import hots
from ibeis.algo import preproc
import utool
print, rrr, profile = utool.inject2(__name__, '[ibeis.algo]')


def reassign_submodule_attributes(verbose=True):
    """
    why reloading all the modules doesnt do this I don't know
    """
    import sys
    if verbose and '--quiet' not in sys.argv:
        print('dev reimport')
    # Self import
    import ibeis.algo
    # Implicit reassignment.
    seen_ = set([])
    for tup in IMPORT_TUPLES:
        if len(tup) > 2 and tup[2]:
            continue  # dont import package names
        submodname, fromimports = tup[0:2]
        submod = getattr(ibeis.algo, submodname)
        for attr in dir(submod):
            if attr.startswith('_'):
                continue
Ejemplo n.º 7
0
# -*- coding: utf-8 -*-
from __future__ import absolute_import, division, print_function, unicode_literals
import networkx as netx
import six  # NOQA
import utool as ut
import numpy as np
from six.moves import zip
print, rrr, profile = ut.inject2(__name__, '[pgmext]')


def print_ascii_graph(model_):
    """
    pip install img2txt.py

    python -c
    """
    from PIL import Image
    from six.moves import StringIO
    #import networkx as netx
    import copy
    model = copy.deepcopy(model_)
    assert model is not model_
    # model.graph.setdefault('graph', {})['size'] = '".4,.4"'
    model.graph.setdefault('graph', {})['size'] = '".3,.3"'
    model.graph.setdefault('graph', {})['height'] = '".3,.3"'
    pydot_graph = netx.to_pydot(model)
    png_str = pydot_graph.create_png(prog='dot')
    sio = StringIO()
    sio.write(png_str)
    sio.seek(0)
    pil_img = Image.open(sio)
Ejemplo n.º 8
0
# -*- coding: utf-8 -*-
from __future__ import absolute_import, division, print_function, unicode_literals
import utool as ut
import six
from ibeis import _ibeis_object
from ibeis.control.controller_inject import make_ibs_register_decorator
(print, rrr, profile) = ut.inject2(__name__, '[images]')

CLASS_INJECT_KEY, register_ibs_method = make_ibs_register_decorator(__name__)

BASE_TYPE = type

try:
    from ibeis import _autogen_image_base
    IMAGE_BASE = _autogen_image_base._image_base_class
except ImportError:
    IMAGE_BASE = _ibeis_object.ObjectList1D

try:
    from ibeis import _autogen_imageset_base
    IMAGESET_BASE = _autogen_imageset_base._imageset_base_class
except ImportError:
    IMAGESET_BASE = _ibeis_object.ObjectList1D


@register_ibs_method
def images(ibs, gids=None, uuids=None, **kwargs):
    """ Makes an Images object """
    if uuids is not None:
        assert gids is None, 'specify one primary key'
        gids = ibs.get_image_gids_from_uuid(uuids)
Ejemplo n.º 9
0
guitool. Each different type of model/view has to register its iders, getters,
and potentially setters (hopefully if guitool ever gets off the ground the
delters as well)

Different columns can be hidden / shown by modifying this file

TODO: need to cache the total number of annotations or something about
imagesets on disk to help startuptime.
"""
from __future__ import absolute_import, division, print_function
from six.moves import zip, map, range
from ibeis import constants as const
import utool as ut
from functools import partial
#from ibeis.control import
(print, rrr, profile) = ut.inject2(__name__, '[headers]')

IMAGESET_TABLE = const.IMAGESET_TABLE
IMAGE_TABLE = const.IMAGE_TABLE
ANNOTATION_TABLE = const.ANNOTATION_TABLE
IMAGE_GRID = 'image_grid'
NAME_TABLE = 'names'
NAMES_TREE = 'names_tree'
QRES_TABLE = 'qres'
THUMB_TABLE = 'thumbs'

#-----------------
# Define the tables
#-----------------

Ejemplo n.º 10
0
# -*- coding: utf-8 -*-
# TODO: Need test harness to do (something smarter than) gridsearch of these guys
"""
In this file dicts specify all possible combinations of the varied parameters
and lists specify the union of parameters

Rename to pipe_cfgdef
"""
from __future__ import absolute_import, division, print_function
import utool as ut
print, rrr, profile = ut.inject2(__name__, '[cfgbank]')

ALIAS_KEYS = {
    'proot': 'pipeline_root',
    'RI': 'rotation_invariance',
    'AI': 'affine_invariance',
    #'AQH': 'augment_queryside_hack',
    'QRH': 'augment_queryside_hack',
    'SV': 'sv_on',
    #'SVxy': 'xy_thresh',
    #'SVxy': 'xy_thresh',
}


def augbase(basedict, updatedict):
    newdict = basedict.copy()
    newdict.update(updatedict)
    return newdict


def apply_param(cfg, **kwargs):
Ejemplo n.º 11
0
# -*- coding: utf-8 -*-
from __future__ import absolute_import, division, print_function, unicode_literals
import utool as ut
import plottool_ibeis as pt
from plottool_ibeis import plot_helpers as ph
from ibeis.viz import viz_helpers as vh
from ibeis.viz import viz_image
(print, rrr, profile) = ut.inject2(__name__, '[viz_chip]')


def HARDCODE_SHOW_PB_PAIR():
    """
    python -m ibeis.viz.viz_chip HARDCODE_SHOW_PB_PAIR --show

    Example:
        >>> # SCRIPT
        >>> from ibeis.viz.viz_chip import *  # NOQA
        >>> import plottool_ibeis as pt
        >>> HARDCODE_SHOW_PB_PAIR()
        >>> pt.show_if_requested()
    """
    # TODO: generalize into testdata_annotmatches which filters ams propertly
    # Then a function to show these ams
    import ibeis
    import ibeis.viz
    has_any = ut.get_argval('--has_any', default=['photobomb'])
    index = ut.get_argval('--index', default=0)

    ibs = ibeis.opendb(defaultdb='PZ_Master1')
    ams = ibs._get_all_annotmatch_rowids()
    tags = ibs.get_annotmatch_case_tags(ams)
Ejemplo n.º 12
0
# -*- coding: utf-8 -*-
from __future__ import absolute_import, division, print_function, unicode_literals
from six.moves import zip, range, map  # NOQA
import numpy as np
import vtool as vt
import utool as ut
import itertools
from ibeis.algo.hots import hstypes
from ibeis.algo.hots import _pipeline_helpers as plh  # NOQA
from collections import namedtuple
(print, rrr, profile) = ut.inject2(__name__, '[nscoring]')

NameScoreTup = namedtuple('NameScoreTup', ('sorted_nids', 'sorted_nscore',
                                           'sorted_aids', 'sorted_scores'))


def testdata_chipmatch():
    from ibeis.algo.hots import chip_match
    # only the first indicies will matter in these test
    # feature matches
    fm_list = [
        np.array([(0, 9), (1, 9), (2, 9), (3, 9)], dtype=np.int32),
        np.array([(0, 9), (1, 9), (2, 9), (3, 9)], dtype=np.int32),
        np.array([(0, 9), (1, 9), (2, 9), (3, 9)], dtype=np.int32),
        np.array([(4, 9), (5, 9), (6, 9), (3, 9)], dtype=np.int32),
        np.array([(0, 9), (1, 9), (2, 9), (3, 9), (4, 9)], dtype=np.int32)
    ]
    # score each feature match as 1
    fsv_list = [
        np.array([(1,), (1,), (1,), (1,)], dtype=hstypes.FS_DTYPE),
        np.array([(1,), (1,), (1,), (1,)], dtype=hstypes.FS_DTYPE),
Ejemplo n.º 13
0
    autogen_time = 11:34:25 2016/01/05
    autogen_key = annotmatch

ToRegenerate:
    python -m ibeis.templates.template_generator --key annotmatch --Tcfg with_web_api=False with_api_cache=False with_deleters=True no_extern_deleters=True --diff
    python -m ibeis.templates.template_generator --key annotmatch --Tcfg with_web_api=False with_api_cache=False with_deleters=True no_extern_deleters=True --write
"""
from __future__ import absolute_import, division, print_function, unicode_literals
import functools  # NOQA
import six  # NOQA
from six.moves import map, range, zip  # NOQA
from ibeis import constants as const
import utool as ut
from ibeis.control import controller_inject
from ibeis.control import accessor_decors  # NOQA
print, rrr, profile = ut.inject2(__name__, '[autogen_annotmatch]')

# Create dectorator to inject functions in this module into the IBEISController
CLASS_INJECT_KEY, register_ibs_method = controller_inject.make_ibs_register_decorator(
    __name__)

register_api = controller_inject.get_ibeis_flask_api(__name__)
register_route = controller_inject.get_ibeis_flask_route(__name__)


def testdata_annotmatch(defaultdb='testdb1'):
    import ibeis
    ibs = ibeis.opendb(defaultdb=defaultdb)
    config2_ = None  # qreq_.qparams
    #from ibeis.hots import query_config
    #config2_ = query_config.QueryParams(cfgdict=dict())
Ejemplo n.º 14
0
# -*- coding: utf-8 -*-
# Autogenerated on 15:42:03 2016/04/18
# flake8: noqa
from __future__ import absolute_import, division, print_function, unicode_literals
from ibeis.algo.detect import grabmodels
from ibeis.algo.detect import randomforest
from ibeis.algo.detect import yolo
from ibeis.algo.detect import background
from ibeis.algo.detect import classifier
from ibeis.algo.detect import labeler
from ibeis.algo.detect import orientation
import utool
print, rrr, profile = utool.inject2(__name__, '[ibeis.algo.detect]')


def reassign_submodule_attributes(verbose=True):
    """
    why reloading all the modules doesnt do this I don't know
    """
    import sys
    if verbose and '--quiet' not in sys.argv:
        print('dev reimport')
    # Self import
    import ibeis.algo.detect
    # Implicit reassignment.
    seen_ = set([])
    for tup in IMPORT_TUPLES:
        if len(tup) > 2 and tup[2]:
            continue  # dont import package names
        submodname, fromimports = tup[0:2]
        submod = getattr(ibeis.algo.detect, submodname)
Ejemplo n.º 15
0
#    }
#}
#)

from ibeis.init import main_helpers
testdata_cm = main_helpers.testdata_cm
testdata_cmlist = main_helpers.testdata_cmlist
testdata_qreq_ = main_helpers.testdata_qreq_
testdata_pipecfg = main_helpers.testdata_pipecfg
testdata_filtcfg = main_helpers.testdata_filtcfg
testdata_expts = main_helpers.testdata_expts
testdata_expanded_aids = main_helpers.testdata_expanded_aids
testdata_aids = main_helpers.testdata_aids

# Utool generated init makeinit.py
print, rrr, profile = ut.inject2(__name__, '[ibeis]')

def reload_subs(verbose=True):
    """ Reloads ibeis and submodules """
    import_subs()
    rrr(verbose=verbose)
    getattr(constants, 'rrr', lambda verbose: None)(verbose=verbose)
    getattr(ibsfuncs, 'rrr', lambda verbose: None)(verbose=verbose)
    getattr(main_module, 'rrr', lambda verbose: None)(verbose=verbose)
    getattr(params, 'rrr', lambda verbose: None)(verbose=verbose)
    getattr(other, 'reload_subs', lambda verbose: None)(verbose=verbose)
    getattr(dbio, 'reload_subs', lambda verbose: None)(verbose=verbose)
    getattr(algo, 'reload_subs', lambda verbose: None)(verbose=verbose)
    getattr(control, 'reload_subs', lambda verbose: None)(verbose=verbose)
    getattr(viz, 'reload_subs', lambda: None)()
Ejemplo n.º 16
0
# -*- coding: utf-8 -*-
"""
helpers for controller manual_annot_funcs
"""
from __future__ import absolute_import, division, print_function, unicode_literals
from six.moves import zip, range, filter, map  # NOQA
import six
import utool as ut
import uuid
from vtool import geometry
(print, rrr, profile) = ut.inject2(__name__, '[preproc_annot]')


def make_annotation_uuids(image_uuid_list, bbox_list, theta_list, deterministic=True):
    try:
        # Check to make sure bbox input is a tuple-list, not a list-list
        if len(bbox_list) > 0:
            try:
                assert isinstance(bbox_list[0], tuple), 'Bounding boxes must be tuples of ints!'
                assert isinstance(bbox_list[0][0], int), 'Bounding boxes must be tuples of ints!'
            except AssertionError as ex:
                ut.printex(ex)
                print('bbox_list = %r' % (bbox_list,))
                raise
        annotation_uuid_list = [ut.augment_uuid(img_uuid, bbox, theta)
                                for img_uuid, bbox, theta
                                in zip(image_uuid_list, bbox_list, theta_list)]
        if not deterministic:
            # Augment determenistic uuid with a random uuid to ensure randomness
            # (this should be ensured in all hardward situations)
            annotation_uuid_list = [ut.augment_uuid(ut.random_uuid(), _uuid)
Ejemplo n.º 17
0
sysres.py == system_resources
Module for dealing with system resoureces in the context of IBEIS
but without the need for an actual IBEIS Controller

"""
from __future__ import absolute_import, division, print_function
import os
from os.path import exists, join, realpath
import utool as ut
from six.moves import input, zip, map
from utool import util_cache, util_list
from ibeis import constants as const
from ibeis import params

# Inject utool functions
(print, rrr, profile) = ut.inject2(__name__, '[sysres]')

WORKDIR_CACHEID   = 'work_directory_cache_id'
DEFAULTDB_CAHCEID = 'cached_dbdir'
LOGDIR_CACHEID = ut.logdir_cacheid
__APPNAME__ = 'ibeis'


def get_ibeis_resource_dir():
    return ut.ensure_app_resource_dir('ibeis')


def _ibeis_cache_dump():
    util_cache.global_cache_dump(appname=__APPNAME__)

Ejemplo n.º 18
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Example of interfacing with IBEIS getters
First run ~/code/wbia/reset_dbs.sh to ensure you have the testdata
"""
import logging
import os
import sys
import multiprocessing
import wbia  # IBEIS module
import utool  # Useful Utility Tools

sys.path.append(os.path.expanduser('~/code/wbia'))  # Put IBEIS in PYTHONPATH  # NOQA

(print, rrr, profile) = utool.inject2(__name__)
logger = logging.getLogger('wbia')


def run_example(ibs):
    # Print IBEIS Database info
    print(ibs.get_infostr())
    ibs.print_tables()  # uncomment if you want to see a lot of text
    #
    #
    # Each table in the database is indexed with a unique id (rowid)
    # NOTE: This is differnt than a universal unique id (uuid)
    # rowids are ints and uuids are hex strings. Currently
    # only annotations and images have uuids
    #
    gid_list = ibs.get_valid_gids()  # Valid Image IDS
Ejemplo n.º 19
0
# -*- coding: utf-8 -*-
from __future__ import absolute_import, division, print_function
from os.path import split, splitext, join, exists
import datetime
import distutils
import utool as ut
(print, rrr, profile) = ut.inject2(__name__, '[sql-helpers]')

# =======================
# Helper Functions
# =======================
VERBOSE_SQL = ut.get_argflag(('--print-sql', '--verbose-sql', '--verb-sql', '--verbsql'))
#AUTODUMP = ut.get_argflag('--auto-dump')
NOT_QUIET = not (ut.QUIET or ut.get_argflag('--quiet-sql'))


def compare_string_versions(a, b):
    """
    Example:
        >>> # ENABLE_DOCTEST
        >>> from ibeis.control._sql_helpers import *  # NOQA
        >>> a = '1.1.1'
        >>> b = '1.0.0'
        >>> result1 = compare_string_versions(a, b)
        >>> result2 = compare_string_versions(b, a)
        >>> result3 = compare_string_versions(a, a)
        >>> result = ', '.join(map(str, [result1, result2, result3]))
        >>> print(result)
        1, -1, 0
    """
    va = distutils.version.LooseVersion(a)
Ejemplo n.º 20
0
# -*- coding: utf-8 -*-
### __init__.py ###
# flake8: noqa
from __future__ import absolute_import, division, print_function
from ibeis.expt import experiment_configs
from ibeis.expt import experiment_drawing
from ibeis.expt import test_result
from ibeis.expt import harness
from ibeis.expt import experiment_helpers
from ibeis.expt import experiment_printres
import utool as ut
print, rrr, profile = ut.inject2(__name__, '[ibeis.expt]')


def reassign_submodule_attributes(verbose=True):
    """
    why reloading all the modules doesnt do this I don't know
    """
    import sys
    if verbose and '--quiet' not in sys.argv:
        print('dev reimport')
    # Self import
    import ibeis.expt
    # Implicit reassignment.
    seen_ = set([])
    for tup in IMPORT_TUPLES:
        if len(tup) > 2 and tup[2]:
            continue  # dont import package names
        submodname, fromimports = tup[0:2]
        submod = getattr(ibeis.expt, submodname)
        for attr in dir(submod):
Ejemplo n.º 21
0
       o - Spceies sensitivity

    * Add ability for user to relearn encoder from labeled database.

TODO:
    * One class SVM http://scikit-learn.org/stable/auto_examples/svm/plot_oneclass.html
"""
from __future__ import absolute_import, division, print_function, unicode_literals
import re
import dtool
import numpy as np
import utool as ut
import vtool as vt
import six  # NOQA
from functools import partial
print, rrr, profile = ut.inject2(__name__, '[scorenorm]')


class NormFeatScoreConfig(dtool.Config):
    _alias = 'nfscfg'
    _param_info_list = [
        ut.ParamInfo('disttype', None),
        ut.ParamInfo('namemode', True),
        ut.ParamInfo('fsvx', None, type_='fuzzy_subset', hideif=None),
        ut.ParamInfo('threshx',  None, hideif=None),
        ut.ParamInfo('thresh', .9, hideif=lambda cfg: cfg['threshx'] is None),
        ut.ParamInfo('num', 5),
        # ut.ParamInfo('top_percent', None, hideif=None),
        ut.ParamInfo('top_percent', .5, hideif=None),
    ]
Ejemplo n.º 22
0
import vtool as vt
import utool as ut
import cv2
import wbia.constants as const
from wbia.control import controller_inject
from wbia.other.detectfuncs import (
    general_parse_gt,
    general_get_imageset_gids,
    localizer_parse_pred,
    _resize,
    general_overlap,
)
import random

# Inject utool functions
(print, rrr, profile) = ut.inject2(__name__, '[other.detectcore]')
logger = logging.getLogger('wbia')

CLASS_INJECT_KEY, register_ibs_method = controller_inject.make_ibs_register_decorator(
    __name__)


def nms(dets, scores, thresh, use_cpu=True):
    # Interface into Faster R-CNN's Python native NMS algorithm by Girshick et al.
    from wbia.algo.detect.nms.py_cpu_nms import py_cpu_nms

    return py_cpu_nms(dets, scores, thresh)


@register_ibs_method
def export_to_pascal(ibs, *args, **kwargs):
Ejemplo n.º 23
0
# -*- coding: utf-8 -*-
from __future__ import absolute_import, division, print_function, unicode_literals
from six.moves import zip, range, map  # NOQA
#import six
#from six import next
import cv2
import numpy as np
import utool as ut
from vtool import patch as ptool
from vtool import keypoint as ktool
print, rrr, profile = ut.inject2(__name__, '[cov]', DEBUG=False)


# TODO: integrate more
COVKPTS_DEFAULT = ut.ParamInfoList('coverage_kpts', [
    ut.ParamInfo('cov_agg_mode' , 'max'),
    ut.ParamInfo('cov_blur_ksize' , (5, 5)),
    ut.ParamInfo('cov_blur_on' , True),
    ut.ParamInfo('cov_blur_sigma' , 5.0),
    ut.ParamInfo('cov_remove_scale' , True),
    ut.ParamInfo('cov_remove_shape' , True),
    ut.ParamInfo('cov_scale_factor' , .3),
    ut.ParamInfo('cov_size_penalty_frac' , .1),
    ut.ParamInfo('cov_size_penalty_on' , True),
    ut.ParamInfo('cov_size_penalty_power' , .5),
])


@profile
#@ut.memprof
def make_kpts_coverage_mask(
Ejemplo n.º 24
0
# -*- coding: utf-8 -*-
from __future__ import absolute_import, division, print_function, unicode_literals
import plottool as pt
import utool as ut  # NOQA
import numpy as np
from ibeis.other import ibsfuncs
#from ibeis.algo.hots import chip_match
from ibeis.viz import viz_helpers as vh
from ibeis.viz import viz_chip
from ibeis.viz import viz_matches  # NOQA
(print, rrr, profile) = ut.inject2(__name__, '[viz_qres]')

DEFAULT_NTOP = 3


#@ut.indent_func
@profile
def show_qres_top(ibs, cm, qreq_=None, **kwargs):
    """
    Wrapper around show_qres.
    """
    N = kwargs.get('N', DEFAULT_NTOP)
    #name_scoring = kwargs.get('name_scoring', False)
    #if isinstance(cm, chip_match.ChipMatch):
    top_aids = cm.get_top_aids(N)
    #else:
    #    top_aids = cm.get_top_aids(num=N, ibs=ibs, name_scoring=name_scoring)
    aidstr = ibsfuncs.aidstr(cm.qaid)
    figtitle = kwargs.get('figtitle', '')
    if len(figtitle) > 0:
        figtitle = ' ' + figtitle
Ejemplo n.º 25
0
# -*- coding: utf-8 -*-
"""
module for making the correct automatic decisions in incremental tests
"""
from __future__ import absolute_import, division, print_function
import numpy as np
import utool as ut
print, rrr, profile = ut.inject2(__name__, '[incoracle]')


@profile
def oracle_method1(ibs_gt, ibs, qnid1, aid_list2, aid2_to_aid1, sorted_nids, MAX_LOOK):
    """ METHOD 1: MAKE BEST DECISION FROM GIVEN INFORMATION """
    # Map annotations to ibs_gt annotation rowids
    sorted_nids = np.array(sorted_nids)
    aid_list1 = ut.dict_take_list(aid2_to_aid1, aid_list2)
    nid_list1 = np.array(ibs_gt.get_annot_name_rowids(aid_list1))
    # Using ibs_gt nameids find the correct index in returned results
    correct_rank = np.where(nid_list1 == qnid1)[0]
    correct_rank = correct_rank[correct_rank < MAX_LOOK]
    # Return a list of any number of correct names or empty if it is a new name
    nid_list2 = sorted_nids[correct_rank]
    chosen_names = ibs.get_name_texts(nid_list2)
    return chosen_names


@profile
def oracle_method2(ibs_gt, qnid1):
    """ METHOD 2: MAKE THE ABSOLUTE CORRECT DECISION REGARDLESS OF RESULT """
    # use the name from the groundruth database
    name2 = ibs_gt.get_name_texts(qnid1)
Ejemplo n.º 26
0
# -*- coding: utf-8 -*-
from __future__ import absolute_import, division, print_function
#import six
from six.moves import zip, range, map  # NOQA
import utool as ut
import numpy as np
from ibeis.algo.hots.smk import smk_index
from ibeis.algo.hots.smk import smk_repr
from ibeis.algo.hots.smk import smk_core
#from six.moves import zip
#from ibeis.algo.hots.hstypes import INTEGER_TYPE
(print, rrr, profile) = ut.inject2(__name__, '[smk_match]')

DEBUG_SMK = ut.DEBUG2 or ut.get_argflag('--debug-smk')


@ut.indent_func('[smk_query]')
#@ut.memprof
@profile
def execute_smk_L5(qreq_):
    """
    ibeis query interface

    Example:
        >>> from ibeis.algo.hots.smk.smk_match import *  # NOQA
        >>> from ibeis.algo.hots.smk import smk_match
        >>> from ibeis.algo.hots.smk import smk_debug
        >>> ibs, annots_df, daids, qaids, invindex, qreq_ = smk_debug.testdata_internals_full()
        >>> qaid2_scores, qaid2_chipmatch = smk_match.execute_smk_L5(qreq_)

    Dev::
Ejemplo n.º 27
0
# -*- coding: utf-8 -*-
"""
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
"""
from __future__ import absolute_import, division, print_function, unicode_literals
import utool as ut
import six  # NOQA
from ibeis.init import old_main_helpers
(print, rrr, profile) = ut.inject2(__name__, '[main_helpers]')


# DEPRICATE
get_test_daids = old_main_helpers.get_test_daids
get_test_qaids = old_main_helpers.get_test_qaids

VERB_TESTDATA, VERYVERB_TESTDATA = ut.get_verbflag('testdata', 'td')
VERYVERB_MAIN_HELPERS = VERYVERB_TESTDATA
VERB_MAIN_HELPERS = VERB_TESTDATA

#VERB_TESTDATA = ut.get_argflag(('--verbose-testdata', '--verbtd')) or VERYVERB_TESTDATA
#VERB_MAIN_HELPERS = ut.get_argflag(('--verbose-main-helpers', '--verbmhelp'))
#or ut.VERBOSE or VERB_TESTDATA


def testdata_pipecfg(p=None, t=None):
    r"""
    Returns:
Ejemplo n.º 28
0
# -*- coding: utf-8 -*-
# Autogenerated on 12:54:39 2017/06/25
# flake8: noqa
from __future__ import absolute_import, division, print_function, unicode_literals
from ibeis.algo.verif import clf_helpers
from ibeis.algo.verif import sklearn_utils
from ibeis.algo.verif import deploy
from ibeis.algo.verif import pairfeat
from ibeis.algo.verif import verifier
from ibeis.algo.verif import vsone
import utool
print, rrr, profile = utool.inject2(__name__, '[ibeis.algo.verif]')


def reassign_submodule_attributes(verbose=1):
    """
    Updates attributes in the __init__ modules with updated attributes
    in the submodules.
    """
    import sys
    if verbose and '--quiet' not in sys.argv:
        print('dev reimport')
    # Self import
    import ibeis.algo.verif
    # Implicit reassignment.
    seen_ = set([])
    for tup in IMPORT_TUPLES:
        if len(tup) > 2 and tup[2]:
            continue  # dont import package names
        submodname, fromimports = tup[0:2]
        submod = getattr(ibeis.algo.verif, submodname)
Ejemplo n.º 29
0
"""
controller functions for contributors, versions, configs, and other metadata
"""
from __future__ import absolute_import, division, print_function
#import uuid
import six  # NOQA
#from os.path import join
import functools
from six.moves import range, input, zip, map  # NOQA
from ibeis import constants as const
from ibeis.control import accessor_decors, controller_inject
import utool as ut
from ibeis.algo import Config
#from ibeis import ibsfuncs
from ibeis.control.controller_inject import make_ibs_register_decorator
print, print_, profile = ut.inject2(__name__, '[manual_meta]')


CLASS_INJECT_KEY, register_ibs_method = make_ibs_register_decorator(__name__)


register_api   = controller_inject.get_ibeis_flask_api(__name__)
register_route = controller_inject.get_ibeis_flask_route(__name__)


@register_ibs_method
@accessor_decors.adder
@register_api('/api/contributor/', methods=['POST'])
def add_contributors(ibs, tag_list, uuid_list=None, name_first_list=None, name_last_list=None,
                     loc_city_list=None, loc_state_list=None,
                     loc_country_list=None, loc_zip_list=None,
Ejemplo n.º 30
0
# -*- coding: utf-8 -*-
"""
Small GUI for asking the user to enter the clock time shown, and moving along a gid list if the first image isn't a clock
"""
import logging
from functools import partial
from six.moves import range
from time import mktime
from datetime import date, datetime
import utool as ut
import wbia.guitool as gt
from wbia.guitool.__PYQT__ import QtWidgets
from wbia.guitool.__PYQT__.QtCore import Qt
import wbia.plottool as pt

(print, rrr, profile) = ut.inject2(__name__, '[co_gui]')
logger = logging.getLogger('wbia')


class ClockOffsetWidget(QtWidgets.QWidget):
    def __init__(co_wgt, ibs, gid_list, parent=None, hack=False):
        logger.info('[co_gui] Initializing')
        logger.info('[co_gui] gid_list = %r' % (gid_list, ))

        QtWidgets.QWidget.__init__(co_wgt, parent=parent)

        co_wgt.fnum = pt.next_fnum()

        co_wgt.main_layout = QtWidgets.QVBoxLayout(co_wgt)

        co_wgt.text_layout = gt.newWidget(co_wgt,
Ejemplo n.º 31
0
# -*- coding: utf-8 -*-
# TODO: ADD COPYRIGHT TAG
# TODO: Restructure
from __future__ import absolute_import, division, print_function, unicode_literals
import numpy as np
import utool as ut
from six.moves import zip, range, map
print, rrr, profile = ut.inject2(__name__, '[query_helpers]')


def get_query_components(ibs, qaids):
    r"""
    Args:
        ibs (IBEISController):  ibeis controller object
        qaids (?):

    Returns:
        ?:

    CommandLine:
        python -m ibeis.algo.hots.query_helpers --test-get_query_components

    Example:
        >>> # DISABLE_DOCTEST
        >>> from ibeis.algo.hots.query_helpers import *  # NOQA
        >>> import ibeis
        >>> # build test data
        >>> ibs = ibeis.opendb('testdb1')
        >>> qaids = ibs.get_valid_aids()
        >>> # execute function
        >>> result = get_query_components(ibs, qaids)
Ejemplo n.º 32
0
# -*- coding: utf-8 -*-
"""Interface to Lightnet object proposals."""
from __future__ import absolute_import, division, print_function
import utool as ut
from six.moves import zip
import numpy as np
from os.path import abspath, dirname, expanduser, join, exists, splitext  # NOQA
from tqdm import tqdm
import cv2
(print, rrr, profile) = ut.inject2(__name__, '[lightnet]')

if not ut.get_argflag('--no-lightnet'):
    try:
        import torch
        from torchvision import transforms as tf
        import lightnet as ln
    except ImportError:
        print('WARNING Failed to import lightnet. '
              'PyDarknet YOLO detection is unavailable')
        if ut.SUPER_STRICT:
            raise

VERBOSE_LN = ut.get_argflag('--verbln') or ut.VERBOSE

CONFIG_URL_DICT = {
    'hammerhead':
    'https://cthulhu.dyn.wildme.io/public/models/detect.lightnet.shark_hammerhead.py',
    'lynx':
    'https://cthulhu.dyn.wildme.io/public/models/detect.lightnet.lynx.py',
    'manta':
    'https://cthulhu.dyn.wildme.io/public/models/detect.lightnet.manta_ray_giant.py',
Ejemplo n.º 33
0
from __future__ import absolute_import, division, print_function, unicode_literals
# from six.moves import zip
import dtool
import utool as ut
import vtool as vt
import six
import pyflann
import numpy as np
# import cv2
from ibeis.control.controller_inject import register_preprocs, register_subprops
(print, rrr, profile) = ut.inject2(__name__, '[new_annots]')


derived_attribute = register_preprocs['annot']
register_subprop = register_subprops['annot']
# dtool.Config.register_func = derived_attribute


@ut.memoize
def testdata_vocab():
    from ibeis.new_annots import *  # NOQA
    import ibeis
    ibs, aid_list = ibeis.testdata_aids('testdb1')
    depc = ibs.depc_annot
    fid_list = depc.get_rowids('feat', aid_list)
    config = VocabConfig()
    vocab = compute_vocab(depc, fid_list, config)
    return ibs, aid_list, vocab


@six.add_metaclass(ut.ReloadingMetaclass)
Ejemplo n.º 34
0
# -*- coding: utf-8 -*-
"""
Interface to Faster R-CNN object proposals.
"""
from __future__ import absolute_import, division, print_function
import utool as ut
import vtool_ibeis as vt
from six.moves import zip, range
from os.path import abspath, dirname, expanduser, join, exists  # NOQA
import numpy as np
import sys
import cv2
(print, rrr, profile) = ut.inject2(__name__, '[faster r-cnn]')

# SCRIPT_PATH = abspath(dirname(__file__))
SCRIPT_PATH = abspath(expanduser(join('~', 'code', 'py-faster-rcnn')))

if not ut.get_argflag('--no-faster-rcnn'):
    try:
        assert exists(SCRIPT_PATH)

        def add_path(path):
            # if path not in sys.path:
            sys.path.insert(0, path)

        # Add pycaffe to PYTHONPATH
        pycaffe_path = join(SCRIPT_PATH, 'caffe-fast-rcnn', 'python')
        add_path(pycaffe_path)

        # Add caffe lib path to PYTHONPATH
        lib_path = join(SCRIPT_PATH, 'lib')
Ejemplo n.º 35
0
# -*- coding: utf-8 -*-
"""
Interface to pydarknet yolo object detection.
"""
from __future__ import absolute_import, division, print_function
import utool as ut
import vtool as vt
from six.moves import zip
(print, rrr, profile) = ut.inject2(__name__, '[yolo]')

if not ut.get_argflag('--no-pydarknet'):
    try:
        import pydarknet
    except ImportError as ex:
        if ut.SUPER_STRICT:
            print('WARNING Failed to import pydarknet. '
                  'PyDarknet YOLO detection is unavailable')
            raise


VERBOSE_DARK = ut.get_argflag('--verbdark') or ut.VERBOSE


# def train_gid_list(ibs, gid_list, trees_path=None, species=None, setup=True,


def detect_gid_list(ibs, gid_list, downsample=False, **kwargs):
    """
    Args:
        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
Ejemplo n.º 36
0
# -*- coding: utf-8 -*-
from __future__ import absolute_import, division, print_function, unicode_literals
import numpy as np
import utool as ut
import six
from ibeis.algo.hots import hstypes
print, rrr, profile = ut.inject2(__name__, '[old_chip_match]')


class AlignedListDictProxy(ut.DictLike_old):
    """
    simulates a dict when using parallel lists the point of this class is that
    when there are many instances of this class, then key2_idx can be shared between
    them. Ideally this class wont be used and will disappear when the parallel
    lists are being used properly.

    DEPCIRATE AlignedListDictProxy's defaultdict behavior is weird
    """
    def __init__(self, key2_idx, key_list, val_list):
        #if isinstance(key_list, np.ndarray):
        #    key_list = key_list.tolist()
        self.key_list = key_list
        self.val_list = val_list
        self.key2_idx = key2_idx
        self.default_function = None

    def __eq__(self, key):
        raise NotImplementedError()

    def pop(self, key):
        raise NotImplementedError()
Ejemplo n.º 37
0
#!/usr/bin/env python2.7
# -*- coding: utf-8 -*-
from __future__ import absolute_import, division, print_function
import utool
from ibeis.control import SQLDatabaseControl
from os.path import join
from functools import partial
print, rrr, profile = utool.inject2(__name__, '[TEST_SQL_CONTROL]')
import random

###########################


def converter(val):
    return str(val) + '_str'


def get_rowid_from_text(db, text_list):
    param_iter = ((text,) for text in text_list)
    return db.get_rowid_from_superkey('test', param_iter, superkey_colnames=('test_text',))


def add_text(db, text_list):
    param_iter = ((text,) for text in text_list)
    func = partial(get_rowid_from_text, db)
    return db.add_cleanly('test', ('test_text',), param_iter, func)


def get_text(db, tablename, rowid_list):
    return db.get(tablename, ('test_text',), rowid_list)
Ejemplo n.º 38
0
This module should handle all things elliptical
"""
from __future__ import absolute_import, division, print_function
from six.moves import zip, range
from numpy.core.umath_tests import matrix_multiply
import scipy.signal as spsignal
import numpy as np
from vtool import keypoint as ktool
from vtool import image as gtool
import utool as ut
try:
    import cv2
except ImportError as ex:
    print('ERROR: import cv2 is failing!')
    cv2 = ut.DynStruct()
(print, rrr, profile) = ut.inject2(__name__, '[ellipse]', DEBUG=False)


@profile
def adaptive_scale(img_fpath, kpts, nScales=4, low=-.5, high=.5, nSamples=16):
    #imgBGR = cv2.imread(img_fpath, flags=cv2.CV_LOAD_IMAGE_COLOR)
    imgBGR = gtool.imread(img_fpath)

    nKp = len(kpts)
    dtype_ = kpts.dtype

    # Work with float65
    kpts_ = np.array(kpts, dtype=np.float64)

    # Expand each keypoint into a number of different scales
    expanded_kpts = expand_scales(kpts_, nScales, low, high)
Ejemplo n.º 39
0
# -*- coding: utf-8 -*-
"""
Runs functions in pipeline to get query reuslts and does some caching.
"""
from __future__ import absolute_import, division, print_function, unicode_literals
import utool as ut
import six  # NOQA
from os.path import exists
#from ibeis.algo.hots import query_request
#from ibeis.algo.hots import hots_query_result
#from ibeis.algo.hots import exceptions as hsexcept
from ibeis.algo.hots import chip_match
from ibeis.algo.hots import pipeline
from ibeis.algo.hots import _pipeline_helpers as plh  # NOQA
(print, rrr, profile) = ut.inject2(__name__, '[mc4]')


# TODO: Move to params
USE_HOTSPOTTER_CACHE = pipeline.USE_HOTSPOTTER_CACHE
USE_CACHE    = not ut.get_argflag(('--nocache-query', '--noqcache'))  and USE_HOTSPOTTER_CACHE
USE_BIGCACHE = not ut.get_argflag(('--nocache-big', '--no-bigcache-query', '--noqcache', '--nobigcache')) and ut.USE_CACHE
SAVE_CACHE   = not ut.get_argflag('--nocache-save')
#MIN_BIGCACHE_BUNDLE = 20
#MIN_BIGCACHE_BUNDLE = 150
MIN_BIGCACHE_BUNDLE = 64
HOTS_BATCH_SIZE = ut.get_argval('--hots-batch-size', type_=int, default=None)


#----------------------
# Main Query Logic
#----------------------
Ejemplo n.º 40
0
sysres.py == system_resources
Module for dealing with system resoureces in the context of IBEIS
but without the need for an actual IBEIS Controller

"""
from __future__ import absolute_import, division, print_function
import os
from os.path import exists, join, realpath
import utool as ut
from six.moves import input, zip, map
from utool import util_cache, util_list
from ibeis import constants as const
from ibeis import params

# Inject utool functions
(print, rrr, profile) = ut.inject2(__name__, '[sysres]')

WORKDIR_CACHEID = 'work_directory_cache_id'
DEFAULTDB_CAHCEID = 'cached_dbdir'
LOGDIR_CACHEID = ut.logdir_cacheid
__APPNAME__ = 'ibeis'


def get_ibeis_resource_dir():
    return ut.ensure_app_resource_dir('ibeis')


def _ibeis_cache_dump():
    util_cache.global_cache_dump(appname=__APPNAME__)

Ejemplo n.º 41
0
# -*- coding: utf-8 -*-
# UNFINISHED - do not use
from __future__ import print_function, division, absolute_import, unicode_literals
import collections  # NOQA
import networkx as nx
import utool as ut
print, rrr, profile = ut.inject2(__name__)
# import bintrees
# import rbtree


def euler_tour_dfs(G, source=None):
    """ adaptation of networkx dfs """
    if source is None:
        # produce edges for all components
        nodes = G
    else:
        # produce edges for components with source
        nodes = [source]
    yielder = []
    visited = set()
    for start in nodes:
        if start in visited:
            continue
        visited.add(start)
        stack = [(start, iter(G[start]))]
        while stack:
            parent, children = stack[-1]
            try:
                child = next(children)
                if child not in visited:
Ejemplo n.º 42
0
"""
External mechanism for computing feature distinctiveness

stores some set of vectors which lose their association with
their parent.
"""
from __future__ import absolute_import, division, print_function, unicode_literals
import vtool as vt
import utool as ut
import numpy as np
from six.moves import map
import six  # NOQA
from ibeis import constants as const
from ibeis.init import sysres
from ibeis.algo.hots import hstypes
print, rrr, profile = ut.inject2(__name__, '[distinctnorm]')


DCVS_DEFAULT = ut.ParamInfoList('distinctivness', [
    ut.ParamInfo('dcvs_power', 1.0, 'p',    varyvals=[.5, 1.0, 1.5, 2.0]),
    ut.ParamInfo('dcvs_min_clip', .2, 'mn', varyvals=[.2, .02, .03][0:1]),
    ut.ParamInfo('dcvs_max_clip', .5, 'mx', varyvals=[.05, .3, .4, .45, .5, 1.0][1:4]),
    ut.ParamInfo('dcvs_K', 5, 'dcvsK',      varyvals=[5, 7, 15][0:1]),
])


DISTINCTIVENESS_NORMALIZER_CACHE = {}
BASELINE_DISTINCTIVNESS_URLS = {
    # TODO: Populate
    'zebra_grevys': const.ZIPPED_URLS.GZ_DISTINCTIVE,
    'zebra_plains': const.ZIPPED_URLS.PZ_DISTINCTIVE,
Ejemplo n.º 43
0
1) Ambiguity / num names
2) independence of annotations
3) continuous
4) exponential case
5) speicifc examples of our prob
6) human in loop
"""
from __future__ import absolute_import, division, print_function, unicode_literals
import six  # NOQA
import utool as ut
import numpy as np
from six.moves import zip
from ibeis.algo.hots import pgm_ext
from ibeis.algo.hots import pgm_viz

print, rrr, profile = ut.inject2(__name__, '[bayes]')

#SPECIAL_BASIS_POOL = ['fred', 'sue', 'tom']
SPECIAL_BASIS_POOL = []
#'fred', 'sue', 'tom']


def test_model(num_annots, num_names, score_evidence=[], name_evidence=[],
               other_evidence={}, noquery=False, verbose=None,
               **kwargs):
    if verbose is None:
        verbose = ut.VERBOSE

    method = kwargs.pop('method', None)
    model = make_name_model(num_annots, num_names, verbose=verbose, **kwargs)
Ejemplo n.º 44
0
# -*- coding: utf-8 -*-
"""Interface to Lightnet object proposals."""
import logging
from os.path import expanduser, join
from wbia import constants as const
import utool as ut
import numpy as np
import cv2
import random
import tqdm
import time
import os
import copy
import PIL

(print, rrr, profile) = ut.inject2(__name__, '[densenet]')
logger = logging.getLogger('wbia')

PARALLEL = not const.CONTAINERIZED
INPUT_SIZE = 224

ARCHIVE_URL_DICT = {
    'canonical_zebra_grevys_v1':
    'https://wildbookiarepository.azureedge.net/models/classifier.canonical.zebra_grevys.v1.zip',
    'canonical_zebra_grevys_v2':
    'https://wildbookiarepository.azureedge.net/models/classifier.canonical.zebra_grevys.v2.zip',
    'canonical_zebra_grevys_v3':
    'https://wildbookiarepository.azureedge.net/models/classifier.canonical.zebra_grevys.v3.zip',
    'canonical_zebra_grevys_v4':
    'https://wildbookiarepository.azureedge.net/models/classifier.canonical.zebra_grevys.v4.zip',
    'ryan_densenet_v1':
Ejemplo n.º 45
0
# -*- coding: utf-8 -*-
from __future__ import absolute_import, division, print_function, unicode_literals
import six  # NOQA
import utool as ut  # NOQA
import numpy as np
import vtool as vt
#from ibeis import constants as const
from ibeis.control import accessor_decors  # NOQA
from ibeis.control.controller_inject import make_ibs_register_decorator
print, rrr, profile = ut.inject2(__name__, '[manual_newfuncs]')

CLASS_INJECT_KEY, register_ibs_method = make_ibs_register_decorator(__name__)


@register_ibs_method
def new_query_request(ibs, qaid_list, daid_list, cfgdict=None,
                      verbose=ut.NOT_QUIET, **kwargs):
    """
    alias for ibeis.algo.hots.query_request.new_ibeis_query_request

    Args:
        qaid_list (list):
        daid_list (list):
        cfgdict (None):
        verbose (bool):

    Returns:
        QueryRequest: qreq_ -  hyper-parameters

    CommandLine:
        python -m ibeis.control.manual_ibeiscontrol_funcs --test-new_query_request
Ejemplo n.º 46
0
# -*- coding: utf-8 -*-
import logging
from wbia.guitool.__PYQT__ import QtCore, QtGui
from wbia.guitool.__PYQT__ import QtWidgets
from wbia.guitool import api_item_view
from wbia.guitool.guitool_decorators import signal_, slot_
import utool

(print, rrr, profile) = utool.inject2(__name__, '[APITableView]', DEBUG=False)
logger = logging.getLogger('wbia')

# If you need to set the selected index try:
# AbstractItemView::setCurrentIndex
# AbstractItemView::scrollTo
# AbstractItemView::keyboardSearch

API_VIEW_BASE = QtWidgets.QTableView
# API_VIEW_BASE = QtWidgets.QAbstractItemView


class APITableView(API_VIEW_BASE):
    """
    Table view of API data.
    Implicitly inherits from APIItemView
    """

    rows_updated = signal_(str, int)
    contextMenuClicked = signal_(QtCore.QModelIndex, QtCore.QPoint)
    API_VIEW_BASE = API_VIEW_BASE

    def __init__(view, parent=None):
Ejemplo n.º 47
0
# -*- coding: utf-8 -*-
# developer convenience functions for ibs
from __future__ import absolute_import, division, print_function, unicode_literals
import utool as ut
from six.moves import zip
from ibeis import constants as const
(print, rrr, profile) = ut.inject2(__name__, '[duct_tape]')


def fix_compname_configs(ibs):
    """ duct tape to keep version in check """
    #ibs.MANUAL_CONFIG_SUFFIX = '_MANUAL_'  #+ ut.get_computer_name()
    #ibs.MANUAL_CONFIGID = ibs.add_config(ibs.MANUAL_CONFIG_SUFFIX)
    # We need to fix the manual config suffix to not use computer names anymore

    configid_list = ibs.get_valid_configids()
    cfgsuffix_list = ibs.get_config_suffixes(configid_list)

    ibs.MANUAL_CONFIG_SUFFIX = 'MANUAL_CONFIG'
    ibs.MANUAL_CONFIGID = ibs.add_config(ibs.MANUAL_CONFIG_SUFFIX)

    for rowid, suffix in filter(lambda tup:
                                tup[1].startswith('_MANUAL_'),
                                zip(configid_list, cfgsuffix_list)):
        print("EVALUATING: %r, %r" % (rowid, suffix))
        # Fix the tables with bad config_rowids
        ibs.db.executeone(
            '''
            UPDATE {AL_RELATION_TABLE}
            SET config_rowid=?
            WHERE config_rowid=?
Ejemplo n.º 48
0
try:
    from flask.ext.cas import CAS
    from flask.ext.cas import login_required
    HAS_FLASK_CAS = True
except Exception as ex:
    HAS_FLASK_CAS = False
    login_required = ut.identity
    msg = ('Missing flask.ext.cas.\n'
           'To install try pip install git+https://github.com/cameronbwhite/Flask-CAS.git')
    ut.printex(ex, msg, iswarning=True)
    # sudo
    print('')
    if ut.SUPER_STRICT:
        raise
# </flask>
print, rrr, profile = ut.inject2(__name__, '[controller_inject]')


#INJECTED_MODULES = []
UTOOL_AUTOGEN_SPHINX_RUNNING = not (
    os.environ.get('UTOOL_AUTOGEN_SPHINX_RUNNING', 'OFF') == 'OFF')

GLOBAL_APP_ENABLED = (not UTOOL_AUTOGEN_SPHINX_RUNNING and
                      not ut.get_argflag('--no-flask') and HAS_FLASK)
GLOBAL_APP_NAME = 'IBEIS'
GLOBAL_APP_SECRET = 'CB73808F-A6F6-094B-5FCD-385EBAFF8FC0'

GLOBAL_APP = None
GLOBAL_CORS = None
GLOBAL_CAS = None
#JSON_PYTHON_OBJECT_TAG = '__PYTHON_OBJECT__'
Ejemplo n.º 49
0
    autogen_time = 11:34:25 2016/01/05
    autogen_key = annotmatch

ToRegenerate:
    python -m ibeis.templates.template_generator --key annotmatch --Tcfg with_web_api=False with_api_cache=False with_deleters=True no_extern_deleters=True --diff
    python -m ibeis.templates.template_generator --key annotmatch --Tcfg with_web_api=False with_api_cache=False with_deleters=True no_extern_deleters=True --write
"""
from __future__ import absolute_import, division, print_function, unicode_literals
import functools  # NOQA
import six  # NOQA
from six.moves import map, range, zip  # NOQA
from ibeis import constants as const
import utool as ut
from ibeis.control import controller_inject
from ibeis.control import accessor_decors  # NOQA
print, rrr, profile = ut.inject2(__name__, '[autogen_annotmatch]')

# Create dectorator to inject functions in this module into the IBEISController
CLASS_INJECT_KEY, register_ibs_method = controller_inject.make_ibs_register_decorator(__name__)


register_api   = controller_inject.get_ibeis_flask_api(__name__)
register_route = controller_inject.get_ibeis_flask_route(__name__)


def testdata_annotmatch(defaultdb='testdb1'):
    import ibeis
    ibs = ibeis.opendb(defaultdb=defaultdb)
    config2_ = None  # qreq_.qparams
    #from ibeis.hots import query_config
    #config2_ = query_config.QueryParams(cfgdict=dict())
Ejemplo n.º 50
0
# -*- coding: utf-8 -*-
"""
DEPRICATE

TODO: Rename to ibeis/init/commands.py

The AID configuration selection is getting a mjor update right now
"""
from __future__ import absolute_import, division, print_function
import utool as ut
import numpy as np  # NOQA
import six
from ibeis import params
(print, rrr, profile) = ut.inject2(__name__, '[main_helpers]')


VERB_TESTDATA = ut.get_argflag(('--verbose-testdata', '--verbtd'))
VERB_MAIN_HELPERS = ut.get_argflag(('--verbose-main-helpers', '--verbmhelp')) or ut.VERBOSE or VERB_TESTDATA


def define_named_aid_cfgs():
    """
    Definitions for common aid configurations
    TODO: potentially move to experiment configs
    """
    from ibeis.expt import annotation_configs
    named_defaults_dict = ut.dict_take(annotation_configs.__dict__, annotation_configs.TEST_NAMES)
    named_qcfg_defaults = dict(zip(annotation_configs.TEST_NAMES, ut.get_list_column(named_defaults_dict, 'qcfg')))
    named_dcfg_defaults = dict(zip(annotation_configs.TEST_NAMES, ut.get_list_column(named_defaults_dict, 'dcfg')))
    alias_keys = annotation_configs.alias_keys
    named_cfg_dict = {
Ejemplo n.º 51
0
# -*- coding: utf-8 -*-
"""
Definitions for common aid configurations

Rename to annot_cfgdef
"""
from __future__ import absolute_import, division, print_function, unicode_literals
import utool as ut
from ibeis.expt import cfghelpers
import numpy as np  # NOQA
print, rrr, profile = ut.inject2(__name__, '[aidcfg]')


# easier to type names to alias some of these options
ALIAS_KEYS = {
    #'aids'     : 'default_aids',
    'pername'  : 'sample_per_name',
    'offset'   : 'sample_offset',
    'refrule'  : 'sample_rule_ref',
    'rule'     : 'sample_rule',
    'size'     : 'sample_size',
    'mingt'    : 'min_pername',
    'excluderef': 'exclude_reference',
}

OTHER_DEFAULTS = {
    # forces a consistnet sample size across combinations
    'force_const_size'    : None,
    #'hack_extra' : None,  # hack param to make bigger db sizes
    #'hack_encounter': None,
    # Hack out errors in test data
Ejemplo n.º 52
0
# -*- coding: utf-8 -*-
import logging
from os.path import join  # NOQA
import cv2
import numpy as np
import torch
import torch.nn
import utool as ut
import torchvision

print, rrr, profile = ut.inject2(__name__)
logger = logging.getLogger('wbia')


class LRSchedule(object):
    @staticmethod
    def exp(optimizer, epoch, init_lr=0.001, lr_decay_epoch=2):
        """Decay learning rate by a factor of 0.1 every lr_decay_epoch epochs."""
        lr = init_lr
        # epoch += 1
        if epoch % lr_decay_epoch == 0 and epoch != 0:
            lr *= 0.1

        if epoch % lr_decay_epoch == 0:
            logger.info('LR is set to {}'.format(lr))

        for param_group in optimizer.param_groups:
            param_group['lr'] = lr

        return optimizer, lr
Ejemplo n.º 53
0
# LICENCE
from __future__ import absolute_import, division, print_function
# Science
import numpy as np
import numpy.linalg as npl
# VTool
from vtool import linalg as ltool
from vtool import image as gtool
import utool as ut
try:
    import cv2
except ImportError as ex:
    print('ERROR: import cv2 is failing!')
    cv2 = ut.DynStruct()
    cv2.INTER_LANCZOS4 = None
(print, rrr, profile) = ut.inject2(__name__, '[chip]', DEBUG=False)


@profile
def get_image_to_chip_transform(bbox, chipsz, theta):
    """
    transforms image space into chipspace

    Args:
        bbox   - bounding box of chip in image space
        chipsz - size of the chip
        theta  - rotation of the bounding box

    Sympy:
        # https://groups.google.com/forum/#!topic/sympy/k1HnZK_bNNA
        from vtool.patch import *  # NOQA
Ejemplo n.º 54
0
# -*- coding: utf-8 -*-
"""
Interface to Darknet object proposals.
"""
from __future__ import absolute_import, division, print_function
import utool as ut
from os import listdir
from os.path import join, isfile, isdir
(print, rrr, profile) = ut.inject2(__name__, '[svm]')

VERBOSE_SVM = ut.get_argflag('--verbsvm') or ut.VERBOSE

CONFIG_URL_DICT = {
    # 'localizer-zebra-10'  : 'https://lev.cs.rpi.edu/public/models/classifier.svm.localization.zebra.10.zip',
    # 'localizer-zebra-20'  : 'https://lev.cs.rpi.edu/public/models/classifier.svm.localization.zebra.20.zip',
    # 'localizer-zebra-30'  : 'https://lev.cs.rpi.edu/public/models/classifier.svm.localization.zebra.30.zip',
    # 'localizer-zebra-40'  : 'https://lev.cs.rpi.edu/public/models/classifier.svm.localization.zebra.40.zip',
    # 'localizer-zebra-50'  : 'https://lev.cs.rpi.edu/public/models/classifier.svm.localization.zebra.50.zip',
    # 'localizer-zebra-60'  : 'https://lev.cs.rpi.edu/public/models/classifier.svm.localization.zebra.60.zip',
    # 'localizer-zebra-70'  : 'https://lev.cs.rpi.edu/public/models/classifier.svm.localization.zebra.70.zip',
    # 'localizer-zebra-80'  : 'https://lev.cs.rpi.edu/public/models/classifier.svm.localization.zebra.80.zip',
    # 'localizer-zebra-90'  : 'https://lev.cs.rpi.edu/public/models/classifier.svm.localization.zebra.90.zip',
    # 'localizer-zebra-100' : 'https://lev.cs.rpi.edu/public/models/classifier.svm.localization.zebra.100.zip',

    # 'image-zebra'         : 'https://lev.cs.rpi.edu/public/models/classifier.svm.image.zebra.pkl',

    # 'default'             : 'https://lev.cs.rpi.edu/public/models/classifier.svm.image.zebra.pkl',
    # None                  : 'https://lev.cs.rpi.edu/public/models/classifier.svm.image.zebra.pkl',
}

Ejemplo n.º 55
0
from six.moves import range
import functools
import six
from collections import OrderedDict as odict
import utool as ut
import vtool as vt
from plottool import interact_helpers as ih
from plottool import plot_helpers as ph
import matplotlib as mpl
import plottool.draw_func2 as df2
from ibeis.other import ibsfuncs
from ibeis.viz import viz_helpers as vh
from ibeis.viz import viz_matches
from ibeis.viz.interact.interact_sver import ishow_sver

(print, rrr, profile) = ut.inject2(__name__, '[interact_qres2]')


BREAK_MATCH_PREF = 'break match'
NEW_MATCH_PREF   = 'new match'
RENAME1_PREF     = 'rename query: '
RENAME2_PREF     = 'rename result: '


def default_interact_qres_params():
    params = {
        'fnum'               : 512,
        'nPerPage'           : 6,
        'ranks_lt'           : 3,
        'on_change_callback' : None
    }
Ejemplo n.º 56
0
# -*- coding: utf-8 -*-
# Autogenerated on 18:39:13 2016/02/22
# flake8: noqa
import logging
from wbia.other import dbinfo
from wbia.other import duct_tape
from wbia.other import detectgrave
from wbia.other import detectcore
from wbia.other import detectexport
from wbia.other import detectfuncs
from wbia.other import detecttrain
from wbia.other import ibsfuncs
import utool

print, rrr, profile = utool.inject2(__name__, '[wbia.other]')
logger = logging.getLogger('wbia')


def reassign_submodule_attributes(verbose=True):
    """
    why reloading all the modules doesnt do this I don't know
    """
    import sys

    if verbose and '--quiet' not in sys.argv:
        print('dev reimport')
    # Self import
    import wbia.other

    # Implicit reassignment.
    seen_ = set([])
Ejemplo n.º 57
0
# -*- coding: utf-8 -*-
"""
Helper module that helps expand parameters for grid search

DEPRICATE: Most of this can likely be replaced by util_gridsearch
TODO: rectify with versions in util_gridsearch

It turns out a lot of the commandlines made possible here can be generatd by
using bash brace expansion.
http://www.linuxjournal.com/content/bash-brace-expansion
"""
from __future__ import absolute_import, division, print_function, unicode_literals
import utool as ut
print, rrr, profile = ut.inject2(__name__, '[cfghelpers]')


def remove_prefix_hack(cfg, cfgtype, cfg_options, alias_keys):
    if cfgtype is not None and cfgtype in ['qcfg', 'dcfg']:
        for key in list(cfg_options.keys()):
            # check if key is nonstandard
            if not (key in cfg or key in alias_keys):
                # does removing prefix make it stanard?
                prefix = cfgtype[0]
                if key.startswith(prefix):
                    key_ = key[len(prefix):]
                    if key_ in cfg or key_ in alias_keys:
                        # remove prefix
                        cfg_options[key_] = cfg_options[key]
                try:
                    assert key[1:] in cfg or key[1:] in alias_keys, (
                        'key=%r, key[1:] =%r' % (key, key[1:] ))
Ejemplo n.º 58
0
             - be able to mark a column as determined by the aggregate of other
               columns. Then the data is either generated on the fly, or it is
               cached and the necessary book-keeping functions are
               autogenerated.

    Decision UIs::
        * Is Exemplar
            - LONG TERM: it would be cool if they were visualized by using
              networkx or some gephi like program and clustered by match score.

"""
from __future__ import absolute_import, division, print_function, unicode_literals
import utool as ut
import six
from six.moves import input
print, rrr, profile = ut.inject2(__name__, '[autohelp]')


def assert_testdb_annot_consistency(ibs_gt, ibs2, aid_list1, aid_list2):
    """
    just tests uuids

    if anything goes wrong this should fix it:
        from ibeis.other import ibsfuncs
        aid_list1 = ibs_gt.get_valid_aids()
        ibs_gt.update_annot_visual_uuids(aid_list1)
        ibs2.update_annot_visual_uuids(aid_list2)
        ibsfuncs.fix_remove_visual_dupliate_annotations(ibs_gt)
    """
    assert len(aid_list2) == len(aid_list1)
    visualtup1 = ibs_gt.get_annot_visual_uuid_info(aid_list1)
Ejemplo n.º 59
0
"""
from __future__ import absolute_import, division, print_function, unicode_literals
#if False:
#    import os
#    os.environ['UTOOL_NOCNN'] = 'True'
import six
import utool as ut
import time
import zmq
import uuid  # NOQA
import itertools
import numpy as np
import functools
from functools import partial
from ibeis.control import accessor_decors, controller_inject
print, rrr, profile = ut.inject2(__name__, '[zmqstuff]')


CLASS_INJECT_KEY, register_ibs_method = (
    controller_inject.make_ibs_register_decorator(__name__))
register_api   = controller_inject.get_ibeis_flask_api(__name__)


ctx = zmq.Context.instance()

url = 'tcp://127.0.0.1'
_portgen = functools.partial(six.next, itertools.count(51381))
engine_url1 = url + ':' + six.text_type(_portgen())
engine_url2 = url + ':' + six.text_type(_portgen())
collect_url1 = url + ':' + six.text_type(_portgen())
collect_url2 = url + ':' + six.text_type(_portgen())
Ejemplo n.º 60
0
from wbia.guitool import qtype
from wbia.guitool import api_button_delegate
from wbia.guitool import api_thumb_delegate
from wbia.guitool import guitool_main
from wbia.guitool import guitool_misc
from six.moves import range, reduce  # NOQA
import utool
import utool as ut
import operator

# Valid API Models
from wbia.guitool.stripe_proxy_model import StripeProxyModel
from wbia.guitool.filter_proxy_model import FilterProxyModel
from wbia.guitool.api_item_model import APIItemModel

(print, rrr, profile) = utool.inject2(__name__, '[APIItemView]')
logger = logging.getLogger('wbia')

VERBOSE_QT = ut.get_argflag(('--verbose-qt', '--verbqt'))
VERBOSE_ITEM_VIEW = ut.get_argflag(('--verbose-item-view'))
VERBOSE = utool.VERBOSE or VERBOSE_QT or VERBOSE_ITEM_VIEW

API_VIEW_BASE = QtWidgets.QAbstractItemView
ABSTRACT_VIEW_INJECT_KEY = ('QtWidgets.QAbstractItemView', 'guitool')
register_view_method = utool.make_class_method_decorator(
    ABSTRACT_VIEW_INJECT_KEY, __name__)

injectviewinstance = functools.partial(utool.inject_instance,
                                       classkey=ABSTRACT_VIEW_INJECT_KEY)

VALID_API_MODELS = (FilterProxyModel, StripeProxyModel, APIItemModel)