Beispiel #1
0
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
Beispiel #2
0
def change_names(ibs, qaid_list):
    #next_name = utool.get_arg('--name', str, default='<name>_the_<species>')
    next_name = utool.get_arg('--name', str, default='glob')
    for aid in qaid_list:
        ibs.print_name_table()
        #(nid,) = ibs.add_names((next_name,))
        ibs.set_annot_names(aid, next_name)
        ibs.print_name_table()
        ibs.print_annotation_table()
Beispiel #3
0
def TEST_INTERACT(ibs):

    valid_gids = ibs.get_valid_gids()
    valid_aids = ibs.get_valid_aids()

    print('''
    * len(valid_aids) = %r
    * len(valid_gids) = %r
    ''' % (len(valid_aids), len(valid_gids)))
    assert len(valid_gids) > 0, 'database images cannot be empty for test'
    gindex = int(utool.get_arg('--gx', default=0))
    cindex = int(utool.get_arg('--rx', default=0))
    gid = valid_gids[gindex]
    aid_list = ibs.get_image_aids(gid)
    aid = aid_list[cindex]

    #----------------------
    #print('Show Image')
    aids = aid_list[1:3]
    interact.ishow_image(ibs, gid, aids=aids, fnum=1)

    #----------------------
    #print('Show Chip')
    interact.ishow_chip(ibs, aid, in_image=False, fnum=2)
    #interact.ishow_chip(ibs, aid, in_image=True, fnum=3)

    #----------------------
    #print('Show Query')
    #aid1 = aid
    #qcid2_qres = ibs.query_all([aid1])
    #qres = qcid2_qres.values()[0]
    #top_cids = qres.get_top_cids(ibs)
    #assert len(top_cids) > 0, 'there does not seem to be results'
    #cid2 = top_cids[0]  # 294
    #viz.show_matches(ibs, qres, cid2, fnum=4)

    #viz.show_qres(ibs, qres, fnum=5)
    return locals()
def TEST_QUERY_COMP(ibs):
    print('[TEST_QUERY_COMP]')
    qaid_list = ibs.get_valid_aids()[0:1]
    print('[TEST_QUERY_COMP] len(qaid_list)=%r' % (qaid_list))
    ibs._init_query_requestor()
    qreq = ibs.qreq

    #query_helpers.find_matchable_chips(ibs)

    aids = ibs.get_recognition_database_aids()
    index = 0
    index = utool.get_arg('--index', type_=int, default=index)
    qaid_list = utool.safe_slice(aids, index, index + 1)

    comp_locals_ = query_helpers.get_query_components(ibs, qaid_list)
    qres_dict = OrderedDict([
        ('ORIG', comp_locals_['qres_ORIG']),
        ('FILT', comp_locals_['qres_FILT']),
        ('SVER', comp_locals_['qres_SVER']),
    ])

    top_aids = qres_dict['SVER'].get_top_aids(ibs)
    top_aids = utool.safe_slice(top_aids, 3)
    aid2 = top_aids[0]

    for px, (lbl, qres) in enumerate(six.iteritems(qres_dict)):
        print(lbl)
        fnum = df2.next_fnum()
        df2.figure(fnum=fnum, doclf=True)
        #viz_matches.show_matches(ibs, qres, aid2, fnum=fnum, in_image=True)
        #viz.show_qres(ibs, qres, fnum=fnum, top_aids=top_aids, ensure=False)
        interact.ishow_qres(ibs, qres, fnum=fnum, top_aids=top_aids, ensure=False)
        df2.set_figtitle(lbl)
        df2.adjust_subplots_safe(top=.8)

    fnum = df2.next_fnum()

    qaid2_svtups = comp_locals_['qaid2_svtups']
    qaid2_chipmatch_FILT = comp_locals_['qaid2_chipmatch_FILT']
    aid1 = qaid = comp_locals_['qaid']
    aid2_svtup  = qaid2_svtups[aid1]
    chipmatch_FILT = qaid2_chipmatch_FILT[aid1]
    viz.show_sver(ibs, aid1, aid2, chipmatch_FILT, aid2_svtup, fnum=fnum)
    return locals()
Beispiel #5
0
def show_descriptors_match_distances(orgres2_distance, fnum=1, db_name='', **kwargs):
    disttype_list = orgres2_distance.itervalues().next().keys()
    orgtype_list = orgres2_distance.keys()
    (nRow, nCol) = len(orgtype_list), len(disttype_list)
    nColors = nRow * nCol
    color_list = df2.distinct_colors(nColors)
    df2.figure(fnum=fnum, docla=True, doclf=True)
    pnum_ = lambda px: (nRow, nCol, px + 1)
    plot_type = utool.get_arg('--plot-type', default='plot')

    # Remember min and max val for each distance type (l1, emd...)
    distkey2_min = {distkey: np.uint64(-1) for distkey in disttype_list}
    distkey2_max = {distkey: 0 for distkey in disttype_list}

    def _distplot(dists, color, label, distkey, plot_type=plot_type):
        data = sorted(dists)
        ax = df2.gca()
        min_ = distkey2_min[distkey]
        max_ = distkey2_max[distkey]
        if plot_type == 'plot':
            df2.plot(data, color=color, label=label, yscale='linear')
            #xticks = np.linspace(np.min(data), np.max(data), 3)
            #yticks = np.linspace(0, len(data), 5)
            #ax.set_xticks(xticks)
            #ax.set_yticks(yticks)
            ax.set_ylim(min_, max_)
            ax.set_xlim(0, len(dists))
            ax.set_ylabel('distance')
            ax.set_xlabel('matches indexes (sorted by distance)')
            df2.legend(loc='lower right')
        if plot_type == 'pdf':
            df2.plot_pdf(data, color=color, label=label)
            ax.set_ylabel('pr')
            ax.set_xlabel('distance')
            ax.set_xlim(min_, max_)
            df2.legend(loc='upper left')
        df2.dark_background(ax)
        df2.small_xticks(ax)
        df2.small_yticks(ax)

    px = 0
    for orgkey in orgtype_list:
        for distkey in disttype_list:
            dists = orgres2_distance[orgkey][distkey]
            if len(dists) == 0:
                continue
            min_ = dists.min()
            max_ = dists.max()
            distkey2_min[distkey] = min(distkey2_min[distkey], min_)
            distkey2_max[distkey] = max(distkey2_max[distkey], max_)

    for count, orgkey in enumerate(orgtype_list):
        for distkey in disttype_list:
            printDBG('[allres-viz] plotting: %r' % ((orgkey, distkey),))
            dists = orgres2_distance[orgkey][distkey]
            df2.figure(fnum=fnum, pnum=pnum_(px))
            color = color_list[px]
            title = distkey + ' ' + orgkey
            label = 'P(%s | %s)' % (distkey, orgkey)
            _distplot(dists, color, label, distkey, **kwargs)
            if count == 0:
                ax = df2.gca()
                ax.set_title(distkey)
            px += 1

    subtitle = 'the matching distances between sift descriptors'
    title = '(sift) matching distances'
    if db_name != '':
        title = db_name + ' ' + title
    df2.set_figtitle(title, subtitle)
    df2.adjust_subplots_safe()
Beispiel #6
0
        res.show_topN(hs, fnum=fnum, query_cfg=query_cfg)
        fnum += 1
    return fnum


def plot_feature_distances(allres, orgres_list=None, fnum=1):
    print('[dev] plot_feature_distances()')
    orgres2_distance = allres.get_orgres2_distances(orgres_list=orgres_list)
    db_name = allres.hs.get_db_name()
    allres_viz.show_descriptors_match_distances(orgres2_distance,
                                                db_name=db_name, fnum=fnum)
    fnum += 1
    return fnum


YSCALE = utool.get_arg('--yscale', default='symlog')  # 'symlog'
XSCALE = 'linear'


def plot_seperability(hs, qcx_list, fnum=1):
    print('[dev] plot_seperability(fnum=%r)' % fnum)
    qcx2_res = get_qcx2_res(hs, qcx_list)
    qcx2_separability = get_seperatbility(hs, qcx2_res)
    sep_score_list = qcx2_separability.values()
    df2.figure(fnum=fnum, doclf=True, docla=True)
    print('[dev] seperability stats: ' + utool.stats_str(sep_score_list))
    sorted_sepscores = sorted(sep_score_list)
    df2.plot(sorted_sepscores, color=df2.DEEP_PINK, label='seperation score',
             yscale=YSCALE)
    df2.set_xlabel('true chipmatch index (%d)' % len(sep_score_list))
    df2.set_logyscale_from_data(sorted_sepscores)
Beispiel #7
0
    return aid_list


def list_ingestable_images(img_dir, fullpath=True, recursive=True):
    ignore_list = ['_hsdb', '.hs_internals', '_ibeis_cache', '_ibsdb']
    gpath_list = utool.list_images(img_dir,
                                   fullpath=fullpath,
                                   recursive=recursive,
                                   ignore_list=ignore_list)
    # Ensure in unix format
    gpath_list = map(utool.unixpath, gpath_list)
    return gpath_list


if __name__ == '__main__':
    import multiprocessing
    multiprocessing.freeze_support()  # win32
    print('__main__ = ingest_database.py')
    print(utool.unindent(
        '''
        usage:
        ./ibeis/ingest/ingest_database.py --db [dbname]

        Valid dbnames:''') + utool.indentjoin(STANDARD_INGEST_FUNCS.keys(), '\n  * '))
    db = utool.get_arg('--db', str, None)
    ibs = ingest_standard_database(db)
    #img_dir = join(ibeis.sysres.get_workdir(), 'polar_bears')
    #main_locals = ibeis.main(dbdir=img_dir, gui=False)
    #ibs = main_locals['ibs']
    #ingest_rawdata(ibs, img_dir)
Beispiel #8
0
from __future__ import absolute_import, division, print_function
import numpy as np
from itertools import izip
import plottool.draw_func2 as df2
from plottool import plot_helpers as ph
import utool
import vtool.keypoint as ktool
from ibeis.dev import ibsfuncs
from ibeis.control.accessor_decors import getter, getter_vector_output
(print, print_, printDBG, rrr, profile) = utool.inject(__name__, '[viz_helpers]', DEBUG=False)


NO_LBL_OVERRIDE = utool.get_arg('--no-lbl-override', type_=bool, default=None)


FNUMS = dict(image=1, chip=2, res=3, inspect=4, special=5, name=6)

IN_IMAGE_OVERRIDE = utool.get_arg('--in-image-override', type_=bool, default=None)
SHOW_QUERY_OVERRIDE = utool.get_arg('--show-query-override', type_=bool, default=None)
NO_LBL_OVERRIDE = utool.get_arg('--no-lbl-override', type_=bool, default=None)

SIFT_OR_VECFIELD  = ph.SIFT_OR_VECFIELD


def register_FNUMS(FNUMS_):
    # DEPREICATE
    global FNUMS
    FNUMS = FNUMS_

draw = ph.draw
get_square_row_cols = ph.get_square_row_cols
Beispiel #9
0
    for repo in TPL_REPO_DIRS:
        utool.util_git.std_build_command(repo)  # Executes {plat}_build.{ext}
    # Build only IBEIS repos with setup.py
    utool.set_project_repos(IBEIS_REPO_URLS, IBEIS_REPO_DIRS)
    utool.gg_command('sudo {pythoncmd} setup.py build'.format(**envcmds))

if utool.get_flag('--develop'):
    utool.set_project_repos(IBEIS_REPO_URLS, IBEIS_REPO_DIRS)
    utool.gg_command('sudo {pythoncmd} setup.py develop'.format(**envcmds))


if utool.get_flag('--tag-status'):
    utool.gg_command('git tag')

# Tag everything
tag_name = utool.get_arg('--newtag', type_=str, default=None)
if tag_name is not None:
    utool.gg_command('git tag -a "{tag_name}" -m "super_setup autotag {tag_name}"'.format(**locals()))
    utool.gg_command('git push --tags')


if utool.get_flag('--test'):
    import ibeis
    print('found ibeis=%r' % (ibeis,))


if utool.get_flag('--push'):
    utool.gg_command('git push')


if utool.get_flag('--bext'):
Beispiel #10
0
def show_descriptors_match_distances(orgres2_distance,
                                     fnum=1,
                                     db_name='',
                                     **kwargs):
    disttype_list = orgres2_distance.itervalues().next().keys()
    orgtype_list = orgres2_distance.keys()
    (nRow, nCol) = len(orgtype_list), len(disttype_list)
    nColors = nRow * nCol
    color_list = df2.distinct_colors(nColors)
    df2.figure(fnum=fnum, docla=True, doclf=True)
    pnum_ = lambda px: (nRow, nCol, px + 1)
    plot_type = utool.get_arg('--plot-type', default='plot')

    # Remember min and max val for each distance type (l1, emd...)
    distkey2_min = {distkey: np.uint64(-1) for distkey in disttype_list}
    distkey2_max = {distkey: 0 for distkey in disttype_list}

    def _distplot(dists, color, label, distkey, plot_type=plot_type):
        data = sorted(dists)
        ax = df2.gca()
        min_ = distkey2_min[distkey]
        max_ = distkey2_max[distkey]
        if plot_type == 'plot':
            df2.plot(data, color=color, label=label, yscale='linear')
            #xticks = np.linspace(np.min(data), np.max(data), 3)
            #yticks = np.linspace(0, len(data), 5)
            #ax.set_xticks(xticks)
            #ax.set_yticks(yticks)
            ax.set_ylim(min_, max_)
            ax.set_xlim(0, len(dists))
            ax.set_ylabel('distance')
            ax.set_xlabel('matches indexes (sorted by distance)')
            df2.legend(loc='lower right')
        if plot_type == 'pdf':
            df2.plot_pdf(data, color=color, label=label)
            ax.set_ylabel('pr')
            ax.set_xlabel('distance')
            ax.set_xlim(min_, max_)
            df2.legend(loc='upper left')
        df2.dark_background(ax)
        df2.small_xticks(ax)
        df2.small_yticks(ax)

    px = 0
    for orgkey in orgtype_list:
        for distkey in disttype_list:
            dists = orgres2_distance[orgkey][distkey]
            if len(dists) == 0:
                continue
            min_ = dists.min()
            max_ = dists.max()
            distkey2_min[distkey] = min(distkey2_min[distkey], min_)
            distkey2_max[distkey] = max(distkey2_max[distkey], max_)

    for count, orgkey in enumerate(orgtype_list):
        for distkey in disttype_list:
            printDBG('[allres-viz] plotting: %r' % ((orgkey, distkey), ))
            dists = orgres2_distance[orgkey][distkey]
            df2.figure(fnum=fnum, pnum=pnum_(px))
            color = color_list[px]
            title = distkey + ' ' + orgkey
            label = 'P(%s | %s)' % (distkey, orgkey)
            _distplot(dists, color, label, distkey, **kwargs)
            if count == 0:
                ax = df2.gca()
                ax.set_title(distkey)
            px += 1

    subtitle = 'the matching distances between sift descriptors'
    title = '(sift) matching distances'
    if db_name != '':
        title = db_name + ' ' + title
    df2.set_figtitle(title, subtitle)
    df2.adjust_subplots_safe()
Beispiel #11
0
"""
from __future__ import absolute_import, division, print_function
import multiprocessing
import ibeis
import utool
from os.path import join


if __name__ == '__main__':
    multiprocessing.freeze_support()  # for win32

    # Create a directory for the demo database
    workdir = ibeis.get_workdir()
    demodir = join(workdir, 'demo')

    if utool.get_arg('--reset'):
        # Remove the previous demo if it exists
        utool.delete(demodir)

    # Start a new database there
    main_locals = ibeis.main(dbdir=demodir)

    # Get a handle to the GUIBackend Control
    back = main_locals['back']

    # Get a directory with some images in it

    testurl = 'https://www.dropbox.com/s/s4gkjyxjgghr18c/testdata_detect.zip'
    testdir = utool.grab_zipped_url(testurl)

    execstr = ibeis.main_loop(main_locals)