(args)
Process a single subpath in a I1K tar. By process:
        optionally untar recursive tars (only on 'train')
        resize/copy images
    Returns a list of [(fname, label), ...]
Process a single subpath in a I1K tar. By process:
        optionally untar recursive tars (only on 'train')
        resize/copy images
    Returns a list of [(fname, label), ...]
Process a single subpath in a I1K tar . By process : optionally untar recursive tars ( only on train ) resize / copy images Returns a list of [ ( fname label ) ... ]
def process_i1k_tar_subpath(args):
    """
    Process a single subpath in a I1K tar. By process:
        optionally untar recursive tars (only on 'train')
        resize/copy images
    Returns a list of [(fname, label), ...]
    """
    target_size, toptar, img_dir, setn, label_dict, subpath = args
    name_slice = slice(None, 9) if setn == 'train' else slice(15, -5)
    label = label_dict[subpath.name[name_slice]]
    outpath = os.path.join(img_dir, str(label))
    if setn == 'train':
        tf = tarfile.open(toptar)
        subtar = tarfile.open(fileobj=tf.extractfile(subpath))
        file_list = subtar.getmembers()
        return process_files_in_tar(target_size, label, subtar, file_list, outpath)
    elif setn == 'val':
        tf = tarfile.open(toptar)
        file_list = [subpath]
        return process_files_in_tar(target_size, label, tf, file_list, outpath)
def process_i1k_tar_subpath ( args ) : target_size , toptar , img_dir , setn , label_dict , subpath = args name_slice = slice ( None , 9 ) if setn == 'train' else slice ( 15 , - 5 ) label = label_dict [ subpath . name [ name_slice ] ] outpath = os . path . join ( img_dir , str ( label ) ) if setn == 'train' : tf = tarfile . open ( toptar ) subtar = tarfile . open ( fileobj = tf . extractfile ( subpath ) ) file_list = subtar . getmembers ( ) return process_files_in_tar ( target_size , label , subtar , file_list , outpath ) elif setn == 'val' : tf = tarfile . open ( toptar ) file_list = [ subpath ] return process_files_in_tar ( target_size , label , tf , file_list , outpath )