MCPcopy Index your code
hub / github.com/OpenDriveLab/ReSim / test_metads_batch

Function test_metads_batch

SwissArmyTransformer/tests/test_read_img.py:105–120  ·  view source on GitHub ↗
(path)

Source from the content-addressed store, hash-verified

103
104
105def 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
122from webdataset import WebDataset
123# test_raw_reading(WebDataset("/mnt/shared/img_datasets/clay1b_dataset/coyo_700m_merged_cleaned_wds/part-00000/000000.tar"))

Callers 1

test_read_img.pyFile · 0.85

Calls 2

printFunction · 0.50

Tested by

no test coverage detected