Spaces:
dylanebert
/
Running on Zero

File size: 1,631 Bytes
5f9d349
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
def scene_cameras_train_test_split(scene, verbose=False):
    """
    Iterate over resolutions in the scene. For each resolution check if this resolution has test_cameras
    if it doesn't then extract every 8th camera from the train and put it to the test set. This follows the
    evaluation protocol suggested by Kerbl et al. in the seminal work on 3DGS. All changes to the input
    object scene are inplace changes.
    :param scene: Scene Class object from the gaussian-splatting.scene module
    :param verbose: Print initial and final stage of the function
    :return:  None

    """
    if verbose: print("Preparing train and test sets split...")
    for resolution in scene.train_cameras.keys():
        if len(scene.test_cameras[resolution]) == 0:
            if verbose:
                print(f"Found no test_cameras for resolution {resolution}. Move every 8th camera out ouf total "+\
                      f"{len(scene.train_cameras[resolution])} train cameras to the test set now")
            N = len(scene.train_cameras[resolution])
            scene.test_cameras[resolution] = [scene.train_cameras[resolution][idx] for idx in range(0, N) 
                                              if idx % 8 == 0]
            scene.train_cameras[resolution] = [scene.train_cameras[resolution][idx] for idx in range(0, N)
                                               if idx % 8 != 0]
            if verbose:
                print(f"Done. Now train and test sets contain each {len(scene.train_cameras[resolution])} and " + \
                      f"{len(scene.test_cameras[resolution])} cameras respectively.")


    return