(self, setn)
return pairs
untar imagenet tar files into directories that indicate their label.

        returns [(filename, label), ...] for train or val set partitions
untar imagenet tar files into directories that indicate their label.
untar imagenet tar files into directories that indicate their label .
def train_or_val_pairs(self, setn):
        """
        untar imagenet tar files into directories that indicate their label.

        returns [(filename, label), ...] for train or val set partitions
        """
        img_dir = os.path.join(self.out_dir, setn)

        neon_logger.display("Extracting %s files" % (setn))
        root_tf_path = self.tars[setn]
        if not os.path.exists(root_tf_path):
            raise IOError(("tar file {} not found. Ensure you have ImageNet downloaded"
                           ).format(root_tf_path))

        try:
            root_tf = tarfile.open(root_tf_path)
        except tarfile.ReadError as e:
            raise ValueError('ReadError opening {}: {}'.format(root_tf_path, e))

        label_dict = self.extract_labels(setn)
        subpaths = root_tf.getmembers()
        arg_iterator = zip(repeat(self.target_size), repeat(root_tf_path), repeat(img_dir),
                           repeat(setn), repeat(label_dict), subpaths)
        pool = multiprocessing.Pool()

        pairs = []
        for pair_list in tqdm.tqdm(pool.imap_unordered(process_i1k_tar_subpath, arg_iterator),
                                   total=len(subpaths)):
            pairs.extend(pair_list)
        pool.close()
        pool.join()
        root_tf.close()

        return pairs
def train_or_val_pairs ( self , setn ) : img_dir = os . path . join ( self . out_dir , setn ) neon_logger . display ( "Extracting %s files" % ( setn ) ) root_tf_path = self . tars [ setn ] if not os . path . exists ( root_tf_path ) : raise IOError ( ( "tar file {} not found. Ensure you have ImageNet downloaded" ) . format ( root_tf_path ) ) try : root_tf = tarfile . open ( root_tf_path ) except tarfile . ReadError as e : raise ValueError ( 'ReadError opening {}: {}' . format ( root_tf_path , e ) ) label_dict = self . extract_labels ( setn ) subpaths = root_tf . getmembers ( ) arg_iterator = zip ( repeat ( self . target_size ) , repeat ( root_tf_path ) , repeat ( img_dir ) , repeat ( setn ) , repeat ( label_dict ) , subpaths ) pool = multiprocessing . Pool ( ) pairs = [ ] for pair_list in tqdm . tqdm ( pool . imap_unordered ( process_i1k_tar_subpath , arg_iterator ) , total = len ( subpaths ) ) : pairs . extend ( pair_list ) pool . close ( ) pool . join ( ) root_tf . close ( ) return pairs