示例#1
0
 def get_other_nids(self):
     ibs = self.ibs
     all_nid_list = ibs.get_annot_name_rowids(self.all_aid_list)
     unique_nid_list = ut.unique_ordered(all_nid_list)
     is_unknown = ibs.is_nid_unknown(unique_nid_list)
     is_name1 = [nid == self.nid1 for nid in unique_nid_list]
     is_name2 = [nid == self.nid2 for nid in unique_nid_list]
     is_other = ut.and_lists(*tuple(map(ut.not_list, (is_name1, is_name2, is_unknown))))
     other_nid_list = ut.compress(unique_nid_list, is_other)
     return other_nid_list
示例#2
0
 def get_other_nids(self):
     ibs = self.ibs
     all_nid_list = ibs.get_annot_name_rowids(self.all_aid_list)
     unique_nid_list = ut.unique_ordered(all_nid_list)
     is_unknown = ibs.is_nid_unknown(unique_nid_list)
     is_name1 = [nid == self.nid1 for nid in unique_nid_list]
     is_name2 = [nid == self.nid2 for nid in unique_nid_list]
     is_other = ut.and_lists(
         *tuple(map(ut.not_list, (is_name1, is_name2, is_unknown))))
     other_nid_list = ut.compress(unique_nid_list, is_other)
     return other_nid_list
示例#3
0
def export_data(ibs, gid_list, aid_list, nid_list, new_dbpath=None):
    """
    exports a subset of data and other required info

    Args:
        ibs (IBEISController):  wbia controller object
        gid_list (list):  list of image rowids
        aid_list (list):  list of annotation rowids
        nid_list (list):  list of name rowids
        imgsetid_list (list):  list of imageset rowids
        gsgrid_list (list):  list of imageset-image pairs rowids
        new_dbpath (None): (default = None)

    Returns:
        str: new_dbpath
    """
    import wbia

    imgsetid_list = ut.unique_unordered(
        ut.flatten(ibs.get_image_imgsetids(gid_list)))
    gsgrid_list = ut.unique_unordered(
        ut.flatten(ibs.get_image_gsgrids(gid_list)))

    # TODO: write SQL query to do this
    am_rowids = ibs._get_all_annotmatch_rowids()
    flags1_list = [
        aid in set(aid_list) for aid in ibs.get_annotmatch_aid1(am_rowids)
    ]
    flags2_list = [
        aid in set(aid_list) for aid in ibs.get_annotmatch_aid2(am_rowids)
    ]
    flag_list = ut.and_lists(flags1_list, flags2_list)
    am_rowids = ut.compress(am_rowids, flag_list)
    # am_rowids = ibs.get_valid_aids(ibs.get_valid_aids())

    rowid_subsets = {
        const.ANNOTATION_TABLE: aid_list,
        const.NAME_TABLE: nid_list,
        const.IMAGE_TABLE: gid_list,
        const.ANNOTMATCH_TABLE: am_rowids,
        const.GSG_RELATION_TABLE: gsgrid_list,
        const.IMAGESET_TABLE: imgsetid_list,
    }
    ibs_dst = wbia.opendb(dbdir=new_dbpath, allow_newdir=True)
    # Main merge driver
    merge_databases(ibs, ibs_dst, rowid_subsets=rowid_subsets)
    logger.info('Exported to %r' % (new_dbpath, ))
    return new_dbpath