RuntimeError: shape is invalid for input of size
I have done evetything correctly and i am getting this error! Why does the input shape not match my image dimensions? Why is it initializing randomly (it changes every time I run it)?
Traceback (most recent call last):
File "/content/SuGaR/train.py", line 127, in
I have done evetything correctly and i am getting this error! Why does the input shape not match my image dimensions? Why is it initializing randomly (it changes every time I run it)?
Traceback (most recent call last): File "/content/SuGaR/train.py", line 127, in coarse_sugar_path = coarse_training_with_density_regularization(coarse_args) File "/content/SuGaR/sugar_trainers/coarse_density.py", line 526, in coarse_training_with_density_regularization gt_rgb = gt_image.view(-1, sugar.image_height, sugar.image_width, 3) RuntimeError: shape '[-1, 1024, 1920, 3]' is invalid for input of size 6059520
I think the resolution of the images you input is not all the same, so this is the cause of the problem
I have done evetything correctly and i am getting this error! Why does the input shape not match my image dimensions? Why is it initializing randomly (it changes every time I run it)?
Traceback (most recent call last): File "/content/SuGaR/train.py", line 127, in coarse_sugar_path = coarse_training_with_density_regularization(coarse_args) File "/content/SuGaR/sugar_trainers/coarse_density.py", line 526, in coarse_training_with_density_regularization gt_rgb = gt_image.view(-1, sugar.image_height, sugar.image_width, 3) RuntimeError: shape '[-1, 1024, 1920, 3]' is invalid for input of size 6059520
I got exactly the same errors.
@ywaison I used the same set of input/images to run this script. I believe the resolution of images are the same.
Is there any possible reasons I'm encountering this error? Thank you very much.
All my input images are size 1280 x 720
However, when I checked the cameras.json output from gaussian_splatting/train.py,
the resolutions are various and not the same as my image size.
I think this might be the reason why there would be a shape mismatch when training the SuGaR model. Do you know why this happened? Thank you very much.
@GoroYeh-HRI are You using hierarchical colmap mapper? I have the same issue going on rn. Did you fix it?
I have the same issue
Same issue here. Did you find any solution?
@GoroYeh-HRI are You using hierarchical colmap mapper? I have the same issue going on rn. Did you fix it?
Same issue. I also use the hierarchical colmap mapper. Can I please ask did you solve it ? Many thanks.
@psemalah In my case, the issue was that I was using the wrong set of images—the modified ones. Once I switched to the original set, everything started to work.
I was using the older README instruction.
I built my COLMAP model separately using point_triangulator with know camera poses.
These are my steps to train SuGaR:
SuGaR steps:
Assuming you have a reconstruction built from COLMAP: model/ containing following files:
- images.bin
- cameras.bin
- points3D.bin
Let's say you want to train the SuGaR model in ~/target_folder and you clone this repository in ~/SuGaR/.
-
Copy you images to
target_folder/input/ -
Copy the reconstruction to
target_folder/distorted/sparse/0/ -
Run
python gaussian_splatting/convert.py --skip_matchingpython gaussian_splatting/convert.py -s ../target_folder/ --skip_matching -
Use cloud_mapper
read_write_model.pyto converttarget_folder/distorted/sparse/0/frombintotxtformatcd ~/colmap/scripts/python python read_write_model.py --input_model ~/target_folder/distorted/sparse/0/ --output_model ~/target_folder/distorted/sparse/0/ --output_format .txt -
Modify
cameras.txt: use original triangulation inputcameras.txt. ChangeFULL_OPENCVtoPINHOLE. Delete distortion parameters -
Modify
target_folder/images/: copy and pastetarget_foler/input/images. -
Train the GS model:
python gaussian_splatting/train.py -s ../target_folder/ --iterations 7000 -m ../target_folder-GS -
Train the SuGaR model:
python train.py -s ../target_folder -c ../target_folder-GS/ -r "sdf"
@michelgokan @GoroYeh-HRI Thanks so much for your help. The problem is the caused by the resize of the image, operated by the undistotion function of colmap implemented in the convert.py.
I found a more simple way to make the size consistent after to the colmap distortion:
just simply run the following instead of the convert.py
colmap image_undistorter
--image_path $DATASET_PATH/images
--input_path $DATASET_PATH/sparse/0
--output_path $DATASET_PATH/dense
--output_type COLMAP
--min_scale 1
--max_scale 1
which make make your image add black blank on the edge but will not significantly affect your results.