MCPcopy
hub / github.com/NVlabs/SPADE / save_image

Function save_image

util/util.py:128–138  ·  view source on GitHub ↗
(image_numpy, image_path, create_dir=False)

Source from the content-addressed store, hash-verified

126
127
128def save_image(image_numpy, image_path, create_dir=False):
129 if create_dir:
130 os.makedirs(os.path.dirname(image_path), exist_ok=True)
131 if len(image_numpy.shape) == 2:
132 image_numpy = np.expand_dims(image_numpy, axis=2)
133 if image_numpy.shape[2] == 1:
134 image_numpy = np.repeat(image_numpy, 3, 2)
135 image_pil = Image.fromarray(image_numpy)
136
137 # save to png
138 image_pil.save(image_path.replace('.jpg', '.png'))
139
140
141def mkdirs(paths):

Callers

nothing calls this directly

Calls 1

saveMethod · 0.45

Tested by

no test coverage detected