File size: 919 Bytes
bd4eea7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import os
from typing import List

import torch
from omegaconf import OmegaConf
import numpy as np

from sdata import create_dataset, create_loader

num_it = 100
max_vis = 3

if __name__ == "__main__":
    filedir = os.path.realpath(os.path.dirname(__file__))
    config_path = os.path.join(filedir, "configs", "example.yaml")
    config = OmegaConf.load(config_path)

    # build config
    datapipeline = create_dataset(**config.dataset)

    # build loader
    loader = create_loader(datapipeline, **config.loader)

    print(f"Yielding {num_it} batches")

    for i, batch in enumerate(loader):
        if i >= num_it:
            break

        for key in batch:
            if isinstance(batch[key], (torch.Tensor, np.ndarray)):
                print(key, batch[key].shape)
            elif isinstance(batch[key], (List)):
                print(key)
                print(batch[key][:max_vis])

    print("ciao")