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

Function read_MiDaS_depth

inpaint/utils.py:942–954  ·  view source on GitHub ↗
(disp_fi, disp_rescale=10., h=None, w=None)

Source from the content-addressed store, hash-verified

940 return depth_map
941
942def read_MiDaS_depth(disp_fi, disp_rescale=10., h=None, w=None):
943 if 'npy' in os.path.splitext(disp_fi)[-1]:
944 disp = np.load(disp_fi)
945 else:
946 disp = imageio.imread(disp_fi).astype(np.float32)
947 disp = disp - disp.min()
948 disp = cv2.blur(disp / disp.max(), ksize=(3, 3)) * disp.max()
949 disp = (disp / disp.max()) * disp_rescale
950 if h is not None and w is not None:
951 disp = resize(disp / disp.max(), (h, w), order=1) * disp.max()
952 depth = 1. / np.maximum(disp, 0.05)
953
954 return depth
955
956def follow_image_aspect_ratio(depth, image):
957 H, W = image.shape[:2]

Callers 1

main.pyFile · 0.90

Calls 1

loadMethod · 0.80

Tested by

no test coverage detected