Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RuntimeError: stack expects each tensor to be equal size & AttributeError: 'NoneType' object has no attribute 'shape' #28

Open
bartman081523 opened this issue Mar 15, 2022 · 1 comment

Comments

@bartman081523
Copy link

#local run
colmap feature_extractor \
--database_path ./database.db --image_path ./dense/images/

colmap exhaustive_matcher \
--database_path ./database.db

colmap mapper \
--database_path ./database.db \
--image_path ./dense/images \
--output_path ./dense/sparse

colmap image_undistorter \
--image_path ./dense/images \
--input_path ./dense/sparse/0 \
--output_path ./dense \
--output_type COLMAP \
--max_image_size 2000

#colab run

%cd /content/drive/MyDrive/neural-net
!git clone https://github.com/zl548/Neural-Scene-Flow-Fields
%cd Neural-Scene-Flow-Fields
!pip install configargparse
!pip install matplotlib
!pip install opencv
!pip install scikit-image
!pip install scipy
!pip install cupy
!pip install imageio.
!pip install tqdm
!pip install kornia

my Images are 288x512 pixels

%cd /content/drive/MyDrive/neural-net/Neural-Scene-Flow-Fields/nsff_scripts/
    # create camera intrinsics/extrinsic format for NSFF, same as original NeRF where it uses imgs2poses.py script from the LLFF code: https://github.com/Fyusion/LLFF/blob/master/imgs2poses.py
!python save_poses_nerf.py --data_path "/content/drive/MyDrive/neural-net/Neural-Scene-Flow-Fields/nerf_data/bolli/dense"
    # Resize input images and run single view model, 
    # argument resize_height: resized image height for model training, width will be resized based on original aspect ratio
!python run_midas.py --data_path "/content/drive/MyDrive/neural-net/Neural-Scene-Flow-Fields/nerf_data/bolli/dense"  --resize_height 512
!bash ./download_models.sh
    # Run optical flow model
!python run_flows_video.py --model models/raft-things.pth --data_path /content/drive/MyDrive/neural-net/Neural-Scene-Flow-Fields/nerf_data/bolli/dense

Error:

Traceback (most recent call last):
  File "run_flows_video.py", line 448, in <module>
    run_optical_flows(args)
  File "run_flows_video.py", line 350, in run_optical_flows
    images = load_image_list(images)
  File "run_flows_video.py", line 257, in load_image_list
    images = torch.stack(images, dim=0)
RuntimeError: stack expects each tensor to be equal size, but got [3, 512, 288] at entry 0 and [3, 512, 287] at entry 31

So input_w = is not consistent, eventhough my images are all dimensions 288x512

Even if I modify the script:

def load_image(imfile):
    long_dim = 512

    img = np.array(Image.open(imfile)).astype(np.uint8)

    # Portrait Orientation
    if img.shape[0] > img.shape[1]:
        input_h = long_dim
        input_w = 288

The dimensions error is gone, but another error:

...
flow input w 288 h 512
0
/usr/local/lib/python3.7/dist-packages/torch/functional.py:445: UserWarning: torch.meshgrid: in an upcoming release, it will be required to pass the indexing argument. (Triggered internally at  ../aten/src/ATen/native/TensorShape.cpp:2157.)
  return _VF.meshgrid(tensors, **kwargs)  # type: ignore[attr-defined]
Traceback (most recent call last):
  File "run_flows_video.py", line 448, in <module>
    run_optical_flows(args)
  File "run_flows_video.py", line 363, in run_optical_flows
    (img_train.shape[1], img_train.shape[0]), 
AttributeError: 'NoneType' object has no attribute 'shape'
@zhengqili
Copy link
Owner

This should means somehow you didn't load img_train properly. the code always load the first image in the folder which is called "00000.png", but your image file name might be different

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants