Exemple #1
0
def save_ds_samples():
    """Load datasets from pickle files. Get samples from random indices and save them as JPEG images"""

    pickles = [
        "../datasets/stl10/original_train.pkl",
        "../datasets/stl10/mirror_train.pkl",
        "../datasets/stl10/rot_90_1_train.pkl",
        "../datasets/stl10/rot_90_3_train.pkl",
        "../datasets/stl10/rand_distorted_train_0.pkl",
        "../datasets/stl10/rand_distorted_train_1.pkl",
        "../datasets/stl10/rand_distorted_train_2.pkl",
    ]
    dataset = ImageDataset.load_from_pickles(pickles)
    items_per_pickle = 11000

    for i in range(20):
        images = []
        idx = randint(0, items_per_pickle - 1)
        for j in range(len(pickles)):
            images.append(
                LabeledImage.load_from_dataset(dataset,
                                               index=j * items_per_pickle +
                                               idx,
                                               max_value=1), )
        LabeledImage(np.concatenate([x.image for x in images], axis=1), images[0].name) \
            .save(location="../samples/", name="{}_{}".format(idx, images[0].name))
Exemple #2
0
def load_eval_dataset():
    """Load Evaluation dataset from list of pickle files"""

    dataset = ImageDataset.load_from_pickles([
        "../datasets/stl10/original_test.pkl",
    ])

    return dataset.x, dataset.y
Exemple #3
0
def load_train_dataset():
    """Load Training dataset from list of pickle files"""

    dataset = ImageDataset.load_from_pickles([
        "../datasets/stl10/original_train.pkl",
        "../datasets/stl10/mirror_train.pkl",
        # "../datasets/stl10/rot_90_1_train.pkl",
        # "../datasets/stl10/rot_90_3_train.pkl",
        "../datasets/stl10/rand_distorted_train_0.pkl",
        # "../datasets/stl10/rand_distorted_train_1.pkl",
        # "../datasets/stl10/rand_distorted_train_2.pkl",
    ])

    return dataset.x, dataset.y
Exemple #4
0
def load_cifar10():
    train_ds = ImageDataset.load_from_pickles([
        "/datasets/cifar10/original_train.pkl",
        "/datasets/cifar10/mirror_train.pkl",
        "/datasets/cifar10/rand_distorted_train.pkl",
    ])
    test_ds = ImageDataset.load_from_pickles([
        "/datasets/cifar10/original_test.pkl",
    ])

    offset = 1024
    img0 = LabeledImage.load_from_dataset_tuple((train_ds.x, train_ds.y),
                                                0 + offset)
    img1 = LabeledImage.load_from_dataset_tuple((train_ds.x, train_ds.y),
                                                50000 + offset)
    img2 = LabeledImage.load_from_dataset_tuple((train_ds.x, train_ds.y),
                                                100000 + offset)

    mixed_img = np.concatenate([img0.image, img1.image, img2.image], axis=1)
    LabeledImage(mixed_img, "mixed_" + img0.name) \
        .save_image()

    return (train_ds.x, train_ds.y), (test_ds.x, test_ds.y)