MCPcopy
hub / github.com/stas00/ml-engineering / unpack

Function unpack

debug/tiny-scripts/m4-ds-unpack.py:59–76  ·  view source on GitHub ↗
(args, idx, row)

Source from the content-addressed store, hash-verified

57 if '-' in i else [int(i)]) for i in s.split(',')), [])
58
59def unpack(args, idx, row):
60 #pprint(row)
61 path = f"{args.target_path}/{idx}"
62 Path(path).mkdir(parents=True, exist_ok=True)
63 for i, img in enumerate(row["images"]):
64 basename = f"{path}/images_{i:02d}"
65 ext = "null" if img is None else "jpg"
66 file = f"{basename}.{ext}"
67 with open(file, "w") as fh:
68 if img is not None:
69 img.save(fh, 'jpeg')
70 for i, txt in enumerate(row["texts"]):
71 basename = f"{path}/texts_{i:02d}"
72 ext = "null" if txt is None else "txt"
73 file = f"{basename}.{ext}"
74 with open(file, "w") as fh:
75 if txt is not None:
76 fh.write(txt)
77
78def dump_example_shapes(idx, row):
79 """ dump the row stats """

Callers 1

m4-ds-unpack.pyFile · 0.70

Calls 1

writeMethod · 0.45

Tested by

no test coverage detected