Ejemplo n.º 1
0
def testdata_showchip():
    import ibeis
    ibs = ibeis.opendb(defaultdb='PZ_MTEST')
    aid_list = ut.get_argval(('--aids', '--aid'), type_=list, default=None)
    if aid_list is None:
        aid_list = ibs.get_valid_aids()[0:4]
    weight_label = ut.get_argval('--weight_label',
                                 type_=str,
                                 default='fg_weights')
    annote = not ut.get_argflag('--no-annote')
    kwargs = dict(ori=ut.get_argflag('--ori'),
                  weight_label=weight_label,
                  annote=annote)
    kwargs['notitle'] = ut.get_argflag('--notitle')
    kwargs['pts'] = ut.get_argflag('--drawpts')
    kwargs['ell'] = ut.get_argflag('--drawell')
    kwargs['ell_alpha'] = ut.get_argval('--ellalpha', default=.4)
    kwargs['ell_linewidth'] = ut.get_argval('--ell_linewidth', default=2)
    ut.print_dict(kwargs)
    default_config = dict(
        ibeis.algo.Config.FeatureWeightConfig().parse_items())
    cfgdict = ut.argparse_dict(default_config)
    print('[viz_chip.testdata] cfgdict = %r' % (cfgdict, ))
    config2_ = ibs.new_query_params(cfgdict=cfgdict)
    print('query_cfgstr = ' + config2_.query_cfgstr)
    print('feat_cfgstr = ' + config2_.feat_cfgstr)
    print('[viz_chip.testdata] aid_list = %r' % (aid_list, ))
    return ibs, aid_list, kwargs, config2_
Ejemplo n.º 2
0
    def on_click_inside(self, event, ax):
        from plottool import plot_helpers as ph
        ibs       = self.ibs
        viztype = ph.get_plotdat(ax, 'viztype', '')
        is_match_type = viztype in ['matches', 'multi_match']

        key = '' if event.key is None else event.key
        print('key=%r ' % key)
        ctrl_down = key.find('control') == 0
        # Click in match axes
        if event.button == 3:
            return super(MatchInteraction, self).on_click_inside(event, ax)
        if is_match_type and ctrl_down:
            # Ctrl-Click
            print('.. control click')
            return self.sv_view()
        elif viztype in ['warped', 'unwarped']:
            print('clicked at patch')
            ut.print_dict(ph.get_plotdat_dict(ax))
            hs_aid = {
                'aid1': self.qaid,
                'aid2': self.daid,
            }[vh.get_ibsdat(ax, 'aid', None)]
            hs_fx = vh.get_ibsdat(ax, 'fx', None)
            print('hs_fx = %r' % (hs_fx,))
            print('hs_aid = %r' % (hs_aid,))
            if hs_aid is not None and viztype == 'unwarped':
                ishow_chip(ibs, hs_aid, fx=hs_fx, fnum=pt.next_fnum())
            elif hs_aid is not None and viztype == 'warped':
                viz.show_keypoint_gradient_orientations(ibs, hs_aid, hs_fx,
                                                        fnum=pt.next_fnum())
        else:
            return super(MatchInteraction, self).on_click_inside(event, ax)
        self.draw()
Ejemplo n.º 3
0
    def __init__(bing,
                 default=True,
                 verbose=VERBOSE_BING,
                 quiet=QUIET_BING,
                 **kwargs):
        '''
            Create the C object for the PyBING detector.

            Args:
                verbose (bool, optional): verbose flag; defaults to --verbbing flag

            Kwargs:
                base (int)
                W (int)
                NNS (int)

            Returns:
                detector (object): the BING Detector object
        '''
        bing.verbose = verbose
        bing.quiet = quiet

        # Default values
        params = odict([
            ('base', 2.0),
            ('W', 8),
            ('NNS', 2),
            ('verbose', verbose),
            ('quiet', quiet),
        ])
        params.update(kwargs)
        params_list = list(params.values())

        if bing.verbose and not bing.quiet:
            """ debug with dmesg | tail -n 200 """
            print('[pybing.py] Start Create New BING Object')
            ut.print_dict(params)
            print('[pybing.py] params_list = %r' % (params_list, ))
            print('[pybing.py] type of params = %r' %
                  (list(map(type, params_list)), ))
            pass

        bing.detector_c_obj = BING_CLIB.init(*params_list)

        if bing.verbose and not bing.quiet:
            print('[pybing.py] Finished Create New BING Object')

        if default:
            model_path = ut.grab_zipped_url(VOC2007_MODEL_URL,
                                            appname='pybing')
            model_path = join(model_path, 'model')
            print('Loading models: %r' % (model_path, ))
            bing.model(model_path)
Ejemplo n.º 4
0
    def __init__(bing, default=True, verbose=VERBOSE_BING, quiet=QUIET_BING, **kwargs):
        '''
            Create the C object for the PyBING detector.

            Args:
                verbose (bool, optional): verbose flag; defaults to --verbbing flag

            Kwargs:
                base (int)
                W (int)
                NNS (int)

            Returns:
                detector (object): the BING Detector object
        '''
        bing.verbose = verbose
        bing.quiet = quiet

        # Default values
        params = odict([
            ('base',       2.0),
            ('W',          8),
            ('NNS',        2),
            ('verbose',    verbose),
            ('quiet',      quiet),
        ])
        params.update(kwargs)
        params_list = list(params.values())

        if bing.verbose and not bing.quiet:
            """ debug with dmesg | tail -n 200 """
            print('[pybing.py] Start Create New BING Object')
            ut.print_dict(params)
            print('[pybing.py] params_list = %r' % (params_list,))
            print('[pybing.py] type of params = %r' % (list(map(type, params_list)),))
            pass

        bing.detector_c_obj = BING_CLIB.init(*params_list)

        if bing.verbose and not bing.quiet:
            print('[pybing.py] Finished Create New BING Object')

        if default:
            model_path = ut.grab_zipped_url(VOC2007_MODEL_URL, appname='pybing')
            model_path = join(model_path, 'model')
            print('Loading models: %r' % (model_path, ))
            bing.model(model_path)
Ejemplo n.º 5
0
 def __init__(self, **kwargs):
     #self.num_engines = 3
     self.num_engines = NUM_ENGINES
     self.engine_queue_proc = None
     self.collect_queue_proc = None
     self.engine_procs = None
     self.collect_proc = None
     # --
     only_engine = ut.get_argflag('--only-engine')
     self.spawn_collector = not only_engine
     self.spawn_engine = not ut.get_argflag('--no-engine')
     self.fg_engine = ut.get_argflag('--fg-engine')
     self.spawn_queue = not only_engine
     # Find ports
     self.port_dict = None
     self._initialize_job_ports(**kwargs)
     print('JobBackend ports:')
     ut.print_dict(self.port_dict)
Ejemplo n.º 6
0
def __debug_win_msvcr():
    import utool as ut
    fname = 'msvcr*.dll'
    key_list = ['PATH']
    found = ut.search_env_paths(fname, key_list)
    fpaths = ut.unique(ut.flatten(found.values()))
    fpaths = ut.lmap(ut.ensure_unixslash, fpaths)
    from os.path import basename
    dllnames = [basename(x) for x in fpaths]
    grouped = dict(ut.group_items(fpaths, dllnames))
    print(ut.dict_str(grouped, nl=4))

    keytoid = {}

    for key, vals in grouped.items():
        infos = ut.lmap(ut.get_file_nBytes, vals)
        #infos = ut.lmap(ut.get_file_uuid, vals)
        #uuids = [ut.get_file_uuid(val) for val in vals]
        keytoid[key] = list(zip(infos, vals))
    ut.print_dict(keytoid, nl=2)
Ejemplo n.º 7
0
def __debug_win_msvcr():
    import utool as ut
    fname = 'msvcr*.dll'
    key_list = ['PATH']
    found = ut.search_env_paths(fname, key_list)
    fpaths = ut.unique(ut.flatten(found.values()))
    fpaths = ut.lmap(ut.ensure_unixslash, fpaths)
    from os.path import basename
    dllnames = [basename(x) for x in fpaths]
    grouped = dict(ut.group_items(fpaths, dllnames))
    print(ut.repr4(grouped, nl=4))

    keytoid = {
    }

    for key, vals in grouped.items():
        infos = ut.lmap(ut.get_file_nBytes, vals)
        #infos = ut.lmap(ut.get_file_uuid, vals)
        #uuids = [ut.get_file_uuid(val) for val in vals]
        keytoid[key] = list(zip(infos, vals))
    ut.print_dict(keytoid, nl=2)
Ejemplo n.º 8
0
def testdata_showchip():
    import ibeis
    ibs = ibeis.opendb(defaultdb='PZ_MTEST')
    aid_list = ut.get_argval(('--aids', '--aid'), type_=list, default=None)
    if aid_list is None:
        aid_list = ibs.get_valid_aids()[0:4]
    weight_label = ut.get_argval('--weight_label', type_=str, default='fg_weights')
    annote = not ut.get_argflag('--no-annote')
    kwargs = dict(ori=ut.get_argflag('--ori'), weight_label=weight_label, annote=annote)
    kwargs['notitle'] = ut.get_argflag('--notitle')
    kwargs['pts'] = ut.get_argflag('--drawpts')
    kwargs['ell'] = ut.get_argflag('--drawell')
    kwargs['ell_alpha'] = ut.get_argval('--ellalpha', default=.4)
    kwargs['ell_linewidth'] = ut.get_argval('--ell_linewidth', default=2)
    ut.print_dict(kwargs)
    default_config = dict(ibeis.algo.Config.FeatureWeightConfig().parse_items())
    cfgdict = ut.argparse_dict(default_config)
    print('[viz_chip.testdata] cfgdict = %r' % (cfgdict,))
    config2_ = ibs.new_query_params(cfgdict=cfgdict)
    print('query_cfgstr = ' + config2_.query_cfgstr)
    print('feat_cfgstr = ' + config2_.feat_cfgstr)
    print('[viz_chip.testdata] aid_list = %r' % (aid_list,))
    return ibs, aid_list, kwargs, config2_
Ejemplo n.º 9
0
    def on_click(self, event):
        aid = self.daid
        qaid = self.qaid
        ibs = self.ibs
        xywh2_ptr = self.xywh2_ptr
        print('[inter] clicked matches')
        if event is None:
            return
        button = event.button
        is_right_click = button == 3

        # Out of axes click
        (x, y, ax) = (event.xdata, event.ydata, event.inaxes)
        if None in [x, y, ax]:
            in_axis = False
            if not is_right_click:
                print('... out of axis')
                self.chipmatch_view()
                viz.draw()
                return
        else:
            in_axis = True

        if in_axis:
            viztype = vh.get_ibsdat(ax, 'viztype', '')
            is_match_type = viztype in ['matches', 'multi_match']
            print('[ir] viztype=%r ' % viztype)
        else:
            is_match_type = False
            viztype = ''

        if is_right_click:
            from ibeis.gui import inspect_gui
            options = []

            if is_match_type:
                options += inspect_gui.get_aidpair_context_menu_options(
                    self.ibs,
                    self.qaid,
                    self.daid,
                    self.cm,
                    qreq_=self.qreq_,
                    #update_callback=self.show_page,
                    #backend_callback=None, aid_list=aid_list)
                )

            options += [
                ('Toggle same_fig', self.toggle_samefig),
                ('Toggle vert', self.toggle_vert),
                ('query last feature', self.query_last_feature),
                ('show each chip', self.show_each_chip),
                ('show each distinctiveness chip',
                 self.show_each_dstncvs_chip),
                ('show each foreground weight chip',
                 self.show_each_fgweight_chip),
                ('show each probchip', self.show_each_probchip),
                ('show coverage', self.show_coverage),
                #('show each probchip', self.query_last_feature),
            ]

            #options.append(('name_interaction', self.name_interaction))
            if self.H1 is not None:
                options.append(('Toggle homog', self.toggle_homog))
            if ut.is_developer():
                options.append(('dev_reload', self.dev_reload))
                options.append(('dev_embed', self.dev_embed))
            #options.append(('cancel', lambda: print('cancel')))
            self.show_popup_menu(options, event)
            return

        if in_axis:
            key = '' if event.key is None else event.key
            print('key=%r ' % key)
            ctrl_down = key.find('control') == 0
            # Click in match axes
            if is_match_type and ctrl_down:
                # Ctrl-Click
                print('.. control click')
                return self.sv_view()
            elif is_match_type:
                if len(self.fm) == 0:
                    print('[inter] no feature matches to click')
                else:
                    # Normal Click
                    # Select nearest feature match to the click
                    kpts1 = ibs.get_annot_kpts([qaid],
                                               config2_=self.query_config2_)[0]
                    kpts2 = ibs.get_annot_kpts([aid],
                                               config2_=self.data_config2_)[0]
                    kpts1_m = kpts1[self.fm.T[0]]
                    kpts2_m = kpts2[self.fm.T[1]]
                    x2, y2, w2, h2 = xywh2_ptr[0]
                    _mx1, _dist1 = ut.nearest_point(x, y, kpts1_m)
                    _mx2, _dist2 = ut.nearest_point(x - x2, y - y2, kpts2_m)
                    mx = _mx1 if _dist1 < _dist2 else _mx2
                    (fx1, fx2) = self.fm[mx]
                    print('... clicked mx=%r' % mx)
                    print('... fx1, fx2 = %r, %r' % (
                        fx1,
                        fx2,
                    ))
                    self.select_ith_match(mx)
            elif viztype in ['warped', 'unwarped']:
                print('clicked at patch')
                ut.print_dict(ph.get_plotdat_dict(ax))
                hs_aid = vh.get_ibsdat(ax, 'aid', None)
                hs_fx = vh.get_ibsdat(ax, 'fx', None)
                #hs_aid = ax.__dict__.get('_hs_aid', None)
                #hs_fx = ax.__dict__.get('_hs_fx', None)
                print('hs_fx = %r' % (hs_fx, ))
                print('hs_aid = %r' % (hs_aid, ))
                if hs_aid is not None and viztype == 'unwarped':
                    ishow_chip(ibs, hs_aid, fx=hs_fx, fnum=df2.next_fnum())
                elif hs_aid is not None and viztype == 'warped':
                    viz.show_keypoint_gradient_orientations(
                        ibs, hs_aid, hs_fx, fnum=df2.next_fnum())
            elif viztype.startswith('colorbar'):
                # Hack to get a specific scoring feature
                sortx = self.fs.argsort()
                idx = np.clip(int(np.round(y * len(sortx))), 0, len(sortx) - 1)
                mx = sortx[idx]
                (fx1, fx2) = self.fm[mx]
                (fx1, fx2) = self.fm[mx]
                print('... selected score at rank idx=%r' % (idx, ))
                print('... selected score with fs=%r' % (self.fs[mx], ))
                print('... resolved to mx=%r' % mx)
                print('... fx1, fx2 = %r, %r' % (
                    fx1,
                    fx2,
                ))
                self.select_ith_match(mx)
            else:
                print('...Unknown viztype: %r' % viztype)
            viz.draw()
Ejemplo n.º 10
0
 def __init__(jobiface, id_, port_dict):
     jobiface.id_ = id_
     jobiface.verbose = 2 if VERBOSE_JOBS else 1
     jobiface.port_dict = port_dict
     print('JobInterface ports:')
     ut.print_dict(jobiface.port_dict)
Ejemplo n.º 11
0
def compute_occurrence_groups(ibs, gid_list, config={}, use_gps=False, verbose=None):
    r"""
    Args:
        ibs (IBEISController):  wbia controller object
        gid_list (list):

    Returns:
        tuple: (None, None)

    CommandLine:
        python -m wbia compute_occurrence_groups

    Example:
        >>> # DISABLE_DOCTEST
        >>> from wbia.algo.preproc.preproc_occurrence import *  # NOQA
        >>> import wbia
        >>> ibs = wbia.opendb(defaultdb='testdb1')
        >>> verbose = True
        >>> images = ibs.images()
        >>> gid_list = images.gids
        >>> config = {}  # wbia.algo.Config.OccurrenceConfig().asdict()
        >>> tup = wbia_compute_occurrences(ibs, gid_list)
        >>> (flat_imgsetids, flat_gids)
        >>> aids_list = list(ut.group_items(aid_list_, flat_imgsetids).values())
        >>> metric = list(map(len, aids_list))
        >>> sortx = ut.list_argsort(metric)[::-1]
        >>> index = sortx[1]
        >>> aids = aids_list[index]
        >>> gids = list(set(ibs.get_annot_gids(aids)))
    """
    if verbose is None:
        verbose = ut.NOT_QUIET
    # Config info
    gid_list = np.unique(gid_list)
    if verbose:
        logger.info('[occur] Computing occurrences on %r images.' % (len(gid_list)))
        logger.info('[occur] config = ' + ut.repr3(config))

    use_gps = config['use_gps']
    datas = prepare_X_data(ibs, gid_list, use_gps=use_gps)

    from wbia.algo.preproc import occurrence_blackbox

    cluster_algo = config.get('cluster_algo', 'agglomerative')
    km_per_sec = config.get('km_per_sec', occurrence_blackbox.KM_PER_SEC)
    thresh_sec = config.get('seconds_thresh', 30 * 60.0)
    min_imgs_per_occurence = config.get('min_imgs_per_occurence', 1)
    # 30 minutes = 3.6 kilometers
    # 5 minutes = 0.6 kilometers

    assert cluster_algo == 'agglomerative', 'only agglomerative is supported'

    # Group datas with different values separately
    all_gids = []
    all_labels = []
    for key in datas.keys():
        val = datas[key]
        gids, latlons, posixtimes = val
        labels = occurrence_blackbox.cluster_timespace_sec(
            latlons, posixtimes, thresh_sec, km_per_sec=km_per_sec
        )
        if labels is None:
            labels = np.zeros(len(gids), dtype=np.int)
        all_gids.append(gids)
        all_labels.append(labels)

    # Combine labels across different groups
    pads = [vt.safe_max(ys, fill=0) + 1 for ys in all_labels]
    offsets = np.array([0] + pads[:-1]).cumsum()
    all_labels_ = [ys + offset for ys, offset in zip(all_labels, offsets)]
    label_arr = np.array(ut.flatten(all_labels_))
    gid_arr = np.array(ut.flatten(all_gids))

    # Group images by unique label
    labels, label_gids = group_images_by_label(label_arr, gid_arr)
    # Remove occurrences less than the threshold
    occur_labels = labels
    occur_gids = label_gids
    occur_unixtimes = compute_occurrence_unixtime(ibs, occur_gids)
    occur_labels, occur_gids = filter_and_relabel(
        labels, label_gids, min_imgs_per_occurence, occur_unixtimes
    )
    if verbose:
        logger.info('[occur] Found %d clusters.' % len(occur_labels))
    if len(label_gids) > 0 and verbose:
        logger.info('[occur] Cluster image size stats:')
        ut.print_dict(
            ut.get_stats(list(map(len, occur_gids)), use_median=True, use_sum=True),
            'occur image stats',
        )
    return occur_labels, occur_gids
Ejemplo n.º 12
0
    def on_click(self, event):
        aid       = self.daid
        qaid      = self.qaid
        ibs       = self.ibs
        xywh2_ptr = self.xywh2_ptr
        print('[inter] clicked matches')
        if event is None:
            return
        button = event.button
        is_right_click = button == 3

        # Out of axes click
        (x, y, ax) = (event.xdata, event.ydata, event.inaxes)
        if None in [x, y, ax]:
            in_axis = False
            if not is_right_click:
                print('... out of axis')
                self.chipmatch_view()
                viz.draw()
                return
        else:
            in_axis = True

        if in_axis:
            viztype = vh.get_ibsdat(ax, 'viztype', '')
            is_match_type = viztype in ['matches', 'multi_match']
            print('[ir] viztype=%r ' % viztype)
        else:
            is_match_type = False
            viztype = ''

        if is_right_click:
            from ibeis.gui import inspect_gui
            options = []

            if is_match_type:
                options += inspect_gui.get_aidpair_context_menu_options(
                    self.ibs, self.qaid, self.daid, self.cm,
                    qreq_=self.qreq_,
                    #update_callback=self.show_page,
                    #backend_callback=None, aid_list=aid_list)
                )

            options += [
                ('Toggle same_fig', self.toggle_samefig),
                ('Toggle vert', self.toggle_vert),
                ('query last feature', self.query_last_feature),
                ('show each chip', self.show_each_chip),
                ('show each distinctiveness chip', self.show_each_dstncvs_chip),
                ('show each foreground weight chip', self.show_each_fgweight_chip),
                ('show each probchip', self.show_each_probchip),
                ('show coverage', self.show_coverage),
                #('show each probchip', self.query_last_feature),
            ]

            #options.append(('name_interaction', self.name_interaction))
            if self.H1 is not None:
                options.append(('Toggle homog', self.toggle_homog))
            if ut.is_developer():
                options.append(('dev_reload', self.dev_reload))
                options.append(('dev_embed', self.dev_embed))
            #options.append(('cancel', lambda: print('cancel')))
            self.show_popup_menu(options, event)
            return

        if in_axis:
            key = '' if event.key is None else event.key
            print('key=%r ' % key)
            ctrl_down = key.find('control') == 0
            # Click in match axes
            if is_match_type and ctrl_down:
                # Ctrl-Click
                print('.. control click')
                return self.sv_view()
            elif is_match_type:
                if len(self.fm) == 0:
                    print('[inter] no feature matches to click')
                else:
                    # Normal Click
                    # Select nearest feature match to the click
                    kpts1 = ibs.get_annot_kpts([qaid], config2_=self.query_config2_)[0]
                    kpts2 = ibs.get_annot_kpts([aid], config2_=self.data_config2_)[0]
                    kpts1_m = kpts1[self.fm.T[0]]
                    kpts2_m = kpts2[self.fm.T[1]]
                    x2, y2, w2, h2 = xywh2_ptr[0]
                    _mx1, _dist1 = ut.nearest_point(x, y, kpts1_m)
                    _mx2, _dist2 = ut.nearest_point(x - x2, y - y2, kpts2_m)
                    mx = _mx1 if _dist1 < _dist2 else _mx2
                    (fx1, fx2) = self.fm[mx]
                    print('... clicked mx=%r' % mx)
                    print('... fx1, fx2 = %r, %r' % (fx1, fx2,))
                    self.select_ith_match(mx)
            elif viztype in ['warped', 'unwarped']:
                print('clicked at patch')
                ut.print_dict(ph.get_plotdat_dict(ax))
                hs_aid = vh.get_ibsdat(ax, 'aid', None)
                hs_fx = vh.get_ibsdat(ax, 'fx', None)
                #hs_aid = ax.__dict__.get('_hs_aid', None)
                #hs_fx = ax.__dict__.get('_hs_fx', None)
                print('hs_fx = %r' % (hs_fx,))
                print('hs_aid = %r' % (hs_aid,))
                if hs_aid is not None and viztype == 'unwarped':
                    ishow_chip(ibs, hs_aid, fx=hs_fx, fnum=df2.next_fnum())
                elif hs_aid is not None and viztype == 'warped':
                    viz.show_keypoint_gradient_orientations(ibs, hs_aid, hs_fx,
                                                            fnum=df2.next_fnum())
            elif viztype.startswith('colorbar'):
                # Hack to get a specific scoring feature
                sortx = self.fs.argsort()
                idx = np.clip(int(np.round(y * len(sortx))), 0, len(sortx) - 1)
                mx = sortx[idx]
                (fx1, fx2) = self.fm[mx]
                (fx1, fx2) = self.fm[mx]
                print('... selected score at rank idx=%r' % (idx,))
                print('... selected score with fs=%r' % (self.fs[mx],))
                print('... resolved to mx=%r' % mx)
                print('... fx1, fx2 = %r, %r' % (fx1, fx2,))
                self.select_ith_match(mx)
            else:
                print('...Unknown viztype: %r' % viztype)
            viz.draw()
Ejemplo n.º 13
0
def compute_occurrence_groups(ibs, gid_list, cluster_algo, cfgdict={}, use_gps=False, verbose=None):
    r"""
    Args:
        ibs (IBEISController):  ibeis controller object
        gid_list (list):

    Returns:
        tuple: (None, None)

    CommandLine:
        python -m ibeis --tf compute_occurrence_groups
        python -m ibeis --tf compute_occurrence_groups --show --zoom=.3

    Example:
        >>> # DISABLE_DOCTEST
        >>> from ibeis.algo.preproc.preproc_occurrence import *  # NOQA
        >>> import ibeis
        >>> import vtool as vt
        >>> #ibs = ibeis.opendb(defaultdb='testdb1')
        >>> ibs = ibeis.opendb(defaultdb='PZ_Master1')
        >>> gid_list = ibs.get_valid_gids(require_unixtime=True, require_gps=True)
        >>> use_gps = True
        >>> cluster_algo = 'meanshift'
        >>> cfgdict = dict(quantile=.005, min_imgs_per_occurence=2)
        >>> (occur_labels, occur_gids) = compute_occurrence_groups(ibs, gid_list, cluster_algo, cfgdict, use_gps=use_gps)
        >>> aidsgroups_list = ibs.unflat_map(ibs.get_image_aids, occur_gids)
        >>> aids_list = list(map(ut.flatten, aidsgroups_list))
        >>> nids_list = list(map(np.array, ibs.unflat_map(ibs.get_annot_name_rowids, aids_list)))
        >>> metric = [len(np.unique(nids[nids > -1])) for nids in nids_list]
        >>> metric = [vt.safe_max(np.array(ut.dict_hist(nids).values())) for nids in nids_list]
        >>> #metric = list(map(len, aids_list))
        >>> sortx = ut.list_argsort(metric)[::-1]
        >>> index = sortx[20]
        >>> #gids = occur_gids[index]
        >>> aids = aids_list[index]
        >>> aids = ibs.filter_annots_general(aids, min_qual='ok', is_known=True)
        >>> gids = list(set(ibs.get_annot_gids(aids)))
        >>> print('len(aids) = %r' % (len(aids),))
        >>> img_list = ibs.get_images(gids)
        >>> ut.quit_if_noshow()
        >>> from ibeis.viz import viz_graph
        >>> import plottool as pt
        >>> #pt.imshow(bigimg)
        >>> #aids = ibs.group_annots_by_name(aids)[0][0]
        >>> self = viz_graph.make_name_graph_interaction(ibs, aids=aids,
        >>>                                              with_all=False,
        >>>                                              prog='neato')
        >>> ut.show_if_requested()

        ibs.unflat_map(ibs.get_annot_case_tags, aids_list)
        ibs.filter_aidpairs_by_tags(has_any='photobomb')

        photobomb_aids = ibs.filter_aidpairs_by_tags(has_any='photobomb')
        aids = photobomb_aids[0:10].flatten()
        _gt_aids = ibs.get_annot_groundtruth(aids)
        gt_aids = ut.get_list_column_slice(_gt_aids, slice(0, 3))
        aid_set = np.unique(np.append(aids.flatten(), ut.flatten(gt_aids)))
        aid_set = ibs.filter_annots_general(aid_set, minqual='ok')

        # This is the set of annotations used for testing intraoccurrence photobombs
        #print(ut.repr3(ibeis.other.dbinfo.get_dbinfo(ibs, aid_list=aid_set), strvals=True, nl=1))
        print(ut.repr3(ibs.get_annot_stats_dict(aid_set, forceall=True), strvals=True, nl=1))

    """
    if verbose is None:
        verbose = ut.NOT_QUIET
    # Config info
    gid_list = np.unique(gid_list)
    if verbose:
        print("[occur] Computing %r occurrences on %r images." % (cluster_algo, len(gid_list)))
    if len(gid_list) == 0:
        print("[occur] WARNING: len(gid_list) == 0. " "No images to compute occurrences with")
        occur_labels, occur_gids = [], []
    else:
        if len(gid_list) == 1:
            print("[occur] WARNING: custering 1 image into its own occurrence")
            gid_arr = np.array(gid_list)
            label_arr = np.zeros(gid_arr.shape)
        else:
            X_data, gid_arr = prepare_X_data(ibs, gid_list, use_gps=use_gps)
            # Agglomerative clustering of unixtimes
            if cluster_algo == "agglomerative":
                seconds_thresh = cfgdict.get("seconds_thresh", 60.0)
                label_arr = agglomerative_cluster_occurrences(X_data, seconds_thresh)
            elif cluster_algo == "meanshift":
                quantile = cfgdict.get("quantile", 0.01)
                label_arr = meanshift_cluster_occurrences(X_data, quantile)
            else:
                raise AssertionError("[occurrence] Uknown clustering algorithm: %r" % cluster_algo)
        # Group images by unique label
        labels, label_gids = group_images_by_label(label_arr, gid_arr)
        # Remove occurrences less than the threshold
        occur_labels = labels
        occur_gids = label_gids
        occur_unixtimes = compute_occurrence_unixtime(ibs, occur_gids)
        min_imgs_per_occurence = cfgdict.get("min_imgs_per_occurence", 1)
        occur_labels, occur_gids = filter_and_relabel(labels, label_gids, min_imgs_per_occurence, occur_unixtimes)
        if verbose:
            print("[occur] Found %d clusters." % len(occur_labels))
        if len(label_gids) > 0 and verbose:
            print("[occur] Cluster image size stats:")
            ut.print_dict(ut.get_stats(list(map(len, occur_gids)), use_median=True, use_sum=True), "occur image stats")
    return occur_labels, occur_gids