コード例 #1
0
    def test_unsupervised(self):
        """Test the BetterLoader Unsupervised call using the default parameters"""
        index_json = "./examples/sample_index_unsupervised.json"
        basepath = "./examples/sample_dataset/"
        batch_size = 2
        metadata = collate_metadata()
        better_loader = UnsupervisedBetterLoader(
            basepath=basepath,
            base_experiment_details=["simclr", 1, (150, 150)],
            index_json_path=index_json,
            dataset_metadata=metadata,
        )
        dataloaders, sizes = better_loader.fetch_segmented_dataloaders(
            batch_size=batch_size)

        assert dataloaders is not None

        assert sizes["train"] == 4
        assert sizes["test"] == 2
        assert sizes["val"] == 2
コード例 #2
0
    def test_complex_metadata(self):

        index_json = "./examples/sample_index.json"
        basepath = "./examples/sample_dataset/"
        batch_size = 2

        dataset_metadata = collate_metadata()
        loader = BetterLoader(
            basepath=basepath,
            index_json_path=index_json,
            dataset_metadata=dataset_metadata,
        )
        dataloaders, sizes = loader.fetch_segmented_dataloaders(
            batch_size=batch_size, transform=None)

        assert dataloaders is not None

        assert sizes["train"] == 4
        assert sizes["test"] == 2
        assert sizes["val"] == 2
コード例 #3
0
from betterloader import UnsupervisedBetterLoader
from betterloader.defaults import collate_metadata
from PIL import Image

index_json = "./sample_index_unsupervised.json"
basepath = "./sample_dataset/"
batch_size = 2
metadata = collate_metadata()
better_loader = UnsupervisedBetterLoader(
    basepath=basepath,
    base_experiment_details=["simclr", 1, (150, 150)],
    index_json_path=index_json,
    dataset_metadata=metadata,
)
dataloaders, sizes = better_loader.fetch_segmented_dataloaders(
    batch_size=batch_size)

for i, ((xp1, xp2), _) in enumerate(dataloaders["train"]):
    print(i)
    print(xp1.shape)