Skip to content

Commit

Permalink
fix & update
Browse files Browse the repository at this point in the history
  • Loading branch information
Chaphlagical committed May 13, 2024
1 parent c4d13eb commit 07cb672
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 20 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,6 @@
[submodule "submodule/diff-gaussian-rasterization"]
path = submodule/diff-gaussian-rasterization
url = https://github.com/Chaphlagical/diff-gaussian-rasterization
[submodule "submodule/pytorch3d"]
path = submodule/pytorch3d
url = https://github.com/facebookresearch/pytorch3d
2 changes: 2 additions & 0 deletions environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ dependencies:
- torchvision=0.13.1
- tqdm
- timm
- torchmetrics
- pip:
- submodule/diff-gaussian-rasterization
- submodule/knn
- submodule/pytorch3d
- opencv-python
1 change: 1 addition & 0 deletions submodule/pytorch3d
Submodule pytorch3d added at 171171
39 changes: 19 additions & 20 deletions utils/general_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,31 +130,30 @@ def build_scaling_rotation(s, r):
L = R @ L
return L


@torch.no_grad
def visualize_depth(depth, minmax=None, cmap=cv2.COLORMAP_TURBO):
"""
depth: (H, W)
"""
if len(depth.shape) == 3:
depth = depth.squeeze(0)

if type(depth) is not np.ndarray:
depth = depth.cpu().numpy()

x = np.nan_to_num(depth) # change nan to 0
if minmax is None:
# get minimum positive depth (ignore background)
mi = np.min(x)
ma = np.max(x)
else:
mi, ma = minmax
with torch.no_grad():
if len(depth.shape) == 3:
depth = depth.squeeze(0)

if type(depth) is not np.ndarray:
depth = depth.cpu().numpy()

x = np.nan_to_num(depth) # change nan to 0
if minmax is None:
# get minimum positive depth (ignore background)
mi = np.min(x)
ma = np.max(x)
else:
mi, ma = minmax

x = (x - mi) / (ma - mi + 1e-8) # normalize to 0~1
x = (255 * x).astype(np.uint8)
x = Image.fromarray(cv2.applyColorMap(x, cmap))
x = T.ToTensor()(x) # (3, H, W)
return x
x = (x - mi) / (ma - mi + 1e-8) # normalize to 0~1
x = (255 * x).astype(np.uint8)
x = Image.fromarray(cv2.applyColorMap(x, cmap))
x = T.ToTensor()(x) # (3, H, W)
return x


def check_socket_open(hostname, port):
Expand Down

0 comments on commit 07cb672

Please sign in to comment.