STANet icon indicating copy to clipboard operation
STANet copied to clipboard

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

Open weizhiliang0520 opened this issue 2 years ago • 14 comments

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

weizhiliang0520 avatar Nov 25 '21 14:11 weizhiliang0520

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

zhangtaohua avatar Dec 24 '21 02:12 zhangtaohua

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

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

weizhiliang0520 avatar Dec 24 '21 03:12 weizhiliang0520

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

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

weizhiliang0520 avatar Dec 24 '21 03:12 weizhiliang0520

好的, 非常感谢!!

zhangtaohua avatar Dec 24 '21 03:12 zhangtaohua

Hi @justchenhao Is this problem still unresolved?

p00uya avatar Mar 08 '22 05:03 p00uya

hello Is this problem still unresolved?

Amirjomaa avatar Mar 17 '22 17:03 Amirjomaa

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

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

seigechan avatar Apr 13 '22 08:04 seigechan

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/

LVBoA avatar Apr 20 '22 06:04 LVBoA

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])

OmarXu avatar Apr 21 '22 14:04 OmarXu

Is anyone able to fix this issue?

sunhoro avatar Aug 23 '22 00:08 sunhoro

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) # 特征距离

angle011 avatar Sep 07 '22 01:09 angle011

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

mohamedabdallah1996 avatar Sep 10 '22 12:09 mohamedabdallah1996

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 avatar Oct 11 '22 07:10 ZhaoRuu

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) # 特征距离 不好意思想再请教一下,还是没太懂怎么修改

ZhaoRuu avatar Oct 11 '22 07:10 ZhaoRuu