def get_annot_alrids_oftype(ibs, aid_list, lbltype_rowid): """ Get all the relationship ids belonging to the input annotations where the relationship ids are filtered to be only of a specific lbltype/category/type """ alrids_list = ibs.get_annot_alrids(aid_list) # Get lblannot_rowid of each relationship lblannot_rowids_list = ibsfuncs.unflat_map(ibs.get_alr_lblannot_rowids, alrids_list) # Get the type of each lblannot lbltype_rowids_list = ibsfuncs.unflat_map(ibs.get_lblannot_lbltypes_rowids, lblannot_rowids_list) # only want the nids of individuals, not species, for example valids_list = [[typeid == lbltype_rowid for typeid in rowids] for rowids in lbltype_rowids_list] alrids_list = [ ut.compress(alrids, valids) for alrids, valids in zip(alrids_list, valids_list) ] def resolution_func_first(alrid_list): return [alrid_list[0]] alrids_list = [ resolution_func_first(alrid_list) if len(alrid_list) > 1 else alrid_list for alrid_list in alrids_list ] assert all([ len(alrid_list) < 2 for alrid_list in alrids_list ]), ('More than one type per lbltype. ALRIDS: ' + str(alrids_list) + ', ROW: ' + str(lbltype_rowid) + ', KEYS:' + str(ibs.lbltype_ids)) return alrids_list
def tst_name_consistency(ibs): """ Example: >>> # FIXME failing-test (22-Jul-2020) PZ_Master0 doesn't exist >>> # xdoctest: +SKIP >>> import wbia >>> ibs = wbia.opendb(db='PZ_Master0') >>> #ibs = wbia.opendb(db='GZ_ALL') """ from wbia.other import ibsfuncs import utool as ut max_ = -1 # max_ = 10 valid_aids = ibs.get_valid_aids()[0:max_] valid_nids = ibs.get_valid_nids()[0:max_] ax2_nid = ibs.get_annot_name_rowids(valid_aids) nx2_aids = ibs.get_name_aids(valid_nids) logger.info('len(valid_aids) = %r' % (len(valid_aids), )) logger.info('len(valid_nids) = %r' % (len(valid_nids), )) logger.info('len(ax2_nid) = %r' % (len(ax2_nid), )) logger.info('len(nx2_aids) = %r' % (len(nx2_aids), )) # annots are grouped by names, so mapping aid back to nid should # result in each list having the same value _nids_list = ibsfuncs.unflat_map(ibs.get_annot_name_rowids, nx2_aids) logger.info(_nids_list[-20:]) logger.info(nx2_aids[-20:]) assert all(map(ut.allsame, _nids_list))
def get_annot_lblannot_rowids(ibs, aid_list): """ Returns: list_ (list): the name id of each annotation.""" # Get all the annotation lblannot relationships # filter out only the ones which specify names alrids_list = ibs.get_annot_alrids(aid_list) lblannot_rowids_list = ibsfuncs.unflat_map(ibs.get_alr_lblannot_rowids, alrids_list) return lblannot_rowids_list
def compute_occurrence_unixtime(ibs, occur_gids): # assert isinstance(ibs, IBEISController) # TODO: account for -1 from wbia.other import ibsfuncs unixtimes = ibsfuncs.unflat_map(ibs.get_image_unixtime, occur_gids) time_arrs = list(map(np.array, unixtimes)) occur_unixtimes = list(map(np.mean, time_arrs)) return occur_unixtimes
def get_annot_lblannot_rowids_oftype(ibs, aid_list, _lbltype=None): """ Returns: list_ (list): the name id of each annotation.""" # Get all the annotation lblannot relationships # filter out only the ones which specify names assert _lbltype is not None, 'should be using lbltype_rowids anyway' alrids_list = ibs.get_annot_alrids_oftype(aid_list, ibs.lbltype_ids[_lbltype]) lblannot_rowids_list = ibsfuncs.unflat_map(ibs.get_alr_lblannot_rowids, alrids_list) return lblannot_rowids_list