From eebb59632fdce640655ca87740014c66614727fb Mon Sep 17 00:00:00 2001 From: Isabelle Bouchard Date: Mon, 18 Mar 2024 11:09:44 -0400 Subject: [PATCH] Rename utils files --- .../gaussian_renderer/__init__.py | 6 ++---- .../lpipsPyTorch/modules/lpips.py | 3 ++- gaussian_splatting/scene/__init__.py | 8 +++----- gaussian_splatting/scene/cameras.py | 3 ++- gaussian_splatting/scene/dataset_readers.py | 18 ++++++++---------- gaussian_splatting/scene/gaussian_model.py | 17 +++++++---------- gaussian_splatting/training.py | 6 +++--- .../utils/{camera_utils.py => camera.py} | 4 ++-- .../utils/{general_utils.py => general.py} | 0 .../utils/{graphics_utils.py => graphics.py} | 0 .../utils/{image_utils.py => image.py} | 0 .../utils/{loss_utils.py => loss.py} | 0 .../utils/{sh_utils.py => sh.py} | 0 .../utils/{system_utils.py => system.py} | 0 scripts/metrics.py | 4 ++-- scripts/render.py | 2 +- 16 files changed, 32 insertions(+), 39 deletions(-) rename gaussian_splatting/utils/{camera_utils.py => camera.py} (95%) rename gaussian_splatting/utils/{general_utils.py => general.py} (100%) rename gaussian_splatting/utils/{graphics_utils.py => graphics.py} (100%) rename gaussian_splatting/utils/{image_utils.py => image.py} (100%) rename gaussian_splatting/utils/{loss_utils.py => loss.py} (100%) rename gaussian_splatting/utils/{sh_utils.py => sh.py} (100%) rename gaussian_splatting/utils/{system_utils.py => system.py} (100%) diff --git a/gaussian_splatting/gaussian_renderer/__init__.py b/gaussian_splatting/gaussian_renderer/__init__.py index dc5db2e15..4f8677eff 100644 --- a/gaussian_splatting/gaussian_renderer/__init__.py +++ b/gaussian_splatting/gaussian_renderer/__init__.py @@ -12,10 +12,8 @@ import math import torch -from diff_gaussian_rasterization import ( - GaussianRasterizationSettings, - GaussianRasterizer, -) +from diff_gaussian_rasterization import (GaussianRasterizationSettings, + GaussianRasterizer) from gaussian_splatting.scene.gaussian_model import GaussianModel diff --git a/gaussian_splatting/lpipsPyTorch/modules/lpips.py b/gaussian_splatting/lpipsPyTorch/modules/lpips.py index 53927a12e..066bd83ad 100644 --- a/gaussian_splatting/lpipsPyTorch/modules/lpips.py +++ b/gaussian_splatting/lpipsPyTorch/modules/lpips.py @@ -1,7 +1,8 @@ import torch import torch.nn as nn -from gaussian_splatting.lpipsPyTorch.modules.networks import LinLayers, get_network +from gaussian_splatting.lpipsPyTorch.modules.networks import (LinLayers, + get_network) from gaussian_splatting.lpipsPyTorch.modules.utils import get_state_dict diff --git a/gaussian_splatting/scene/__init__.py b/gaussian_splatting/scene/__init__.py index 9314d91cd..af0c4f5ad 100644 --- a/gaussian_splatting/scene/__init__.py +++ b/gaussian_splatting/scene/__init__.py @@ -16,11 +16,9 @@ from gaussian_splatting.arguments import ModelParams from gaussian_splatting.scene.dataset_readers import readColmapSceneInfo from gaussian_splatting.scene.gaussian_model import GaussianModel -from gaussian_splatting.utils.camera_utils import ( - camera_to_JSON, - cameraList_from_camInfos, -) -from gaussian_splatting.utils.system_utils import searchForMaxIteration +from gaussian_splatting.utils.camera import (camera_to_JSON, + cameraList_from_camInfos) +from gaussian_splatting.utils.system import searchForMaxIteration class Scene: diff --git a/gaussian_splatting/scene/cameras.py b/gaussian_splatting/scene/cameras.py index 116ecfaa5..ae85edde4 100644 --- a/gaussian_splatting/scene/cameras.py +++ b/gaussian_splatting/scene/cameras.py @@ -13,7 +13,8 @@ import torch from torch import nn -from gaussian_splatting.utils.graphics_utils import getProjectionMatrix, getWorld2View2 +from gaussian_splatting.utils.graphics import (getProjectionMatrix, + getWorld2View2) class Camera(nn.Module): diff --git a/gaussian_splatting/scene/dataset_readers.py b/gaussian_splatting/scene/dataset_readers.py index 883deb6e5..99a7d1cc8 100644 --- a/gaussian_splatting/scene/dataset_readers.py +++ b/gaussian_splatting/scene/dataset_readers.py @@ -17,17 +17,15 @@ from PIL import Image from plyfile import PlyData, PlyElement -from gaussian_splatting.scene.colmap_loader import ( - qvec2rotmat, - read_extrinsics_binary, - read_extrinsics_text, - read_intrinsics_binary, - read_intrinsics_text, - read_points3D_binary, - read_points3D_text, -) +from gaussian_splatting.scene.colmap_loader import (qvec2rotmat, + read_extrinsics_binary, + read_extrinsics_text, + read_intrinsics_binary, + read_intrinsics_text, + read_points3D_binary, + read_points3D_text) from gaussian_splatting.scene.gaussian_model import BasicPointCloud -from gaussian_splatting.utils.graphics_utils import focal2fov, getWorld2View2 +from gaussian_splatting.utils.graphics import focal2fov, getWorld2View2 class CameraInfo(NamedTuple): diff --git a/gaussian_splatting/scene/gaussian_model.py b/gaussian_splatting/scene/gaussian_model.py index 4e16629dd..de785ba5a 100644 --- a/gaussian_splatting/scene/gaussian_model.py +++ b/gaussian_splatting/scene/gaussian_model.py @@ -17,16 +17,13 @@ from simple_knn._C import distCUDA2 from torch import nn -from gaussian_splatting.utils.general_utils import ( - build_rotation, - build_scaling_rotation, - get_expon_lr_func, - inverse_sigmoid, - strip_symmetric, -) -from gaussian_splatting.utils.graphics_utils import BasicPointCloud -from gaussian_splatting.utils.sh_utils import RGB2SH -from gaussian_splatting.utils.system_utils import mkdir_p +from gaussian_splatting.utils.general import (build_rotation, + build_scaling_rotation, + get_expon_lr_func, + inverse_sigmoid, strip_symmetric) +from gaussian_splatting.utils.graphics import BasicPointCloud +from gaussian_splatting.utils.sh import RGB2SH +from gaussian_splatting.utils.system import mkdir_p class GaussianModel: diff --git a/gaussian_splatting/training.py b/gaussian_splatting/training.py index 021aaa57c..35492f444 100644 --- a/gaussian_splatting/training.py +++ b/gaussian_splatting/training.py @@ -8,9 +8,9 @@ from gaussian_splatting.gaussian_renderer import render from gaussian_splatting.scene import GaussianModel, Scene -from gaussian_splatting.utils.general_utils import safe_state -from gaussian_splatting.utils.image_utils import psnr -from gaussian_splatting.utils.loss_utils import l1_loss, ssim +from gaussian_splatting.utils.general import safe_state +from gaussian_splatting.utils.image import psnr +from gaussian_splatting.utils.loss import l1_loss, ssim class Trainer: diff --git a/gaussian_splatting/utils/camera_utils.py b/gaussian_splatting/utils/camera.py similarity index 95% rename from gaussian_splatting/utils/camera_utils.py rename to gaussian_splatting/utils/camera.py index eeea4a1b6..b1f3002a5 100644 --- a/gaussian_splatting/utils/camera_utils.py +++ b/gaussian_splatting/utils/camera.py @@ -12,8 +12,8 @@ import numpy as np from gaussian_splatting.scene.cameras import Camera -from gaussian_splatting.utils.general_utils import PILtoTorch -from gaussian_splatting.utils.graphics_utils import fov2focal +from gaussian_splatting.utils.general import PILtoTorch +from gaussian_splatting.utils.graphics import fov2focal WARNED = False diff --git a/gaussian_splatting/utils/general_utils.py b/gaussian_splatting/utils/general.py similarity index 100% rename from gaussian_splatting/utils/general_utils.py rename to gaussian_splatting/utils/general.py diff --git a/gaussian_splatting/utils/graphics_utils.py b/gaussian_splatting/utils/graphics.py similarity index 100% rename from gaussian_splatting/utils/graphics_utils.py rename to gaussian_splatting/utils/graphics.py diff --git a/gaussian_splatting/utils/image_utils.py b/gaussian_splatting/utils/image.py similarity index 100% rename from gaussian_splatting/utils/image_utils.py rename to gaussian_splatting/utils/image.py diff --git a/gaussian_splatting/utils/loss_utils.py b/gaussian_splatting/utils/loss.py similarity index 100% rename from gaussian_splatting/utils/loss_utils.py rename to gaussian_splatting/utils/loss.py diff --git a/gaussian_splatting/utils/sh_utils.py b/gaussian_splatting/utils/sh.py similarity index 100% rename from gaussian_splatting/utils/sh_utils.py rename to gaussian_splatting/utils/sh.py diff --git a/gaussian_splatting/utils/system_utils.py b/gaussian_splatting/utils/system.py similarity index 100% rename from gaussian_splatting/utils/system_utils.py rename to gaussian_splatting/utils/system.py diff --git a/scripts/metrics.py b/scripts/metrics.py index 388ea9253..e6fd54292 100644 --- a/scripts/metrics.py +++ b/scripts/metrics.py @@ -20,8 +20,8 @@ from tqdm import tqdm from gaussian_splatting.lpipsPyTorch import lpips -from gaussian_splatting.utils.image_utils import psnr -from gaussian_splatting.utils.loss_utils import ssim +from gaussian_splatting.utils.image import psnr +from gaussian_splatting.utils.loss import ssim def readImages(renders_dir, gt_dir): diff --git a/scripts/render.py b/scripts/render.py index 838adfb19..1138a4983 100644 --- a/scripts/render.py +++ b/scripts/render.py @@ -20,7 +20,7 @@ from gaussian_splatting.arguments import ModelParams, get_combined_args from gaussian_splatting.gaussian_renderer import GaussianModel, render from gaussian_splatting.scene import Scene -from gaussian_splatting.utils.general_utils import safe_state +from gaussian_splatting.utils.general import safe_state def render_set(model_path, name, iteration, views, gaussians):