sniklaus / softmax-splatting

an implementation of softmax splatting for differentiable forward warping using PyTorch
468 stars 58 forks source link

RuntimeError: shape '[1, 3, 1296, 2304]' is invalid for input of size 11943936 #61

Closed jojokic closed 1 year ago

jojokic commented 1 year ago

hi,this is my bug: Traceback (most recent call last): File "G:\aibuzhen\softmax-splatting-master\run.py", line 608, in tenOutput = estimate(tenOne, tenTwo, [0.5])[0] File "G:\aibuzhen\softmax-splatting-master\run.py", line 589, in estimate tenPreprocessedOne = tenOne.cuda().view(1, 3, intHeight, intWidth) RuntimeError: shape '[1, 3, 1296, 2304]' is invalid for input of size 11943936

and when i change: tenOutput = estimate(tenOne, tenTwo, [0.5])[0] to become tenOutput = estimate(tenOne[:3, :, :], tenTwo[:3, :, :], [0.5])[0] No more errors, but the picture turns blue,can you help me?

sniklaus commented 1 year ago

Given that your input size is 11943936 and the width is 1296 and the height is 2034, your input appears to have four channels. Your solution of only using the first three channels is the correct one to address this scenario, but I am not following what you mean that the picture turns blue. Could you share the inputs/output so that I better understand what you mean? From the top of my head, it might be that the color channel order is swapped in the output.

jojokic commented 1 year ago

假设您的输入大小为 11943936,宽度为 1296,高度为 2034,则输入似乎有四个通道。您仅使用前三个通道的解决方案是解决这种情况的正确解决方案,但我没有遵循您的意思,即图片变为蓝色。您能否分享输入/输出,以便我更好地理解您的意思?从我的头顶来看,可能是输出中交换了颜色通道顺序。

yes,i Mixed up the pictures ,i write a .py to del alph, like this :

img_path=r".\images\one.png " img = cv2.imread(img_path)

b_channel, g_channel, r_channel = cv2.split(img)

img_BGRA = cv2.merge((b_channel, g_channel, r_channel))

cv2.imwrite(img_path,img_BGRA)

and then i ues your code not error any more ,but i want to know how to change in your code , copy my this .py to your code? idon't konw how to share input/output , ( .

jojokic commented 1 year ago

it's ok,i konw how to do ,like this: tenOne = tenOne[:3, :, :] tenOne = tenOne[:, :, ::] tenTwo = tenTwo[:3, :, :] tenTwo = tenTwo[:, :, ::]

    tenOutput = estimate(tenOne, tenTwo, [0.5])[0]
sniklaus commented 1 year ago

Happy to hear that you got it to work. :tada:

Just for your information, this has no effect:tenOne = tenOne[:, :, ::]