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

请问device-side assert triggered怎么解决 #29

Closed
youngprogrammerBee opened this issue Apr 12, 2023 · 8 comments
Closed

请问device-side assert triggered怎么解决 #29

youngprogrammerBee opened this issue Apr 12, 2023 · 8 comments

Comments

@youngprogrammerBee
Copy link

你好 抱歉打扰,在训练的时候发生了如下报错
image
网上搜索大多都说是分类任务报的错,没有什么帮助,请问您有遇到过吗 ,该如何解决呢

@LiheYoung
Copy link
Owner

LiheYoung commented Apr 12, 2023

一般来说是因为人工标注的mask中存在比网络输出的类别数 (configs中的nclass)更大的类别(准确来说是大于或等于)。比如如果你的nclass设置的是21,但是mask中存在25这样的类别index,那就会报这样的错,需要检查一下mask。

@youngprogrammerBee
Copy link
Author

感谢您的回复,我的mask做灰度图读入后应该只有背景和血管两个类,好奇怪

@LiheYoung
Copy link
Owner

可以print(torch.unique(mask))确认一下是否只有0和1。

@youngprogrammerBee
Copy link
Author

youngprogrammerBee commented Apr 12, 2023

非常感谢您的回复
改了半天发现是我mask在transform.resize后改了像素值,原来取值只有0,255(黑色和白色)的像素变了,改完后现在输出的print(`torch.unique(torch.from_numpy(mask).long()))结果是tensor([ 0, 255])(不是0,1会影响吗) ,然后我修改了nclass为2然后还是报错
image

@LiheYoung
Copy link
Owner

需要将255的像素改成1才行

@youngprogrammerBee
Copy link
Author

您好 感谢您的回复,将255的像素改为1之后确实成功开始了训练。 我在用得到的模型进行test时候,发现得到的output是两通道的(torch.size[1,2,480,480]),请问这样是否正常?

@LiheYoung
Copy link
Owner

对的

@youngprogrammerBee
Copy link
Author

youngprogrammerBee commented Apr 26, 2023

您好,我在对预测的图像尝试转换为正常模型时,
image
发现argmax后的tensor全部为1,
image
发现是因为两个通道总是有一个通道的像素比另外一个的大,后来放弃使用argmax而是直接将两个通道的值相加后*255,发现出来的结果基本能还原轮廓但是很奇怪,请问您有试过将预测的结果转换成图像吗?有遇到类似问题吗

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

2 participants