MCPcopy Create free account
hub / github.com/QWTforGithub/T2LDM / revert_depth

Function revert_depth

utils/common.py:2080–2098  ·  view source on GitHub ↗

Revert normalized depth in [0, 1] back to metric depth in [0, `max_depth`].

(
    normalized: torch.Tensor,
    image_format="log_depth",
    max_depth=50.0,
    min_depth=0.01,
)

Source from the content-addressed store, hash-verified

2078 return normalized
2079
2080def revert_depth(
2081 normalized: torch.Tensor,
2082 image_format="log_depth",
2083 max_depth=50.0,
2084 min_depth=0.01,
2085) -> torch.Tensor:
2086 """
2087 Revert normalized depth in [0, 1] back to metric depth in [0, `max_depth`].
2088 """
2089
2090 if image_format == "log_depth":
2091 metric = torch.exp2(normalized * np.log2(max_depth + 1 + 0.0001)) - 1 - 0.0001
2092 elif image_format == "inverse_depth":
2093 metric = min_depth / normalized.add(1e-8)
2094 elif image_format == "depth":
2095 metric = normalized.mul(max_depth)
2096 else:
2097 raise ValueError
2098 return metric * get_mask(metric)
2099
2100def denormalize(x):
2101 """Scale from [-1, +1] to [0, 1]"""

Callers

nothing calls this directly

Calls 1

get_maskFunction · 0.85

Tested by

no test coverage detected