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

Function dump_as_core_artifacts

dali/test/python/test_utils.py:215–248  ·  view source on GitHub ↗
(image_info, lhs, rhs, iter=None, sample_idx=None)

Source from the content-addressed store, hash-verified

213
214
215def dump_as_core_artifacts(image_info, lhs, rhs, iter=None, sample_idx=None):
216 import_numpy()
217 import_pil()
218
219 from pathlib import Path
220
221 path = (
222 "/opt/dali"
223 if os.path.exists("/opt/dali") and os.access("/opt/dali", os.W_OK)
224 else os.getcwd()
225 )
226 Path(f"{path}/core_artifacts").mkdir(parents=True, exist_ok=True)
227
228 image_info = image_info.replace("/", "_")
229 image_info = image_info.replace(" ", "_")
230 if iter is not None:
231 image_info = image_info + f"_iter{iter}"
232 if sample_idx is not None:
233 image_info = image_info + f"_sample_idx{sample_idx}"
234
235 try:
236 save_image(lhs, f"{path}/core_artifacts/{image_info}.lhs.png")
237 save_image(rhs, f"{path}/core_artifacts/{image_info}.rhs.png")
238 except Exception as e:
239 print(f"Tried to save images but got an error: {e}")
240
241 try:
242 # save arrays on artifact folder
243 import numpy as np
244
245 np.save(f"{path}/core_artifacts/{image_info}.lhs.npy", lhs)
246 np.save(f"{path}/core_artifacts/{image_info}.rhs.npy", rhs)
247 except Exception as e:
248 print(f"Tried to save arrays but got an error: {e}")
249
250
251# If the `max_allowed_error` is not None, it's checked instead of comparing mean error with `eps`.

Callers 4

test_border_modesFunction · 0.90
test_border_modesFunction · 0.90
run_decode_fusedFunction · 0.90
check_batchFunction · 0.85

Calls 6

import_pilFunction · 0.85
save_imageFunction · 0.85
printFunction · 0.85
existsMethod · 0.80
import_numpyFunction · 0.70
saveMethod · 0.45

Tested by

no test coverage detected