import fiwtools.fiwdb.database as db import numpy as np import fiwtools.utils.log as log logger = log.setup_custom_logger(__name__) logger.debug('Parse FIW') def check_npairs(npairs, ktype, fid): """ Check tht pair counter is greater than 0 and even (i.e., for each element there is a corresponding pair. :param npairs: :return: True if both test passes """ if npairs == 0: logger.info("No {} in {}.".format(ktype, npairs)) # print("No " + ktype + " in " + str(fid)) return False if npairs % 2 != 0: logger.error( "{}: Number of pairs {} should be even. No. pairs are {}".format( fid, ktype, npairs)) # warn.warn("Number of pairs should be even, but there are" + str(npairs)) return False return True def compare_mid_lists(list1, list2): """ Compares sizes and contents of 2 lists. :param list1:
#!/usr/bin/python # Script to parse different pair types for kin verification. # TODO refactor import fiwtools.data.fiw as fiw import fiwtools.fiwdb.database as db import fiwtools.utils.log as log from pyfiw.configs import CONFIGS logger = log.setup_custom_logger(__name__, f_log='fiw_error_new.log', level=log.INFO) # def parse(dir_fids, kind, message="", do_save=False, file_prefix=""): # """ # Function to find pairs for specific type, load and return all face pairs. # :param dir_fids: # :param kind: # :param message: # :param do_save: # :param file_prefix: # :return: # TODO function to replace each block of code below # """ # log = logging.getLogger(__name__) from fiwtools import utils as io out_bin = CONFIGS.path.dpairs
# docker run -ti -v /home/jrobby/Dropbox/Families_In_The_Wild/Database/FIDs:/data -v /home/jrobby/Dropbox/Families_In_The_Wild/python/models:/models -v /media/jrobby/Seagate\ Backup\ Plus\ Drive1/FIW_dataset/FIW_Extended/feats:/feats -v /home/jrobby/Dropbox/github/FIW_KRT:/code bvlc/caffe:gpu bash # TODO: PCA from __future__ import print_function import numpy as np import glob import fiwtools.utils.io as io import fiwtools.fiwdb.database as fiwdb import argparse import os import fiwtools.utils.log as log import src.frameworks.pycaffe.net_wrapper as cw import src.frameworks.pycaffe.tools as caffe_tools logger = log.setup_custom_logger(__name__, f_log='fiw-feat-extractor.log', level=log.INFO) if __name__ == "__main__": parser = argparse.ArgumentParser( description='FIW deep feature extractor.', formatter_class=argparse.ArgumentDefaultsHelpFormatter) parser.add_argument('-l', '--layer', default='fc7', help='Layers of DCNN to extract features from', choices=['conv5_2', 'conv5_3', 'pool5', 'fc6', 'fc7']) parser.add_argument( '-d', '--model_def', help="File path to prototxt (arch definition).",
# all_faces.append([x, y, z]) # [[x, y] for x, y in zip(faces1, faces2)] arr_all_face = np.array(all_faces) return pd.DataFrame({ header[0]: arr_all_face[:, 0], header[1]: arr_all_face[:, 1], header[2]: arr_all_face[:, 2] }) # arr_pairs = np.array(all_faces) # # print('No. Face Pairs is {}.'.format(arr_pairs.shape[0])) # return pd.DataFrame({"p1": arr_pairs[:, 0], "p2": arr_pairs[:, 1], "p3": arr_pairs[:, 2]}) logger = log.setup_custom_logger(__name__, f_log='tri-info.log', level=log.INFO) out_bin = io.sys_home() + "/Dropbox/Families_In_The_Wild/Database/tripairs//" mkdir(out_bin) dir_fids = io.sys_home() + "/Dropbox/Families_In_The_Wild/Database/FIDs_New/" do_save = False logger.info("Parsing Tri-Subject Pairs:\n\t{}\n\t{}\n".format( out_bin, dir_fids)) fmd, fms = fiw.tri_subjects(dir_data=dir_fids) logger.info("{}".format(out_bin, dir_fids)) # pair_set.write_pairs(out_bin + "sibs-pairs.csv") # df_all_faces.to_csv(out_bin + 'sibs-faces.csv', index=False) if do_save:
""" from __future__ import print_function import glob import pandas as pd import numpy as np import fiwtools.utils.image as imutils import fiwtools.utils.io as io import fiwtools.utils.log as log import operator import csv # TODO urllib.request to handle thrown exceptions <p>Error: HTTP Error 403: Forbidden</p> # TODO modify fold2set with optional args that spefify which fold merges into which set (i.e., currently hard coded). logger = log.setup_custom_logger(__name__, f_log='fiwdb.log', level=log.INFO) logger.info('FIW-DB') dir_db = io.sys_home() + "/Dropbox/Families_In_The_Wild/Database/" # dir_db = "/data/" dir_fid_root = dir_db + "FIDs_NEW/" # dir_fid_root = dir_db + "journal_data/FIDs/" def download_images(f_pid_csv=dir_db + "FIW_PIDs_new.csv", dir_out=dir_db + "fiwimages/"): """ Download FIW database by referencing PID LUT. Each PID is listed with corresponding URL. URL is downloaded and saved as <FID>/PID.jpg :type f_pid_csv: object :type dir_out: object