tynguyen / unsupervisedDeepHomographyRAL2018

Unsupervised Deep Homography: A Fast and Robust Homography Estimation Model
https://arxiv.org/abs/1709.03966
277 stars 81 forks source link

Getting dimension mismatch error #31

Open yatharthahuja opened 2 years ago

yatharthahuja commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

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 commented 1 year ago

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

siyu-npc commented 9 months ago

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