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

Function scale_torch

src/depthmap_generation.py:424–440  ·  view source on GitHub ↗

Scale the image and output it in torch.tensor. :param img: input rgb is in shape [H, W, C], input depth/disp is in shape [H, W] :param scale: the scale factor. float :return: img. [C, H, W]

(img)

Source from the content-addressed store, hash-verified

422
423
424def scale_torch(img):
425 """
426 Scale the image and output it in torch.tensor.
427 :param img: input rgb is in shape [H, W, C], input depth/disp is in shape [H, W]
428 :param scale: the scale factor. float
429 :return: img. [C, H, W]
430 """
431 if len(img.shape) == 2:
432 img = img[np.newaxis, :, :]
433 if img.shape[2] == 3:
434 transform = transforms.Compose(
435 [transforms.ToTensor(), transforms.Normalize((0.485, 0.456, 0.406), (0.229, 0.224, 0.225))])
436 img = transform(img.astype(np.float32))
437 else:
438 img = img.astype(np.float32)
439 img = torch.from_numpy(img)
440 return img
441
442
443def estimatezoedepth(img, model, w, h):

Callers 1

estimateleresFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected