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

TypeError: Cannot handle this data type: (1, 1, 64), |u #85

Open
weizhiliang0520 opened this issue Nov 25, 2021 · 14 comments
Open

TypeError: Cannot handle this data type: (1, 1, 64), |u #85

weizhiliang0520 opened this issue Nov 25, 2021 · 14 comments

Comments

@weizhiliang0520
Copy link

我首先运行代码中的python demo.py ,然后报标题的错误。
自己的也分段查看涉及的代码模块,打印从模型输出的图像张量:print(pred) = [1,64,256,256,],请问最后代码中的result结果的图像是2562563。我不知道这个demo.py中最后保存的64chanel,如何变成3的?谢谢

@zhangtaohua
Copy link

我的结果和你的一样,请问你解决了嘛,怎么解决,谢谢!

@weizhiliang0520
Copy link
Author

我的结果和你的一样,请问你解决了嘛,怎么解决,谢谢

我之前遇到的是在colab上调试的,后面没有用google colab,直接用服务器跑代码就可以了。听说是因为python版本的问题,有说换成python3.8就好了,我在服务器上跑的是python3.6.12,你试试。

@weizhiliang0520
Copy link
Author

我的结果和你的一样,请问你解决了嘛,怎么解决,谢谢!

你看看这个博客:
https://blog.csdn.net/qq_41647438/article/details/108344141

@zhangtaohua
Copy link

好的, 非常感谢!!

@p00uya
Copy link

p00uya commented Mar 8, 2022

Hi @justchenhao
Is this problem still unresolved?

@Amirjomaa
Copy link

hello Is this problem still unresolved?

@seigechan
Copy link

我首先运行代码中的python demo.py ,然后报标题的错误。 自己的也分段查看涉及的代码模块,打印从模型输出的图像张量:print(pred) = [1,64,256,256,],请问最后代码中的result结果的图像是256_256_3。我不知道这个demo.py中最后保存的64chanel,如何变成3的?谢谢

你好,我跟你遇到了同样的问题,请问您解决了吗,我也想知道64通道如何变成3通道输出

@LVBoA
Copy link

LVBoA commented Apr 20, 2022

I changed the python version to 3.8.13 but it didn't make sense.
The key is the pytorch version. I have tried this:

pip install torch==1.8.1+cu102 torchvision==0.9.1+cu102 torchaudio==0.8.1 -f https://download.pytorch.org/whl/torch_stable.html

and it worked. cuda 10.1 could also be used with
pip install torch==1.8.1+cu101 torchvision==0.9.1+cu101 torchaudio==0.8.1 -f https://download.pytorch.org/whl/torch_stable.html

you can refer to this website
https://pytorch.org/get-started/previous-versions/

@OmarXu
Copy link

OmarXu commented Apr 21, 2022

self.dist = F.pairwise_distance(self.feat_A, self.feat_B, keepdim=True)
F.pairwise_distance:
在PyTorch1.7中返回值的shape是torch.Size([1,64,64,1])
在PyTorch1.8中返回值的shape是torch.Size([1,1,64,64])

@sunhoro
Copy link

sunhoro commented Aug 23, 2022

Is anyone able to fix this issue?

@angle011
Copy link

angle011 commented Sep 7, 2022

Just Dimension problem. As above comments mentioned, we just need to permute dims.
torch 1.10.0 ---> x1,x2 shape[B,H,W,C] --->result shape [B,H,W,1]
self.feat_A = self.feat_A.permute(0, 2, 3, 1)
self.feat_B = self.feat_B.permute(0, 2, 3, 1)
self.dist = F.pairwise_distance(self.feat_A, self.feat_B, keepdim=True) # 特征距离
self.dist = self.dist.permute(0, 2, 3, 1)
torch 1.8.0 ---> x1,x2 shape[B,C,H,W] --->result shape [B,1,H,W]
self.dist = F.pairwise_distance(self.feat_A, self.feat_B, keepdim=True) # 特征距离

@mohamedabdallah1996
Copy link

Just Dimension problem. As above comments mentioned, we just need to permute dims. torch 1.10.0 ---> x1,x2 shape[B,H,W,C] --->result shape [B,H,W,1] self.feat_A = self.feat_A.permute(0, 2, 3, 1) self.feat_B = self.feat_B.permute(0, 2, 3, 1) self.dist = F.pairwise_distance(self.feat_A, self.feat_B, keepdim=True) # 特征距离 self.dist = self.dist.permute(0, 2, 3, 1) torch 1.8.0 ---> x1,x2 shape[B,C,H,W] --->result shape [B,1,H,W] self.dist = F.pairwise_distance(self.feat_A, self.feat_B, keepdim=True) # 特征距离

Thank you, installing torch 1.8 worked with me

@ZhaoRuu
Copy link

ZhaoRuu commented Oct 11, 2022

I want to know who have an idea to solve this problem.I have the same problem but i don't know how to deal it.

@ZhaoRuu
Copy link

ZhaoRuu commented Oct 11, 2022

Just Dimension problem. As above comments mentioned, we just need to permute dims. torch 1.10.0 ---> x1,x2 shape[B,H,W,C] --->result shape [B,H,W,1] self.feat_A = self.feat_A.permute(0, 2, 3, 1) self.feat_B = self.feat_B.permute(0, 2, 3, 1) self.dist = F.pairwise_distance(self.feat_A, self.feat_B, keepdim=True) # 特征距离 self.dist = self.dist.permute(0, 2, 3, 1) torch 1.8.0 ---> x1,x2 shape[B,C,H,W] --->result shape [B,1,H,W] self.dist = F.pairwise_distance(self.feat_A, self.feat_B, keepdim=True) # 特征距离
不好意思想再请教一下,还是没太懂怎么修改

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