Skip to content

Commit

Permalink
fix cpu ram following graphdeco-inria#667
Browse files Browse the repository at this point in the history
  • Loading branch information
nnmhuy committed Sep 24, 2024
1 parent bf641e5 commit 894c4e0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
3 changes: 2 additions & 1 deletion utils/camera_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ def loadCam(args, id, cam_info, resolution_scale):
scale = float(global_down) * float(resolution_scale)
resolution = (int(orig_w / scale), int(orig_h / scale))

resized_image_rgb = PILtoTorch(cam_info.image, resolution)
# resized_image_rgb = PILtoTorch(cam_info.image, resolution)
resized_image_rgb = PILtoTorch(cam_info.image, resolution, args.data_device)

gt_image = resized_image_rgb[:3, ...]
loaded_mask = None
Expand Down
6 changes: 4 additions & 2 deletions utils/general_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,11 @@
def inverse_sigmoid(x):
return torch.log(x/(1-x))

def PILtoTorch(pil_image, resolution):
def PILtoTorch(pil_image, resolution, data_device="cuda"):
resized_image_PIL = pil_image.resize(resolution)
resized_image = torch.from_numpy(np.array(resized_image_PIL)) / 255.0
# resized_image = torch.from_numpy(np.array(resized_image_PIL)) / 255.0
resized_image = torch.from_numpy(np.array(resized_image_PIL)).to(data_device) / 255.0

if len(resized_image.shape) == 3:
return resized_image.permute(2, 0, 1)
else:
Expand Down

0 comments on commit 894c4e0

Please sign in to comment.