本文整理汇总了Python中utool.inject2函数的典型用法代码示例。如果您正苦于以下问题:Python inject2函数的具体用法?Python inject2怎么用?Python inject2使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了inject2函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_query_components
# -*- 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)
示例2:
# -*- 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
示例3: add_contributors
"""
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,
示例4: parse_exif
# -*- 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
示例5: testdata_pipecfg
# -*- 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:
示例6:
# -*- 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',
示例7: oracle_method1
# -*- 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)
示例8: converter
#!/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)
示例9: compare_string_versions
# -*- 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)
示例10: detect_gid_list
# -*- 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
示例11: reassign_submodule_attributes
# -*- 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
示例12: get_ibeis_resource_dir
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__)
示例13: testdata_vocab
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)
示例14: reload_subs
# }
#}
#)
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)()
示例15: make_kpts_coverage_mask
# -*- 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(