Pārlūkot izejas kodu

Merge branch 'main' of https://github.com/graphdeco-inria/gaussian-splatting

Bernhard Kerbl 2 gadi atpakaļ
vecāks
revīzija
7228fc7bd9
5 mainītis faili ar 102 papildinājumiem un 49 dzēšanām
  1. 72 21
      README.md
  2. 22 20
      convert.py
  3. 4 4
      scene/dataset_readers.py
  4. 1 1
      submodules/simple-knn
  5. 3 3
      train.py

Failā izmaiņas netiks attēlotas, jo tās ir par lielu
+ 72 - 21
README.md


+ 22 - 20
convert.py

@@ -16,6 +16,7 @@ import shutil
 # This Python script is based on the shell converter script provided in the MipNerF 360 repository.
 parser = ArgumentParser("Colmap converter")
 parser.add_argument("--no_gpu", action='store_true')
+parser.add_argument("--skip_matching", action='store_true')
 parser.add_argument("--source_path", "-s", required=True, type=str)
 parser.add_argument("--camera", default="OPENCV", type=str)
 parser.add_argument("--colmap_executable", default="", type=str)
@@ -26,29 +27,30 @@ colmap_command = '"{}"'.format(args.colmap_executable) if len(args.colmap_execut
 magick_command = '"{}"'.format(args.magick_executable) if len(args.magick_executable) > 0 else "magick"
 use_gpu = 1 if not args.no_gpu else 0
 
-os.makedirs(args.source_path + "/distorted/sparse", exist_ok=True)
+if not args.skip_matching:
+    os.makedirs(args.source_path + "/distorted/sparse", exist_ok=True)
 
-## Feature extraction
-os.system(colmap_command + " feature_extractor "\
-    "--database_path " + args.source_path + "/distorted/database.db \
-    --image_path " + args.source_path + "/input \
-    --ImageReader.single_camera 1 \
-    --ImageReader.camera_model " + args.camera + " \
-    --SiftExtraction.use_gpu " + str(use_gpu))
+    ## Feature extraction
+    os.system(colmap_command + " feature_extractor "\
+        "--database_path " + args.source_path + "/distorted/database.db \
+        --image_path " + args.source_path + "/input \
+        --ImageReader.single_camera 1 \
+        --ImageReader.camera_model " + args.camera + " \
+        --SiftExtraction.use_gpu " + str(use_gpu))
 
-## Feature matching
-os.system(colmap_command + " exhaustive_matcher \
-    --database_path " + args.source_path + "/distorted/database.db \
-    --SiftMatching.use_gpu " + str(use_gpu))
+    ## Feature matching
+    os.system(colmap_command + " exhaustive_matcher \
+        --database_path " + args.source_path + "/distorted/database.db \
+        --SiftMatching.use_gpu " + str(use_gpu))
 
-### Bundle adjustment
-# The default Mapper tolerance is unnecessarily large,
-# decreasing it speeds up bundle adjustment steps.
-os.system(colmap_command + " mapper \
-    --database_path " + args.source_path + "/distorted/database.db \
-    --image_path "  + args.source_path + "/input \
-    --output_path "  + args.source_path + "/distorted/sparse \
-    --Mapper.ba_global_function_tolerance=0.000001")
+    ### Bundle adjustment
+    # The default Mapper tolerance is unnecessarily large,
+    # decreasing it speeds up bundle adjustment steps.
+    os.system(colmap_command + " mapper \
+        --database_path " + args.source_path + "/distorted/database.db \
+        --image_path "  + args.source_path + "/input \
+        --output_path "  + args.source_path + "/distorted/sparse \
+        --Mapper.ba_global_function_tolerance=0.000001")
 
 ### Image undistortion
 ## We need to undistort our images into ideal pinhole intrinsics.

+ 4 - 4
scene/dataset_readers.py

@@ -92,7 +92,7 @@ def readColmapCameras(cam_extrinsics, cam_intrinsics, images_folder):
             FovY = focal2fov(focal_length_y, height)
             FovX = focal2fov(focal_length_x, width)
         else:
-            assert False, "Colmap camera model not handled!"
+            assert False, "Colmap camera model not handled: only undistorted datasets (PINHOLE or SIMPLE_PINHOLE cameras) supported!"
 
         image_path = os.path.join(images_folder, os.path.basename(extr.name))
         image_name = os.path.basename(image_path).split(".")[0]
@@ -154,9 +154,9 @@ def readColmapSceneInfo(path, images, eval, llffhold=8):
 
     nerf_normalization = getNerfppNorm(train_cam_infos)
 
-    ply_path = os.path.join(path, "sparse/0/points3d.ply")
-    bin_path = os.path.join(path, "sparse/0/points3d.bin")
-    txt_path = os.path.join(path, "sparse/0/points3d.txt")
+    ply_path = os.path.join(path, "sparse/0/points3D.ply")
+    bin_path = os.path.join(path, "sparse/0/points3D.bin")
+    txt_path = os.path.join(path, "sparse/0/points3D.txt")
     if not os.path.exists(ply_path):
         print("Converting point3d.bin to .ply, will happen only the first time you open the scene.")
         try:

+ 1 - 1
submodules/simple-knn

@@ -1 +1 @@
-Subproject commit 76eff30b1533718fe652799729203821b7f54d73
+Subproject commit 44f764299fa305faf6ec5ebd99939e0508331503

+ 3 - 3
train.py

@@ -162,9 +162,9 @@ def training_report(tb_writer, iteration, Ll1, loss, l1_loss, elapsed, testing_i
                     images = torch.cat((images, image.unsqueeze(0)), dim=0)
                     gts = torch.cat((gts, gt_image.unsqueeze(0)), dim=0)
                     if tb_writer and (idx < 5):
-                        tb_writer.add_images(config['name'] + "_view_{}/render".format(viewpoint.image_name), image, global_step=iteration)
+                        tb_writer.add_images(config['name'] + "_view_{}/render".format(viewpoint.image_name), image[None], global_step=iteration)
                         if iteration == testing_iterations[0]:
-                            tb_writer.add_images(config['name'] + "_view_{}/ground_truth".format(viewpoint.image_name), gt_image, global_step=iteration)
+                            tb_writer.add_images(config['name'] + "_view_{}/ground_truth".format(viewpoint.image_name), gt_image[None], global_step=iteration)
 
                 l1_test = l1_loss(images, gts)
                 psnr_test = psnr(images, gts).mean()            
@@ -204,4 +204,4 @@ if __name__ == "__main__":
     training(lp.extract(args), op.extract(args), pp.extract(args), args.test_iterations, args.save_iterations)
 
     # All done
-    print("\nTraining complete.")
+    print("\nTraining complete.")