MCPcopy Index your code
hub / github.com/thygate/stable-diffusion-webui-depthmap-script / save_raw_16bit

Function save_raw_16bit

dzoedepth/utils/misc.py:358–368  ·  view source on GitHub ↗
(depth, fpath="raw.png")

Source from the content-addressed store, hash-verified

356 return ToTensor()(img).unsqueeze(0)
357
358def save_raw_16bit(depth, fpath="raw.png"):
359 if isinstance(depth, torch.Tensor):
360 depth = depth.squeeze().cpu().numpy()
361
362 assert isinstance(depth, np.ndarray), "Depth must be a torch tensor or numpy array"
363 assert depth.ndim == 2, "Depth must be 2D"
364 depth = depth * 256 # scale for 16-bit png
365 depth = depth.astype(np.uint16)
366 depth = Image.fromarray(depth)
367 depth.save(fpath)
368 print("Saved raw depth to", fpath)

Callers

nothing calls this directly

Calls 1

saveMethod · 0.45

Tested by

no test coverage detected