SegAnyGAussians icon indicating copy to clipboard operation
SegAnyGAussians copied to clipboard

Error in train_contrastive_feature.py on Lerf Dataset

Open polaris98 opened this issue 1 year ago • 5 comments

Hello, when I try to run train_contrastive_feature.py on the Lerf Dataset figurines (the one you can see used in the readme) to Train 3D Gaussian Affinity Features I get this error: File "/home/proietti/SegAnyGAussians/train_contrastive_feature.py", line 113, in training all_scales = torch.cat(all_scales) TypeError: expected Tensor as element 0 in argument 0, but got NoneType Training progress: 0%|
Any suggestion on how to fix this?

polaris98 avatar Dec 22 '24 22:12 polaris98

How did you extract the mask scales of the scene? Seems no scale is available.

Jumpat avatar Dec 23 '24 06:12 Jumpat

I used python get_scale.py --image_root --model_path <path to the pre-trained 3DGS model>. The mask _scales folder is created after running the line

polaris98 avatar Dec 23 '24 10:12 polaris98

Please check here. Did the script run readColmapCameras correctly? I doubt that the code use a wrong data loader, maybe a bug.

Jumpat avatar Dec 26 '24 02:12 Jumpat

Please check here. Did the script run readColmapCameras correctly? I doubt that the code use a wrong data loader, maybe a bug.

It is not running readColmapCameras since this is written for Colmap. I also fail in this step when using lerf dataset.

XcloudFance avatar Aug 01 '25 07:08 XcloudFance

The LERF dataset doesn’t use the COLMAP file format. Camera information is stored in transforms.json, so you need to enable this section in __init__.py:

elif os.path.exists(os.path.join(args.source_path, "transforms.json")):
    print("Found transforms.json file, assuming LERF dataset!")
    scene_info = sceneLoadTypeCallbacks["Lerf"](args.source_path, args.white_background, args.eval)

Then, add the following code to the readCamerasFromLerfTransforms function in dataset_reader.py:

mask_dir = "sam_masks"
mask_scale_dir = "mask_scales"
mask_scale_folder = os.path.join(path, mask_scale_dir)
mask_folder = os.path.join(path, mask_dir)

mask_scales = torch.load(os.path.join(mask_scale_folder, image_name.split('.')[0] + ".pt")) if mask_scale_folder is not None else None
masks = torch.load(os.path.join(mask_folder, image_name.split('.')[0] + ".pt")) if mask_folder is not None else None

Bourennaneyounes avatar Oct 07 '25 13:10 Bourennaneyounes