MCPcopy Create free account
hub / github.com/Vchitect/Latte / create_npz_from_sample_folder

Function create_npz_from_sample_folder

sample/sample_ddp.py:34–48  ·  view source on GitHub ↗

Builds a single .npz file from a folder of .png samples.

(sample_dir, num=50_000)

Source from the content-addressed store, hash-verified

32
33
34def create_npz_from_sample_folder(sample_dir, num=50_000):
35 """
36 Builds a single .npz file from a folder of .png samples.
37 """
38 samples = []
39 for i in tqdm(range(num), desc="Building .npz file from samples"):
40 sample_pil = Image.open(f"{sample_dir}/{i:06d}.png")
41 sample_np = np.asarray(sample_pil).astype(np.uint8)
42 samples.append(sample_np)
43 samples = np.stack(samples)
44 assert samples.shape == (num, samples.shape[1], samples.shape[2], 3)
45 npz_path = f"{sample_dir}.npz"
46 np.savez(npz_path, arr_0=samples)
47 print(f"Saved .npz file to {npz_path} [shape={samples.shape}].")
48 return npz_path
49
50
51def main(args):

Callers

nothing calls this directly

Calls 1

appendMethod · 0.80

Tested by

no test coverage detected