[label] pad_mode = "constant" pad_fill = 255 resize_mode = "nearest" grayscale = False filename = "{prefix}_{subset}-p{x_pad}x{y_pad}x{z_pad}-labeldata.idx" use_channel_dim = False """ from __future__ import division, print_function, unicode_literals import numpy as np from scipy.misc import imresize import datasets.pascal as pc from mlizard import createExperiment from infrastructure.idxconverter import write_idx_file ex = createExperiment(config_string=__doc__) @ex.stage def get_image_path_list(subset): return list({'train' : pc.get_seg_train_image_files, 'val' : pc.get_seg_val_image_files, 'all' : pc.get_seg_trainval_image_files}[subset]()) @ex.stage def get_label_path_list(subset): return list({'train' : pc.get_seg_train_class_label_files, 'val' : pc.get_seg_val_class_label_files, 'all' : pc.get_seg_trainval_class_label_files}[subset]()) get_classes_matrix = ex.stage(pc.get_classes_matrix)
# You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. """ seed = 380434 ds_path = "/home/greff/Datasets/ImageNet/" used_classes = [1, 2, 3, 4] samples_per_class = 10 shuffle = True """ from __future__ import division, print_function, unicode_literals from os.path import join import numpy as np from mlizard import createExperiment ex = createExperiment("ImageNet", config_string=__doc__) @ex.stage def get_image_paths_and_classes(ds_path, logger): path = join(ds_path, "trainfiles.txt" ) f = open(path, 'r') lines = f.readlines() lines = map(lambda s : s.split(None, 1), lines) paths = np.array([join(ds_path, p) for p, c in lines]) targets = np.array([[int(c)] for p, c in lines]) logger.info("Opened path '%s' and got %d samples.", path, len(lines)) return paths, targets @ex.stage def get_subset_indices(targets, used_classes, samples_per_class, shuffle, rnd): indices_for_class = []