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

Getting dimension mismatch error #31

Open
yatharthahuja opened this issue Jan 3, 2022 · 4 comments
Open

Getting dimension mismatch error #31

yatharthahuja opened this issue Jan 3, 2022 · 4 comments

Comments

@yatharthahuja
Copy link

In numpy_spatial_transform line 90, it says:

wa = np.expand_dims(wa, 2)

and I am getting the following error:

     axis = tuple([normalize_axis_index(ax, ndim, argname) for ax in axis])
     numpy.AxisError: axis 2 is out of bounds for array of dimension 2

I have tried changing the second argument in expand_dims to:

1 - it works but crashes with image error in generating synthetic dataset with following error:
Error with image: /home/yatharth/Desktop/CL/unsupervisedDeepHomographyRAL2018/test/test_synth

0 - doesnt work with following error:
File "/home/yatharth/Desktop/CL/unsupervisedDeepHomographyRAL2018/code/utils/numpy_spatial_transformer.py", line 96, in _interpolate
out = waIa + wbIb + wcIc + wdId
ValueError: operands could not be broadcast together with shapes (1,76800) (76800,3)

I am using a smaller number of images from COCO dataset itself for debugging so I am not sure if there is any expectation mismatch or correction in input images. Can somebody please clarify and help me with the issue here?
Thanks in advance!

@tynguyen
Copy link
Owner

tynguyen commented Jan 4, 2022

Based on what I see, there are some issues with the dimension of wa.
I don't remember exactly but it seems like wa is expected to be 2-dimentional (Batchsize x D). Could you check to see wa's dimension?

@yatharthahuja
Copy link
Author

yatharthahuja commented Jan 14, 2022

Hello! Sorry for the delay.
From the following snippet:(numpy_spatial_transform.py, line ~86)

if im.ndim == 3:
  #print(im.shape)
  num_channels = im.shape[2]
  print(wa.shape)
  wa = np.expand_dims(wa, 1)
  wb = np.expand_dims(wb, 1)#2)  
  wc = np.expand_dims(wc, 1)#2) 
  wd = np.expand_dims(wd, 1)#2) 
  print(wa.shape)
  print(Ia.shape)
out = wa*Ia + wb*Ib + wc*Ic + wd*Id
# print '--shape of out:', out.shape 

I am getting the following output:

(76800,)
(76800, 1)
(76800, 3)

What do you think? Really appreciate you response.

@Ask-sola
Copy link

Hello, I would like to ask, has this problem been solved, or is this project actually not working through?

@siyu-npc
Copy link

Hello! Sorry for the delay. From the following snippet:(numpy_spatial_transform.py, line ~86)

if im.ndim == 3:
  #print(im.shape)
  num_channels = im.shape[2]
  print(wa.shape)
  wa = np.expand_dims(wa, 1)
  wb = np.expand_dims(wb, 1)#2)  
  wc = np.expand_dims(wc, 1)#2) 
  wd = np.expand_dims(wd, 1)#2) 
  print(wa.shape)
  print(Ia.shape)
out = wa*Ia + wb*Ib + wc*Ic + wd*Id
# print '--shape of out:', out.shape 

I am getting the following output:

(76800,) (76800, 1) (76800, 3)

What do you think? Really appreciate you response.

It works for me

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

4 participants