MCPcopy Create free account
hub / github.com/NVIDIA/DALI / save_image

Function save_image

dali/test/python/test_utils.py:134–151  ·  view source on GitHub ↗
(image, file_name)

Source from the content-addressed store, hash-verified

132
133
134def save_image(image, file_name):
135 import_numpy()
136 import_pil()
137 if image.dtype == np.float32:
138 min = np.min(image)
139 max = np.max(image)
140 if min >= 0 and max <= 1:
141 image = image * 256
142 elif min >= -1 and max <= 1:
143 image = (image + 1) * 128
144 elif min >= -128 and max <= 127:
145 image = image + 128
146 else:
147 lo = np.iinfo(image.dtype).min
148 hi = np.iinfo(image.dtype).max
149 image = (image - lo) * (255.0 / (hi - lo))
150 image = image.astype(np.uint8)
151 Image.fromarray(image).save(file_name)
152
153
154def get_gpu_num():

Callers 1

dump_as_core_artifactsFunction · 0.85

Calls 5

import_pilFunction · 0.85
minMethod · 0.80
import_numpyFunction · 0.70
maxMethod · 0.45
saveMethod · 0.45

Tested by

no test coverage detected