mirror of
https://github.com/nerfstudio-project/nerfstudio.git
synced 2026-11-16 04:43:52 +08:00
Code cleanup (#234)
This commit is contained in:
1 parent
8b414bafab
commit
e35781fe85
14 files changed
+46
-68
No files matched your search
@@ -66,8 +66,8 @@ CAMERA_MODELS = {
|
||||
CameraModel(model_id=9, model_name="RADIAL_FISHEYE", num_params=5),
|
||||
CameraModel(model_id=10, model_name="THIN_PRISM_FISHEYE", num_params=12),
|
||||
}
|
||||
CAMERA_MODEL_IDS = dict([(camera_model.model_id, camera_model) for camera_model in CAMERA_MODELS])
|
||||
CAMERA_MODEL_NAMES = dict([(camera_model.model_name, camera_model) for camera_model in CAMERA_MODELS])
|
||||
CAMERA_MODEL_IDS = {camera_model.model_id: camera_model for camera_model in CAMERA_MODELS}
|
||||
CAMERA_MODEL_NAMES = {camera_model.model_name: camera_model for camera_model in CAMERA_MODELS}
|
||||
|
||||
|
||||
def read_next_bytes(fid, num_bytes, format_char_sequence, endian_character="<"):
|
||||
@@ -109,7 +109,7 @@ def read_cameras_text(path):
|
||||
void Reconstruction::ReadCamerasText(const std::string& path)
|
||||
"""
|
||||
cameras = {}
|
||||
with open(path, "r") as fid:
|
||||
with open(path) as fid:
|
||||
while True:
|
||||
line = fid.readline()
|
||||
if not line:
|
||||
@@ -160,7 +160,7 @@ def write_cameras_text(cameras, path):
|
||||
HEADER = (
|
||||
"# Camera list with one line of data per camera:\n"
|
||||
+ "# CAMERA_ID, MODEL, WIDTH, HEIGHT, PARAMS[]\n"
|
||||
+ "# Number of cameras: {}\n".format(len(cameras))
|
||||
+ f"# Number of cameras: {len(cameras)}\n"
|
||||
)
|
||||
with open(path, "w") as fid:
|
||||
fid.write(HEADER)
|
||||
@@ -194,7 +194,7 @@ def read_images_text(path):
|
||||
void Reconstruction::WriteImagesText(const std::string& path)
|
||||
"""
|
||||
images = {}
|
||||
with open(path, "r") as fid:
|
||||
with open(path) as fid:
|
||||
while True:
|
||||
line = fid.readline()
|
||||
if not line:
|
||||
@@ -272,7 +272,7 @@ def write_images_text(images, path):
|
||||
"# Image list with two lines of data per image:\n"
|
||||
+ "# IMAGE_ID, QW, QX, QY, QZ, TX, TY, TZ, CAMERA_ID, NAME\n"
|
||||
+ "# POINTS2D[] as (X, Y, POINT3D_ID)\n"
|
||||
+ "# Number of images: {}, mean observations per image: {}\n".format(len(images), mean_observations)
|
||||
+ f"# Number of images: {len(images)}, mean observations per image: {mean_observations}\n"
|
||||
)
|
||||
|
||||
with open(path, "w") as fid:
|
||||
@@ -316,7 +316,7 @@ def read_pointsTD_text(path):
|
||||
void Reconstruction::WritePoints3DText(const std::string& path)
|
||||
"""
|
||||
points3D = {}
|
||||
with open(path, "r") as fid:
|
||||
with open(path) as fid:
|
||||
while True:
|
||||
line = fid.readline()
|
||||
if not line:
|
||||
@@ -374,7 +374,7 @@ def write_pointsTD_text(points3D, path):
|
||||
HEADER = (
|
||||
"# 3D point list with one line of data per point:\n"
|
||||
+ "# POINT3D_ID, X, Y, Z, R, G, B, ERROR, TRACK[] as (IMAGE_ID, POINT2D_IDX)\n"
|
||||
+ "# Number of points: {}, mean track length: {}\n".format(len(points3D), mean_track_length)
|
||||
+ f"# Number of points: {len(points3D)}, mean track length: {mean_track_length}\n"
|
||||
)
|
||||
|
||||
with open(path, "w") as fid:
|
||||
|
||||
@@ -41,7 +41,7 @@ def collate_image_dataset_batch(batch, num_rays_per_batch, keep_full_image: bool
|
||||
* torch.tensor([num_images, image_height, image_width], device=device)
|
||||
).long()
|
||||
|
||||
c, y, x = [i.flatten() for i in torch.split(indices, 1, dim=-1)]
|
||||
c, y, x = (i.flatten() for i in torch.split(indices, 1, dim=-1))
|
||||
image = batch["image"][c, y, x]
|
||||
mask, semantics = None, None
|
||||
if "mask" in batch:
|
||||
|
||||
Reference in new issue
Block a user