(path)
| 103 | |
| 104 | |
| 105 | def test_metads_batch(path): |
| 106 | def process_fn(stream): |
| 107 | for x in stream: |
| 108 | tmp1 = Image.open(io.BytesIO(x['jpg'])).convert('RGB').resize((256, 256)) |
| 109 | # to tensor |
| 110 | tmp1 = torch.from_numpy(np.array(tmp1)).permute(2, 0, 1) |
| 111 | yield tmp1 |
| 112 | |
| 113 | d = MetaDistributedWebDataset(path, process_fn, 0) |
| 114 | batch_size = 16 |
| 115 | loader = torch.utils.data.DataLoader(d, batch_size=batch_size, num_workers=8) |
| 116 | it = iter(loader) |
| 117 | t = time.time() |
| 118 | for i in range(2048 // batch_size): |
| 119 | tmp = next(it) |
| 120 | print("metaDS: Time to read 2048 images: ", time.time() - t) |
| 121 | |
| 122 | from webdataset import WebDataset |
| 123 | # test_raw_reading(WebDataset("/mnt/shared/img_datasets/clay1b_dataset/coyo_700m_merged_cleaned_wds/part-00000/000000.tar")) |
no test coverage detected