from __future__ import absolute_import, division, print_function from itertools import izip import utool from PyQt4 import QtGui, QtCore from PyQt4.QtCore import Qt from PyQt4.QtGui import QAbstractItemView (print, print_, printDBG, rrr, profile) = utool.inject(__name__, '[rowidtables]', DEBUG=False) from ibeis.control import DB_SCHEMA USER_MODE = utool.get_flag('--usermode') # Define which columns are usable in tables: # Specified in (type, header, fancy_header) format COLUMN_DEFS = [ (int, 'gid', 'Image ID'), (int, 'rid', 'ROI ID'), (int, 'nid', 'Name ID'), (int, 'imgsetid', 'ImageSet ID'), (int, 'nRids', '#ROIs'), (int, 'nGt', '#GT'), (int, 'nFeats', '#Features'), (str, 'rank', 'Rank'), # needs to be a string for !Query (float, 'unixtime', 'unixtime'), (str, 'imagesettext', 'ImageSet'), (str, 'gname', 'Image Name'), (str, 'name', 'Name'), (str, 'notes', 'Notes'), (str, 'match_name', 'Matching Name'),
""" from __future__ import absolute_import, division, print_function import utool as ut # Python import six from six.moves import zip, cPickle from os.path import exists, split, join from zipfile import error as BadZipFile # Screwy naming convention. import os # Scientific import numpy as np from ibeis.model.hots import precision_recall from ibeis.model.hots import chip_match from ibeis.model.hots import name_scoring from ibeis.model.hots import exceptions as hsexcept (print, print_, printDBG, rrr, profile) = ut.inject(__name__, '[QRes]', DEBUG=False) #FORCE_LONGNAME = ut.get_argflag('--longname') or (not ut.WIN32 and not ut.get_argflag('--nolongname')) MAX_FNAME_LEN = 64 if ut.WIN32 else 200 TRUNCATE_UUIDS = ut.get_argflag(('--truncate-uuids', '--trunc-uuids')) #or ( ut.is_developer() and not ut.get_argflag(('--notruncate-uuids', '--notrunc-uuids'))) VERBOSE = ut.get_argflag(('--verbose-query-result', '--verb-qres')) or ut.VERBOSE #========================= # Query Result Class #========================= def qres_get_matching_keypoints(qres, ibs, aid2_list): # aid2 is a name. 2 != 2 to here aid1 = qres.qaid
Per Name Incremental Version """ from __future__ import absolute_import, division, print_function import utool as ut import numpy as np from ibeis.algo.hots.smk import smk_debug from vtool import patch as ptool from vtool import image as gtool import six import scipy.stats.mstats as spms from os.path import join from os.path import basename import scipy.spatial.distance as spdist from collections import namedtuple (print, print_, printDBG, rrr, profile) = ut.inject(__name__, '[smk_plots]') Metrics = namedtuple('Metrics', ( 'wx2_nMembers', 'wx2_pdist_stats', 'wx2_wdist_stats', )) def vizualize_vocabulary(ibs, invindex): """ cleaned up version of dump_word_patches. Makes idf scatter plots and dumps the patches that contributed to each word. CommandLine: python -m ibeis.algo.hots.smk.smk_plots --test-vizualize_vocabulary
""" DEPRICATE """ from __future__ import absolute_import, division, print_function import utool import six from os.path import join, realpath from itertools import cycle from six.moves import range print, print_, printDBG, rrr, profile = utool.inject(__name__, '[testdata]') def get_testdata_dir(ensure=True, key='testdb1'): """ Gets test img directory and downloads it if it doesn't exist """ testdata_map = { 'testdb1': 'https://lev.cs.rpi.edu/public/data/testdata.zip' } zipped_testdata_url = testdata_map[key] testdata_dir = utool.grab_zipped_url(zipped_testdata_url, ensure=ensure) return testdata_dir def get_test_gpaths(ndata=None, names=None, **kwargs): # Read ndata from args or command line ndata_arg = utool.get_argval('--ndata', type_=int, default=None, help_='use --ndata to specify bigger data') if ndata_arg is not None: ndata = ndata_arg imgdir = get_testdata_dir(**kwargs) gpath_list = sorted(list(utool.list_images(imgdir, full=True, recursive=True)))
from __future__ import absolute_import, division, print_function import utool from ibeis import constants #from itertools import izip (print, print_, printDBG, rrr, profile) = utool.inject(__name__, '[headers]', DEBUG=False) ENCOUNTER_TABLE = 'encounters' IMAGE_TABLE = 'images' IMAGE_GRID = 'image_grid' ANNOTATION_TABLE = 'annotations' NAME_TABLE = 'names' NAMES_TREE = 'names_tree' QRES_TABLE = 'qres' THUMB_TABLE = 'thumbs' #----------------- # Define the tables #----------------- # available tables TABLENAME_LIST = [ IMAGE_TABLE, ANNOTATION_TABLE, #NAME_TABLE, ENCOUNTER_TABLE, IMAGE_GRID, THUMB_TABLE, NAMES_TREE ] # table nice names
Per Name Incremental Version """ from __future__ import absolute_import, division, print_function import utool as ut import numpy as np from ibeis.algo.hots.smk import smk_debug from vtool import patch as ptool from vtool import image as gtool import six import scipy.stats.mstats as spms from os.path import join from os.path import basename import scipy.spatial.distance as spdist from collections import namedtuple (print, print_, printDBG, rrr, profile) = ut.inject(__name__, '[smk_plots]') Metrics = namedtuple('Metrics', ('wx2_nMembers', 'wx2_pdist_stats', 'wx2_wdist_stats',)) def vizualize_vocabulary(ibs, invindex): """ cleaned up version of dump_word_patches. Makes idf scatter plots and dumps the patches that contributed to each word. CommandLine: python -m ibeis.algo.hots.smk.smk_plots --test-vizualize_vocabulary python -m ibeis.algo.hots.smk.smk_plots --test-vizualize_vocabulary --vf Example:
# -*- coding: utf-8 -*- """ DEPRICATE: use TestResult instead not really used most things in here can be depricated """ from __future__ import absolute_import, division, print_function import utool import utool as ut from ibeis.expt import results_organizer from ibeis.expt import results_analyzer print, print_, printDBG, rrr, profile = utool.inject(__name__, '[results_all]', DEBUG=False) class AllResults(utool.DynStruct): """ Data container for all compiled results """ def __init__(allres): super(AllResults, allres).__init__(child_exclude_list=['qaid2_qres']) allres.ibs = None allres.qaid2_qres = None allres.allorg = None allres.cfgstr = None allres.dbname = None allres.qreq_ = None def get_orgtype(allres, orgtype): orgres = allres.allorg.get(orgtype)
# -*- coding: utf-8 -*- """ TODO: Rename to ibeis/init/commands.py TODO; remove params module """ from __future__ import absolute_import, division, print_function import utool as ut import sys from ibeis import constants as const from ibeis import params from ibeis.other import ibsfuncs from ibeis.init import sysres from os.path import join print, print_, printDBG, rrr, profile = ut.inject(__name__, '[commands]') def vdq(dbdir): """view directory and quit""" _ibsdb = const.PATH_NAMES._ibsdb ut.util_cplat.view_directory(join(dbdir, _ibsdb)) sys.exit(0) def vdd(ibs): " view data dir " ut.util_cplat.view_directory(ibs.dbdir) def vwd():
from __future__ import absolute_import, division, print_function from guitool.__PYQT__ import QtCore, QtGui from guitool import api_item_view from guitool.guitool_decorators import signal_, slot_ import utool (print, print_, printDBG, rrr, profile) = utool.inject(__name__, '[APITableView]', DEBUG=False) # If you need to set the selected index try: # AbstractItemView::setCurrentIndex # AbstractItemView::scrollTo # AbstractItemView::keyboardSearch API_VIEW_BASE = QtGui.QTableView #API_VIEW_BASE = QtGui.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): # Qt Inheritance API_VIEW_BASE.__init__(view, parent)
# -*- coding: utf-8 -*- #!/usr/bin/env python2.7 """ Converts a hotspostter database to IBEIS """ # TODO: ADD COPYRIGHT TAG from __future__ import absolute_import, division, print_function from os.path import join, exists from ibeis import constants as const from ibeis.init import sysres from six.moves import zip, map import utool as ut import re import csv print, print_, printDBG, rrr, profile = ut.inject(__name__, '[ingest_hsbd]') SUCCESS_FLAG_FNAME = '_hsdb_to_ibeis_convert_success' def is_hsdb(dbdir): return is_hsdbv4(dbdir) or is_hsdbv3(dbdir) def is_hsdbv4(dbdir): has4 = (exists(join(dbdir, '_hsdb')) and exists(join(dbdir, '_hsdb', 'name_table.csv')) and exists(join(dbdir, '_hsdb', 'image_table.csv')) and exists(join(dbdir, '_hsdb', 'chip_table.csv'))) return has4
#!/usr/bin/env python2.7 # -*- coding: utf-8 -*- from __future__ import absolute_import, division, print_function import utool from six.moves import range from ibeis.control import __SQLITE3__ as lite from os.path import join, realpath import random print, print_, printDBG, rrr, profile = utool.inject(__name__, '[TEST_SQL_REVERT]') def _val1(i): return i * 2 def _val2(i): return str(i * 2) + "_string" def test_query(connection, cur, _type, alter_callback, isolation_level, bound=10, transaction=True, commit=False): # Offset bound by 1 bound += 1 retval = True
""" Wrapper around flann (with caching) python -c "import vtool, doctest; print(doctest.testmod(vtool.nearest_neighbors))" """ from __future__ import absolute_import, division, print_function from os.path import exists, normpath, join import sys import utool import utool as ut # NOQA import numpy as np (print, print_, printDBG, rrr, profile) = utool.inject(__name__, '[nneighbs]') try: import pyflann except ImportError: print('Warning: pyflann failed to import') def test_cv2_flann(): """ Ignore: [name for name in dir(cv2) if 'create' in name.lower()] [name for name in dir(cv2) if 'stereo' in name.lower()] ut.grab_zipped_url('https://priithon.googlecode.com/archive/a6117f5e81ec00abcfb037f0f9da2937bb2ea47f.tar.gz', download_dir='.') """ import cv2 from vtool.tests import dummy import plottool as pt import vtool as vt
# -*- coding: utf-8 -*- # UTool import logging import utool (print, rrr, profile) = utool.inject2(__name__) logger = logging.getLogger('wbia') # Inject utool functions (print, print_, printDBG, rrr, profile) = utool.inject(__name__, '[preproc_rvecs]', DEBUG=False) def add_rvecs_params_gen(ibs, nInput=None): pass def generate_rvecs(vecs_list, words): pass
autogen_time = 13:34:34 2015/04/28 autogen_key = gar ToRegenerate: python -m ibeis.templates.template_generator --key gar --Tcfg with_web_api=True with_api_cache=False with_deleters=True no_extern_deleters=True --diff python -m ibeis.templates.template_generator --key gar --Tcfg with_web_api=True with_api_cache=False with_deleters=True no_extern_deleters=True --write """ from __future__ import absolute_import, division, print_function 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, print_, printDBG, rrr, profile = ut.inject(__name__, '[autogen_gar]') # 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_ibs(defaultdb='testdb1'): import ibeis ibs = ibeis.opendb(defaultdb=defaultdb) config2_ = None # qreq_.qparams return ibs, config2_
# -*- coding: utf-8 -*- from __future__ import absolute_import, division, print_function import six # NOQA from ibeis import constants as const from ibeis.control.accessor_decors import (adder, getter_1to1, ider) import utool as ut from ibeis.control.controller_inject import make_ibs_register_decorator print, print_, printDBG, rrr, profile = ut.inject(__name__, '[manual_lbltype]') CLASS_INJECT_KEY, register_ibs_method = make_ibs_register_decorator(__name__) @register_ibs_method @ider def _get_all_known_lblannot_rowids(ibs, _lbltype): """ Returns: list_ (list): all nids of known animals (does not include unknown names) """ all_known_lblannot_rowids = ibs.db.get_all_rowids_where(const.LBLANNOT_TABLE, 'lbltype_rowid=?', (ibs.lbltype_ids[_lbltype],)) return all_known_lblannot_rowids @register_ibs_method @adder def add_lbltype(ibs, text_list, default_list): """ Adds a label type and its default value Should only be called at the begining of the program. """ params_iter = zip(text_list, default_list)
#!/usr/bin/env python2.7 # -*- coding: utf-8 -*- # TODO: ADD COPYRIGHT TAG from __future__ import absolute_import, division, print_function import multiprocessing import utool from vtool.tests import grabdata print, print_, printDBG, rrr, profile = utool.inject(__name__, '[TEST_DELETE_FEATURE]') def TEST_DELETE_FEATURE(ibs, back): gpath_list = grabdata.get_test_gpaths(ndata=None)[0:4] gid_list = ibs.add_images(gpath_list) bbox_list = [(0, 0, 100, 100)] * len(gid_list) name_list = ['a', 'b', 'a', 'd'] aid_list = ibs.add_annots(gid_list, bbox_list=bbox_list, name_list=name_list) cid_list = ibs.add_annot_chips(aid_list) assert len(cid_list) != 0, "No chips added" fid_list = ibs.add_chip_feat(cid_list) assert len(fid_list) != 0, "No features added" fid = fid_list[0] ibs.delete_features(fid) fid_list = ibs.get_valid_fids() assert fid not in fid_list, "FID not deleted" return locals() if __name__ == '__main__':
sh Tinc.sh --test-test_inc_query:2 --num-init 0 --devcache --no-normcache --vsone-errs --test-title "GZ_DEV" --gzdev --ninit 34 --naac --interupt-case sh Tinc.sh --test-test_inc_query:2 --num-init 0 --devcache --no-normcache --vsone-errs --test-title "GZ_DEV" --gzdev --ninit 47 --naac --interupt-case """ from __future__ import absolute_import, division, print_function import six import utool as ut import numpy as np import vtool as vt from ibeis.algo.hots import hstypes from ibeis.algo.hots import match_chips4 as mc4 from ibeis.algo.hots import distinctiveness_normalizer from ibeis.algo.hots import automated_params from six.moves import filter print, print_, printDBG, rrr, profile = ut.inject(__name__, '[special_query]') # hack for tests if ut.in_main_process(): test_title = ut.get_argval('--test-title', type_=str, default=None) if test_title is not None: ut.change_term_title(test_title) USE_VSMANY_HACK = ut.get_argflag('--vsmany-hack') TEST_VSONE_ERRORS = ut.get_argflag(('--test-vsone-errors', '--vsone-errs')) TestTup = ut.namedtuple('TestTup', ('qaid_t', 'qaid', 'vsmany_rank', 'vsone_rank')) def testdata_special_query(dbname=None):
# -*- coding: utf-8 -*- """ This provides concrete classes which inherit from abstract api_item_models/api_table_models/api_tree_models in guitool. """ from __future__ import absolute_import, division, print_function import utool as ut from guitool import (APIItemModel, APITableView, APITreeView, APIItemWidget, StripeProxyModel, ChangeLayoutContext) print, print_, printDBG, rrr, profile = ut.inject(__name__, '[newgui_models]') #--------------------- # --- IBEIS Tables --- #--------------------- class IBEISTableWidget(APIItemWidget): def __init__(widget, headers=None, parent=None, *args): widget.ibswin = parent widget.imgsetid = None APIItemWidget.__init__(widget, headers=headers, parent=parent, model_class=IBEISStripeModel, view_class=IBEISTableView) class IBEISTreeWidget(APIItemWidget): def __init__(widget, headers=None, parent=None, *args): widget.ibswin = parent widget.imgsetid = None
from __future__ import absolute_import, division, print_function import utool import pandas as pd import numpy as np (print, print_, printDBG, rrr, profile) = utool.inject(__name__, '[pdh]') from ibeis.model.hots.hstypes import VEC_DIM, INTEGER_TYPE class LazyGetter(object): def __init__(self, getter_func): self.getter_func = getter_func def __getitem__(self, index): return self.getter_func(index) def __call__(self, index): return self.getter_func(index) #def lazy_getter(getter_func): # def lazy_closure(*args): # return getter_func(*args) # return lazy_closure class DataFrameProxy(object): """ pandas is actually really slow. This class emulates it so I don't have to change my function calls, but without all the slowness. """
development module storing my "development state" TODO: * figure out what packages I use have lisencing issues. - Reimplement them or work around them. Excplitict Negative Matches between chips """ from __future__ import absolute_import, division, print_function from ibeis.algo.hots import hstypes from uuid import UUID import utool as ut import copy import six # NOQA import numpy as np # NOQA print, print_, printDBG, rrr, profile = ut.inject(__name__, '[devcases]') def fix_pz_master(): r""" CommandLine: python -m ibeis.algo.hots.devcases --test-fix_pz_master --show Example: >>> # DISABLE_DOCTEST >>> from ibeis.algo.hots.devcases import * # NOQA >>> # build test data >>> # execute function >>> result = fix_pz_master() >>> # verify results >>> print(result)
#!/usr/bin/env python2.7 from __future__ import absolute_import, division, print_function import numpy as np import utool from ibeis.control import SQLDatabaseControl as sqldbc from ibeis.control._sql_helpers import _results_gen from os.path import join print, print_, printDBG, rrr, profile = utool.inject(__name__, '[TEST_SQL_NUMPY] ') # list of 10,000 chips with 3,000 features apeice. def grab_numpy_testdata(shape=(3e3, 128), dtype=np.uint8): ndata = utool.get_arg('--ndata', type_=int, default=2) print('[TEST] build ndata=%d numpy arrays with shape=%r' % (ndata, shape)) print(' * expected_memory(table_list) = %s' % utool.byte_str2(ndata * np.product(shape))) table_list = [np.empty(shape, dtype=dtype) for i in xrange(ndata)] print(' * memory+overhead(table_list) = %s' % utool.byte_str2(utool.get_object_size(table_list))) return table_list def TEST_SQL_NUMPY(): sqldb_fname = 'temp_test_sql_numpy.sqlite3' sqldb_dpath = utool.util_cplat.get_app_resource_dir('ibeis', 'testfiles') utool.ensuredir(sqldb_dpath) utool.util_path.remove_file(join(sqldb_dpath, sqldb_fname), dryrun=False) db = sqldbc.SQLDatabaseController(sqldb_dpath=sqldb_dpath, sqldb_fname=sqldb_fname) db.schema('temp', [ ('temp_id', 'INTEGER PRIMARY KEY'), ('temp_hash', 'NUMPY'),
#from ibeis.other import ibsfuncs #from ibeis.expt import results_organizer #from ibeis.viz import interact #from ibeis.viz import viz_helpers as vh #from plottool import fig_presenter #from plottool import interact_helpers as ih from plottool import imshow, close_figure, next_fnum from six.moves import range import guitool #import numpy as np #import six import utool import utool as ut from datetime import date, datetime from time import mktime (print, print_, printDBG, rrr, profile) = utool.inject(__name__, '[co_gui]') class ClockOffsetWidget(QtGui.QWidget): def __init__(co_wgt, ibs, gid_list, parent=None, hack=False): print('[co_gui] Initializing') print('[co_gui] gid_list = %r' % (gid_list,)) QtGui.QWidget.__init__(co_wgt, parent=parent) co_wgt.fnum = next_fnum() co_wgt.main_layout = QtGui.QVBoxLayout(co_wgt) co_wgt.text_layout = guitool.newWidget(co_wgt, orientation=Qt.Vertical, verticalStretch=10)
""" from __future__ import absolute_import, division, print_function import numpy as np import utool as ut from six.moves import zip from plottool import interact_helpers as ih import functools import plottool as pt from ibeis import viz from ibeis import constants as const from ibeis.viz import viz_helpers as vh from ibeis.other import ibsfuncs from ibeis.viz import viz_chip from plottool.abstract_interaction import AbstractInteraction (print, print_, printDBG, rrr, profile) = ut.inject(__name__, '[interact_name]', DEBUG=False) #========================== # Name Interaction #========================== MAX_COLS = 3 def build_name_context_options(ibs, nids): callback_list = [] from ibeis.viz import viz_graph callback_list.append( ('Interact name graph', functools.partial(viz_graph.make_name_graph_interaction, ibs, nids=nids)), )
#TODO: Licence from __future__ import absolute_import, division, print_function # Python import functools # Qt from PyQt4 import QtGui, QtCore from PyQt4.QtCore import Qt # IBEIS import utool from guitool import slot_, signal_ from ibeis.gui import rowidtables from ibeis.gui.Skeleton import Ui_mainSkel print, print_, printDBG, profile, rrr = utool.inject(__name__, '[front*]', DEBUG=False) QUIET = utool.get_flag('--quiet') VERBOSE = utool.get_flag(('--verbose', '--verbose-front', '--vf')) UID_TYPE = rowidtables.UID_TYPE ENC_TYPE = str # imagesets are ided with imagesettext right now QUTF8 = QtGui.QApplication.UnicodeUTF8 QTRANSLATE = QtGui.QApplication.translate #================= # Decorators / Helpers #================= def rowid_tbl_clicked(func):
from __future__ import absolute_import, division, print_function # UTool import utool import vtool.exif as exif from PIL import Image from os.path import splitext, basename import numpy as np import hashlib import uuid from utool import util_time (print, print_, printDBG, rrr, profile) = utool.inject(__name__, '[preproc_img]', DEBUG=False) GPSInfo_TAGID = exif.EXIF_TAG_TO_TAGID['GPSInfo'] DateTimeOriginal_TAGID = exif.EXIF_TAG_TO_TAGID['DateTimeOriginal'] @profile def parse_exif(pil_img): """ Image EXIF helper <CYTH: returns=str> cdef: Image pil_img dict exif_dict tuple latlon long lat long lon long exiftime </CYTH> """ exif_dict = exif.get_exif_dict(pil_img)
from guitool import api_tree_view from guitool import api_item_widget from guitool import stripe_proxy_model from guitool import guitool_tables from guitool import guitool_dialogs from guitool import guitool_decorators from guitool import guitool_delegates from guitool import guitool_components from guitool import guitool_main from guitool import guitool_misc from guitool import qtype import utool print, print_, printDBG, rrr, profile = utool.inject(__name__, '[guitool]') def reload_subs(): """Reloads utool and submodules """ rrr() if hasattr(guitool_tables, 'rrr'): guitool_tables.rrr() if hasattr(guitool_dialogs, 'rrr'): guitool_dialogs.rrr() if hasattr(guitool_decorators, 'rrr'): guitool_decorators.rrr() if hasattr(guitool_main, 'rrr'): guitool_main.rrr() if hasattr(guitool_misc, 'rrr'): guitool_misc.rrr()
#!/usr/bin/env python2.7 # TODO: ADD COPYRIGHT TAG from __future__ import absolute_import, division, print_function import multiprocessing import utool print, print_, printDBG, rrr, profile = utool.inject(__name__, '[TEST_DELETE_ENC]') def TEST_DELETE_ENC(ibs, back): from ibeis.dev import ibsfuncs ibsfuncs.update_all_image_encounter(ibs) eid_list = ibs.get_valid_eids() assert len(eid_list) != 0, "All Image encounter not created" eid = eid_list[0] ibs.delete_encounters(eid) eid_list = ibs.get_valid_eids() assert eid not in eid_list, "eid=%r still exists" % (eid,) return locals() if __name__ == '__main__': multiprocessing.freeze_support() # For windows import ibeis main_locals = ibeis.main(defaultdb='testdb1', gui=False) ibs = main_locals['ibs'] # IBEIS Control back = main_locals['back'] # IBEIS GUI backend test_locals = utool.run_test(TEST_DELETE_ENC, ibs, back) exec(utool.execstr_dict(test_locals, 'test_locals')) exec(utool.ipython_execstr())
#!/usr/bin/env python2.7 # -*- coding: utf-8 -*- from __future__ import absolute_import, division, print_function from six.moves import range import numpy as np import utool from ibeis.control import SQLDatabaseControl as sqldbc from ibeis.control._sql_helpers import _results_gen from os.path import join print, print_, printDBG, rrr, profile = utool.inject(__name__, '[TEST_SQL_NUMPY] ') # list of 10,000 chips with 3,000 features apeice. def grab_numpy_testdata(shape=(3e3, 128), dtype=np.uint8): ndata = utool.get_argval('--ndata', type_=int, default=2) print('[TEST] build ndata=%d numpy arrays with shape=%r' % (ndata, shape)) print(' * expected_memory(table_list) = %s' % utool.byte_str2(ndata * np.product(shape))) table_list = [np.empty(shape, dtype=dtype) for i in range(ndata)] print(' * memory+overhead(table_list) = %s' % utool.byte_str2(utool.get_object_size(table_list))) return table_list def TEST_SQL_NUMPY(): sqldb_fname = 'temp_test_sql_numpy.sqlite3' sqldb_dpath = utool.util_cplat.get_app_resource_dir('ibeis', 'testfiles') utool.ensuredir(sqldb_dpath) utool.util_path.remove_file(join(sqldb_dpath, sqldb_fname), dryrun=False) db = sqldbc.SQLDatabaseController(sqldb_dpath=sqldb_dpath,
# DEPRICATE? from __future__ import absolute_import, division, print_function from guitool.__PYQT__ import QtCore, QtGui from guitool.__PYQT__.QtCore import Qt from guitool.guitool_delegates import ComboDelegate, ButtonDelegate from guitool import qtype from six.moves import range, map import utool (print, print_, printDBG, rrr, profile) = utool.inject(__name__, "[guitbls]", DEBUG=False) class ColumnListTableView(QtGui.QTableView): """ Table View for an AbstractItemModel """ def __init__(view, *args, **kwargs): super(ColumnListTableView, view).__init__(*args, **kwargs) view.setSortingEnabled(True) view.vertical_header = view.verticalHeader() view.vertical_header.setVisible(True) # view.setSelectionBehavior(QtGui.QAbstractItemView.SelectRows) view.resizeColumnsToContents() @QtCore.pyqtSlot() def cellButtonClicked(self): print(self.sender()) print(self.sender().text()) class ColumnListItemModel(QtCore.QAbstractTableModel): """ Item model for displaying a list of columns """
# -*- coding: utf-8 -*- """ DEPRICATE module which uses multiple flann indexes as a way of working around adding points to a single flann structure which seems to cause crashes. """ from __future__ import absolute_import, division, print_function import six from six.moves import zip, map, range import numpy as np import utool as ut import vtool as vt from ibeis.algo.hots import neighbor_index_cache from ibeis.algo.hots import hstypes (print, rrr, profile) = ut.inject(__name__) USE_FORGROUND_REINDEX = ut.get_argflag(('--use-foreground-reindex', '--fg-reindex')) def testdata_mindexer(): import ibeis ibs = ibeis.opendb(db='PZ_MTEST') daid_list = ibs.get_valid_aids()[1:60] cfgdict = dict(fg_on=False) qreq_ = ibs.new_query_request(daid_list, daid_list, cfgdict=cfgdict) index_method = 'name' mxer = request_ibeis_mindexer(qreq_, index_method) return mxer, qreq_, ibs
#!/usr/bin/env python2.7 # -*- coding: utf-8 -*- # TODO: ADD COPYRIGHT TAG from __future__ import absolute_import, division, print_function # Python import multiprocessing # Tools import utool from functools import partial print, print_, printDBG, rrr, profile = utool.inject(__name__, '[TIME_GEN_PREPROC]') def timeit2(stmt, setup='', number=1000): import timeit stmt_ = utool.unindent(stmt) setup_ = utool.unindent(setup) print('----------') print('TIMEIT: \n' + stmt_) try: total_time = timeit.timeit(stmt_, setup_, number=number) except Exception as ex: utool.printex(ex, iswarning=False) raise print(' * timed: %r seconds' % (total_time)) @profile def TIME_GEN_PREPROC_IMG(ibs): from ibeis.algo.preproc.preproc_image import add_images_params_gen print('[TIME_GEN_PREPROC_IMG]')
from __future__ import absolute_import, division, print_function import utool import guitool import numpy as np from plottool import draw_func2 as df2 from ibeis import viz from plottool.viz_featrow import draw_feat_row from ibeis.viz import viz_helpers as vh from plottool import interact_helpers as ih from .interact_chip import ishow_chip (print, print_, printDBG, rrr, profile) = utool.inject(__name__, '[interact_matches]', DEBUG=False) class LastState(object): def __init__(last_state): last_state.same_fig = None last_state.last_fx = None def ishow_matches(ibs, qres, aid=None, fnum=4, figtitle='Inspect Query Result', same_fig=True, **kwargs): """ Plots a chip result and sets up callbacks for interaction. """ fig = ih.begin_interaction('matches', fnum) qaid = qres.qaid if aid is None: aid = qres.get_top_aids(num=1)[0] rchip1, rchip2 = ibs.get_annot_chips([qaid, aid]) fm = qres.aid2_fm[aid] mx = kwargs.pop('mx', None) xywh2_ptr = [None] annote_ptr = [kwargs.pop('mode', 0)]
# -*- coding: utf-8 -*- """ This file is in a state of disarray. It is not included anywhere. Yet it might have useful code in it """ from __future__ import absolute_import, division, print_function import utool (print, print_, rrr, profile, printDBG) = utool.inject(__name__, '[classifier]', DEBUG=False) # Science import numpy as np # HotSpotter from ibeis.model.hots import report_results2 as rr2 def get_gt_cases(ibs): valid_aids = ibs.get_valid_aids() aid_list = [ aid for aid in valid_aids if len(ibs.get_annot_groundtruth(aid)) > 0 ] return aid_list def get_lblannoted_descriptors(allres, orgtype_='false'): qcxs = allres[orgtype_].qcxs aids = allres[orgtype_].aids match_list = zip(qcxs, aids) aggdesc1, aggdesc2 = rr2.get_matching_descriptors(allres, match_list) return aggdesc1, aggdesc2
# flake8: noqa from __future__ import absolute_import, division, print_function import numpy as np from plottool import draw_func2 as df2 from vtool import keypoint as ktool from utool import util_latex from ibeis.model import Config import utool print, print_, printDBG, rrr, profile = utool.inject(__name__, '[devport]', DEBUG=False) def plot_keypoint_scales(hs, fnum=1): print('[dev] plot_keypoint_scales()') cx2_kpts = hs.feats.cx2_kpts if len(cx2_kpts) == 0: hs.refresh_features() cx2_kpts = hs.feats.cx2_kpts cx2_nFeats = map(len, cx2_kpts) kpts = np.vstack(cx2_kpts) print('[dev] --- LaTeX --- ') _printopts = np.get_printoptions() np.set_printoptions(precision=3) print(util_latex.latex_scalar(r'\# keypoints, ', len(kpts))) print(util_latex.latex_mystats(r'\# keypoints per image', cx2_nFeats)) scales = ktool.get_scales(kpts) scales = np.array(sorted(scales)) print(util_latex.latex_mystats(r'keypoint scale', scales)) np.set_printoptions(**_printopts) print('[dev] ---/LaTeX --- ') # df2.figure(fnum=fnum, docla=True, title='sorted scales')
#!/usr/bin/env python2.7 # TODO: ADD COPYRIGHT TAG from __future__ import absolute_import, division, print_function import multiprocessing import utool from vtool.tests import grabdata from ibeis.model.preproc import preproc_image from PIL import Image print, print_, printDBG, rrr, profile = utool.inject(__name__, '[TEST_PIL_HASH]') def TEST_PIL_HASH(): print('[TEST] GET_TEST_IMAGE_PATHS') # The test api returns a list of interesting chip indexes gpath_list = grabdata.get_test_gpaths(ndata=None) pil_img_list = [Image.open(gpath, 'r') for gpath in gpath_list] uuid_list = [preproc_image.get_image_uuid(pil_img) for pil_img in pil_img_list] unique_uuid_list = list(set(uuid_list)) assert len(uuid_list) == len(unique_uuid_list), 'Reinstall PIL, watch for libjpeg' return locals() if __name__ == '__main__': multiprocessing.freeze_support() # For win32 test_locals = utool.run_test(TEST_PIL_HASH) execstr = utool.execstr_dict(test_locals, 'test_locals') exec(execstr)
# flake8: noqa from __future__ import absolute_import, division, print_function, unicode_literals import utool as ut ut.noinject(__name__, '[ibeis.algo.preproc.__init__]', DEBUG=False) from ibeis.algo.preproc import preproc_chip from ibeis.algo.preproc import preproc_detectimg from ibeis.algo.preproc import preproc_encounter from ibeis.algo.preproc import preproc_feat from ibeis.algo.preproc import preproc_featweight from ibeis.algo.preproc import preproc_image from ibeis.algo.preproc import preproc_probchip from ibeis.algo.preproc import preproc_residual from ibeis.algo.preproc import preproc_rvec import utool print, print_, printDBG, rrr, profile = utool.inject( __name__, '[ibeis.algo.preproc]') def reload_subs(verbose=True): """ Reloads ibeis.algo.preproc and submodules """ rrr(verbose=verbose) def fbrrr(*args, **kwargs): """ fallback reload """ pass #getattr(preproc_annot, 'rrr', fbrrr)(verbose=verbose) getattr(preproc_chip, 'rrr', fbrrr)(verbose=verbose) getattr(preproc_detectimg, 'rrr', fbrrr)(verbose=verbose) getattr(preproc_encounter, 'rrr', fbrrr)(verbose=verbose) getattr(preproc_feat, 'rrr', fbrrr)(verbose=verbose) getattr(preproc_featweight, 'rrr', fbrrr)(verbose=verbose) getattr(preproc_image, 'rrr', fbrrr)(verbose=verbose)
from __future__ import absolute_import, division, print_function import utool print, print_, printDBG, rrr, profile = utool.inject(__name__, '[cfgbank]') # Python exclude_vars = vars().keys() # this line is before tests vsmany_2 = { 'query_type': ['vsmany'], 'checks': [1024], # , 8192], 'K': [5], # 5, 10], 'Knorm': [1], # 2, 3], 'Krecip': [0], # , 5, 10], 'bboxdist_weight': [0], # 1,] 'recip_weight': [0], # 1,] 'bursty_weight': [0], # 1,] 'ratio_weight': [0, 1], # 1,] 'lnbnn_weight': [0, 1], # 1,] 'lnrat_weight': [0, 1], # 1,] 'bboxdist_thresh': [None], # .5,] 'recip_thresh': [0], # 0 'bursty_thresh': [None], # 'ratio_thresh': [None], # 1.2, 1.6 'lnbnn_thresh': [None], # 'lnrat_thresh': [None], # 'nShortlist': [50], 'sv_on': [True], # True, False], 'score_method': ['csum'], 'max_alts': [1000], }
#flake8:noqa from __future__ import absolute_import, division, print_function from os.path import join from plottool import draw_func2 as df2 import numpy as np import os import utool print, print_, printDBG, rrr, profile = utool.inject(__name__, '[viz_allres]', DEBUG=False) # Global variables BROWSE = True DUMP = False FIGNUM = 1 def plot_rank_stem(allres, orgres_type='true'): print('[viz] plotting rank stem') # Visualize rankings with the stem plot ibs = allres.ibs title = orgres_type + 'rankings stem plot\n' + allres.title_suffix orgres = allres.__dict__[orgres_type] df2.figure(fnum=FIGNUM, doclf=True, title=title) x_data = orgres.qcxs y_data = orgres.ranks df2.draw_stems(x_data, y_data) slice_num = int(np.ceil(np.log10(len(orgres.qcxs)))) df2.set_xticks(ibs.test_sample_cx[::slice_num]) df2.set_xlabel('query chip indeX (qcx)') df2.set_ylabel('groundtruth chip ranks') #df2.set_yticks(list(seen_ranks)) __dump_or_browse(allres.ibs, 'rankviz')
# Scientific import numpy as np from vtool import keypoint as ktool from vtool import linalg as ltool from vtool import spatial_verification as sver # Hotspotter from ibeis.model.hots import hots_query_result from ibeis.model.hots import exceptions as hsexcept from ibeis.model.hots import coverage_image from ibeis.model.hots import nn_filters from ibeis.model.hots import voting_rules2 as vr2 import utool from functools import partial #profile = utool.profile print, print_, printDBG, rrr, profile = utool.inject(__name__, '[mf]', DEBUG=False) np.tau = 2 * np.pi # tauday.com NOT_QUIET = utool.NOT_QUIET and not utool.get_flag('--quiet-query') VERBOSE = utool.VERBOSE or utool.get_flag('--verbose-query') #================= # Cython Metadata #================= """ ctypedef np.float32_t float32_t ctypedef np.float64_t float64_t ctypedef np.uint8_t uint8_t ctypedef np.uint8_t desc_t ctypedef ktool.KPTS_T kpts_t
# -*- coding: utf-8 -*- """ TODO: DEPRICATE WITH QRES IBEIS AGNOSTIC DEFINITIONS ARE NOW IN VTOOL """ from __future__ import absolute_import, division, print_function import utool as ut import numpy as np (print, print_, printDBG, rrr, profile) = ut.inject(__name__, '[precision_recall]', DEBUG=False) def get_nTruePositive(atrank, was_retrieved, gt_ranks): """ the number of documents we got right """ TP = (np.logical_and(was_retrieved, gt_ranks <= atrank)).sum() return TP def get_nFalseNegative(TP, atrank, nGroundTruth): """ the number of documents we should have retrieved but didn't """ #FN = min((atrank + 1) - TP, nGroundTruth - TP) #nRetreived = (atrank + 1) FN = nGroundTruth - TP #min(atrank, nGroundTruth - TP) return FN def get_nFalsePositive(TP, atrank): """ the number of documents we should not have retrieved """
#!/usr/bin/env python2.7 from __future__ import absolute_import, division, print_function import utool from ibeis.control import __SQLITE3__ as lite from os.path import join, realpath import random print, print_, printDBG, rrr, profile = utool.inject(__name__, '[TEST_SQL_REVERT]') def _val1(i): return i * 2 def _val2(i): return str(i * 2) + "_string" def test_query(connection, cur, _type, alter_callback, isolation_level, bound=10, transaction=True, commit=False): # Offset bound by 1 bound += 1 retval = True # Clear test data operation = ''' DELETE FROM test WHERE rowid > 0 ''' cur.execute(operation, []) # Add dummy data and commit it for i in xrange(1, bound): operation = ''' INSERT INTO test (
#!/usr/bin/env python2.7 # TODO: ADD COPYRIGHT TAG from __future__ import absolute_import, division, print_function # Python import multiprocessing # Tools import utool print, print_, printDBG, rrr, profile = utool.inject(__name__, '[TEST_HOTS_SPLITTREE]') def TEST_HOTS_SPLITTREE(ibs): from ibeis.model.hots.hots_nn_index import NNSplitIndex num_forests = 8 daid_list = ibs.get_valid_aids() num_neighbors = 3 qfx2_desc = ibs.get_annot_desc(daid_list[2]) split_index = NNSplitIndex(ibs, daid_list, num_forests=num_forests) #nid_list = ibs.get_annot_nids(aid_list) ##flag_list = ibs.get_annot_exemplar_flag(aid_list) #nid2_aids = utool.group_items(aid_list, nid_list) #key_list = nid2_aids.keys() #val_list = nid2_aids.values() #isunknown_list = ibs.is_nid_unknown(key_list) #num_forests = 8 ## Put one name per forest #forest_aids, overflow_aids = utool.sample_zip(val_list, num_forests, allow_overflow=True) #forest_indexes = []
#!/usr/bin/env python2.7 # -*- coding: utf-8 -*- """ Converts an IBEIS database to a hotspotter db """ # TODO: ADD COPYRIGHT TAG from __future__ import absolute_import, division, print_function from six.moves import map from os.path import join, relpath # import ibeis import utool as ut print, print_, printDBG, rrr, profile = ut.inject(__name__, "[export_hsdb]") def get_hsdb_image_gpaths(ibs, gid_list): r""" Args: ibs (IBEISController): ibeis controller object gid_list (list): Returns: list: gpath_list CommandLine: python -m ibeis.dbio.export_hsdb --test-get_hsdb_image_gpaths Example: >>> # ENABLE_DOCTEST >>> from ibeis.dbio.export_hsdb import * # NOQA
""" smk core """ from __future__ import absolute_import, division, print_function #import six from six.moves import zip from itertools import product import utool #import pandas as pd import numpy as np import scipy.sparse as spsparse from ibeis.algo.hots import hstypes from ibeis.algo.hots.smk import smk_scoring from vtool import clustering2 as clustertool (print, print_, printDBG, rrr, profile) = utool.inject(__name__, '[smk_core]') DEBUG_SMK = utool.DEBUG2 or utool.get_argflag('--debug-smk') @profile def accumulate_scores(dscores_list, daids_list): """ helper to accumulate grouped scores for database annotations """ daid2_aggscore = utool.ddict(lambda: 0) ### Weirdly iflatten was slower here for dscores, daids in zip(dscores_list, daids_list): for daid, score in zip(daids, dscores): daid2_aggscore[daid] += score daid_agg_keys = np.array(list(daid2_aggscore.keys())) daid_agg_scores = np.array(list(daid2_aggscore.values())) return daid_agg_keys, daid_agg_scores
#!/usr/bin/env python2.7 from __future__ import absolute_import, division, print_function import utool import vtool.spatial_verification as sver from plottool import draw_sv from plottool import draw_func2 as df2 import numpy as np import vtool.tests.dummy as dummy import vtool.keypoint as ktool # NOQA import vtool.linalg as ltool # NOQA from vtool.keypoint import * # NOQA from vtool.spatial_verification import * # NOQA (print, print_, printDBG, rrr, profile) = utool.inject(__name__, '[tets_sv]', DEBUG=False) xy_thresh = ktool.KPTS_DTYPE(.009) scale_thresh_sqrd = ktool.KPTS_DTYPE(2) TAU = np.pi * 2.0 # References: tauday.com ori_thresh = ktool.KPTS_DTYPE(TAU / 4.0) def test_sver(chip1, chip2, kpts1, kpts2, fm, nShow=6): r""" Args: chip1 (ndarray[uint8_t, ndim=2]): annotation image data chip2 (ndarray[uint8_t, ndim=2]): annotation image data kpts1 (ndarray[float32_t, ndim=2]): keypoints kpts2 (ndarray[float32_t, ndim=2]): keypoints fm (list): list of feature matches as tuples (qfx, dfx) nShow (int):
# -*- coding: utf-8 -*- from __future__ import absolute_import, division, print_function, unicode_literals import plottool.draw_func2 as df2 import numpy as np from ibeis.other import ibsfuncs from plottool import plot_helpers as ph import plottool as pt import utool as ut from ibeis.viz import viz_chip (print, print_, printDBG, rrr, profile) = ut.inject(__name__, '[viz]', DEBUG=False) def show_name_of(ibs, aid, **kwargs): nid = ibs.get_annot_names(aid) show_name(ibs, nid, sel_aids=[aid], **kwargs) def testdata_showname(): import ibeis ibs = ibeis.opendb(defaultdb='testdb1') default = None if ibs.dbname == 'testdb1': default = 'easy' name_text = ut.get_argval('--name', type_=str, default=default) if name_text is None: nid = 1 else: nid = ibs.get_name_rowids_from_text(name_text)
#!/usr/bin/env python2.7 from __future__ import absolute_import, division, print_function from itertools import izip # noqa import functools # NOQA from PyQt4 import QtGui, QtCore from guitool import signal_, slot_, checks_qt_error, ChangeLayoutContext # NOQA from ibeis.control import IBEISControl from ibeis.dev import ibsfuncs from ibeis.gui import guiheaders as gh from ibeis.gui.guiheaders import NAMES_TREE from ibeis.gui.models_and_views import IBEISTableModel, IBEISTreeView import guitool import utool print, print_, printDBG, rrr, profile = utool.inject(__name__, '[newgui]') IBEIS_WIDGET_BASE = QtGui.QWidget ############################# ###### Window Widgets ####### ############################# class IBEISGuiWidget(IBEIS_WIDGET_BASE): #@checks_qt_error def __init__(ibswgt, ibs=None, parent=None): IBEIS_WIDGET_BASE.__init__(ibswgt, parent) ibswgt.ibs = ibs ibswgt.tblname_list = [NAMES_TREE] # Create and layout components
# TODO: Rename api_item_model from __future__ import absolute_import, division, print_function from guitool.__PYQT__ import QtCore # NOQA from types import GeneratorType from six.moves import zip, range import utool import utool as ut (print, print_, printDBG, rrr, profile) = utool.inject(__name__, '[tree_node]', DEBUG=False) TREE_NODE_BASE = QtCore.QObject #TREE_NODE_BASE = object VERBOSE = utool.VERBOSE or ut.get_argflag(('--verbose-qt', '--verbqt')) class TreeNode(TREE_NODE_BASE): """ Cyth: cdef: long id_, level list child_nodes TreeNode parent_node """ #__slots__ = ('id_', 'parent_node', 'child_nodes', 'level',) def __init__(self, id_, parent_node, level): TREE_NODE_BASE.__init__(self, parent=parent_node) #super(TreeNode, self).__init__(parent_node) #if TREE_NODE_BASE is not object: #if VERBOSE: # print('[TreeNode] __init__') #super(TreeNode, self).__init__(parent=parent_node)
# -*- coding: utf-8 -*- import utool as ut from wbia import viz from wbia.viz import viz_helpers as vh from wbia.plottool import draw_func2 as df2 from wbia.plottool import interact_helpers as ih (print, print_, printDBG, rrr, profile) = ut.inject(__name__, '[interact_img]', DEBUG=False) # @ut.indent_func def ishow_image(ibs, gid, sel_aids=[], fnum=None, select_callback=None, **kwargs): if ut.VERBOSE: print(ut.get_caller_name(range(9))) print('[interact_image] gid=%r fnum=%r' % (gid, fnum)) if fnum is None: fnum = df2.next_fnum() # TODO: change to class based structure self = ut.DynStruct() self.fnum = fnum fig = ih.begin_interaction('image', fnum) # printDBG(utool.func_str(interact_image, [], locals())) kwargs['draw_lbls'] = kwargs.get('draw_lbls', True)
# developer convenience functions for ibs from __future__ import absolute_import, division, print_function import utool from six.moves import zip from itertools import izip from ibeis import constants from ibeis.dev import ibsfuncs # Inject utool functions (print, print_, printDBG, rrr, profile) = utool.inject(__name__, '[duct_tape]', DEBUG=False) def fix_compname_configs(ibs): """ duct tape to keep version in check """ #ibs.MANUAL_CONFIG_SUFFIX = '_MANUAL_' #+ utool.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_'), izip(configid_list, cfgsuffix_list)): print("EVALUATING: %r, %r" % (rowid, suffix)) # Fix the tables with bad config_rowids ibs.db.executeone( '''
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 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, print_, printDBG, rrr, profile) = ut.inject( __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 }
# -*- coding: utf-8 -*- from __future__ import absolute_import, division, print_function import utool (print, print_, rrr, profile, printDBG) = utool.inject(__name__, '[imageset]', DEBUG=False) # Python import six from six.moves import zip, range # Science import networkx as netx import numpy as np # HotSpotter from ibeis.model.hots import match_chips3 as mc3 import utool def build_imageset_ids(ex2_gxs, gid2_clusterid): USE_STRING_ID = True gid2_imgsetid = [None] * len(gid2_clusterid) for ex, gids in enumerate(ex2_gxs): for gid in gids: nGx = len(gids) gid2_imgsetid[gid] = ( 'ex=%r_nGxs=%d' % (ex, nGx) if USE_STRING_ID else ex + (nGx / 10**np.ceil(np.log(nGx) / np.log(10)))) def get_chip_imagesets(ibs): gid2_ex, ex2_gxs = compute_occurrences(ibs) # NOQA
#!/usr/bin/env python2.7 # TODO: ADD COPYRIGHT TAG from __future__ import absolute_import, division, print_function import multiprocessing import utool import numpy as np from ibeis.dev import sysres from vtool.tests import grabdata import ibeis print, print_, printDBG, rrr, profile = utool.inject(__name__, '[TEST_GUI_ALL]') np.tau = 2 * np.pi def TEST_GUI_ALL(ibs, back, gpath_list): """ Creates a new database Adds test images Creates dummy ANNOTATIONS Selects things """ # DELETE OLD print('[TEST] DELETE_OLD_DATABASE') work_dir = sysres.get_workdir() new_dbname = 'testdb_guiall' new_dbdir = utool.truepath(utool.join(work_dir, new_dbname)) ibs_dbdir = utool.truepath(ibs.dbdir) msg = 'must start in different dir new_dbdir=%r != ibs_dbdir=%r,' % (new_dbdir, ibs_dbdir) assert new_dbdir != ibs_dbdir, msg print('passed: ' + msg) utool.delete(new_dbdir, ignore_errors=False) #
from __future__ import absolute_import, division, print_function import utool import plottool.draw_func2 as df2 from plottool.viz_keypoints import _annotate_kpts from plottool import viz_image2 from . import viz_helpers as vh from . import viz_image (print, print_, printDBG, rrr, profile) = utool.inject(__name__, '[viz_chip]', DEBUG=False) @utool.indent_func def show_chip(ibs, aid, in_image=False, annote=True, **kwargs): """ Driver function to show chips """ printDBG('[viz] show_chip()') vh.ibsfuncs.assert_valid_aids(ibs, (aid,)) #utool.embed() # Get chip chip = vh.get_chips(ibs, aid, in_image, **kwargs) # Create chip title chip_text = vh.get_annot_texts(ibs, [aid], **kwargs)[0] # Draw chip fig, ax = df2.imshow(chip, **kwargs) # Populate axis user data vh.set_ibsdat(ax, 'viztype', 'chip') vh.set_ibsdat(ax, 'aid', aid) if annote and not kwargs.get('nokpts', False): # Get and draw keypoints kpts = vh.get_kpts(ibs, aid, in_image, **kwargs) _annotate_kpts(kpts, **kwargs) df2.upperleft_text(chip_text, color=kwargs.get('text_color', None))
### __init__.py ### # flake8: noqa from __future__ import absolute_import, division, print_function import utool as ut ut.noinject(__name__, "[ibeis.control.__init__]", DEBUG=False) from ibeis.control import DB_SCHEMA from ibeis.control import IBEISControl from ibeis.control import _sql_helpers from ibeis.control import accessor_decors import utool print, print_, printDBG, rrr, profile = utool.inject(__name__, "[ibeis.control]") def reload_subs(verbose=True): """ Reloads ibeis.control and submodules """ rrr(verbose=verbose) getattr(DB_SCHEMA, "rrr", lambda verbose: None)(verbose=verbose) getattr(IBEISControl, "rrr", lambda verbose: None)(verbose=verbose) getattr(SQLDatabaseControl, "rrr", lambda verbose: None)(verbose=verbose) getattr(_sql_helpers, "rrr", lambda verbose: None)(verbose=verbose) getattr(accessor_decors, "rrr", lambda verbose: None)(verbose=verbose) rrr(verbose=verbose) rrrr = reload_subs
#!/usr/bin/env python2.7 from __future__ import absolute_import, division, print_function import utool import numpy as np from numpy.random import randint try: import pyflann except ImportError: pass (print, print_, printDBG, rrr, profile) = utool.inject(__name__, '[test_pyflann]', DEBUG=False) """ remove_points does not currently have bindings nn_radius has incorrect binindgs class FLANN: __del__(self) __init__(self, **kwargs) build_index(self, pts, **kwargs) delete_index(self, **kwargs) add_points(self, pts, rebuild_threshold=2) hierarchical_kmeans(self, pts, branch_size, num_branches, max_iterations=None, dtype=None, **kwargs) kmeans(self, pts, num_clusters, max_iterations=None, dtype=None, **kwargs) nn(self, pts, qpts, num_neighbors=1, **kwargs) nn_index(self, qpts, num_neighbors=1, **kwargs) nn_radius(self, qpts, radius, **kwargs)
# -*- coding: utf-8 -*- from __future__ import absolute_import, division, print_function, unicode_literals import utool as ut from ibeis.viz import viz_helpers as vh from vtool import image as gtool from ibeis.algo.detect import randomforest from os.path import splitext from plottool import viz_image2 import plottool as pt (print, print_, printDBG, rrr, profile) = ut.inject( __name__, '[viz_hough]', DEBUG=False) def show_hough_image(ibs, gid, species=None, fnum=None, **kwargs): if fnum is None: fnum = pt.next_fnum() title = 'Hough Image: ' + vh.get_image_titles(ibs, gid) print(title) if species is None: species = ibs.cfg.detect_cfg.species_text src_gpath_list = ibs.get_image_detectpaths([gid]) dst_gpath_list = [splitext(gpath)[0] for gpath in src_gpath_list] hough_gpath_list = [gpath + '_' + species + '_hough.png' for gpath in dst_gpath_list] # Detect with hough config = { 'output_gpath_list': hough_gpath_list, } results_list = list(randomforest.detect_gpath_list_with_species(ibs, src_gpath_list, species, **config)) # NOQA # Get path hough_gpath = hough_gpath_list[0]
import plottool as pt import ibeis if __name__ == '__main__': multiprocessing.freeze_support() ibeis._preload() #from ibeis.all_imports import * # NOQA #utool.util_importer.dynamic_import(__name__, ('_devcmds_ibeis', None), # developing=True) from ibeis._devcmds_ibeis import * # NOQA # IBEIS from ibeis.init import main_helpers # NOQA from ibeis.other import dbinfo # NOQA from ibeis.expt import experiment_configs # NOQA from ibeis.expt import harness # NOQA from ibeis import params # NOQA print, print_, printDBG, rrr, profile = utool.inject(__name__, '[dev]') #------------------ # DEV DEVELOPMENT #------------------ # This is where you write all of the functions that will become pristine # and then go in _devcmds_ibeis.py """ ./dev.py -e print_results --db PZ_Master1 -a varysize_pzm:dper_name=[1,2],dsize=1500 -t candidacy_k:K=1 --intersect_hack ./dev.py -e draw_rank_cdf -t baseline -a baseline --show --db PZ_Master1 ./dev.py -e get_dbinfo --db PZ_Master1 --aid_list=baseline ./dev.py -e get_dbinfo --db PZ_MTEST ./dev.py -e get_dbinfo --db PZ_Master1 --aid_list=baseline --hackshow-unixtime --show
from __future__ import absolute_import, division, print_function import ibeis from os.path import isfile, join, exists, expanduser from ibeis.algo.detect.classifier.model import Classifier_Model from os import listdir import utool as ut import vtool as vt import numpy as np import cv2 try: from jpcnn.core import JPCNN_Network, JPCNN_Data except: print('[ibeis.algo.detect] WARNING: Could not load CNN library for some detectors (ignore for now)') pass print, print_, printDBG, rrr, profile = ut.inject( __name__, '[classifier]') MODEL_DOMAIN = 'https://lev.cs.rpi.edu/public/models/' MODEL_URLS = { 'v1' : 'classifier.v1.npy', } def load_classifier(source_path=None, source_name='classifier', cache_data_filename='data.npy', cache_labels_filename='labels.npy', cache=True, **kwargs): if source_path is None: source_path = expanduser(join('~', 'Desktop', 'extracted'))
#!/usr/bin/env python2.7 # -*- coding: utf-8 -*- # TODO: ADD COPYRIGHT TAG """ Tests IBEIS parallel """ from __future__ import absolute_import, division, print_function import multiprocessing import utool import pyhesaff from utool import util_parallel from vtool.tests import grabdata print, print_, printDBG, rrr, profile = utool.inject(__name__, '[TEST_PARALLEL]') #utool.inject_all() def TEST_PARALLEL(): gpath_list = grabdata.get_test_gpaths(ndata=10, names=['zebra', 'lena', 'jeff']) args_list = [(gpath, ) for gpath in gpath_list] @utool.argv_flag_dec def print_test_results(result_list): for kpts, desc in result_list: print('[test] kpts.shape=(%4d, %d), desc.sum=%8d' % (kpts.shape[0], kpts.shape[1], desc.sum())) hesaff_kwargs = {'scale_min': -1, 'scale_max': -1, 'nogravity_hack': False} with utool.Timer('c++ parallel'):