NUISTGY/UNet-Pytorch

单通道可以修改为三通道吗?

wlj567 opened this issue · 7 comments

您好,打扰一下,我想请教一个问题,您代码中图像训练分割过程是单通道图像net = UNet(n_channels=1, n_classes=1),我想改为三通道图像,请问怎么修改呀?如果知道的话希望能告知一下,谢谢了。

您好,打扰一下,我想请教一个问题,您代码中图像训练分割过程是单通道图像net = UNet(n_channels=1, n_classes=1),我想改为三通道图像,请问怎么修改呀?如果知道的话希望能告知一下,谢谢了。

net = UNet(n_channels=3, n_classes=1) 你好,参数n_channels改为3即可

我试过,直接修改的话会报错的,数据处理方式是按单通道处理的。 RuntimeError: Given groups=1, weight of size [64, 3, 3, 3], expected input[1, 512, 512, 3] to have 3 channels, but got 512 channels instead

根据你的报错,貌似你的输入为512通道。另外,还需修改utils文件夹内dataset文件的28~31行,将通道数进行修改

您好,谢谢您的回复,但是我对代码还是不太明白怎么改,我的输入图像是512×512大小,通道数想改为3,分类数为1。能帮忙再提一下建议吗?

------------------ 原始邮件 ------------------ 发件人: "NUISTGY/UNet-Pytorch" @.>; 发送时间: 2022年4月18日(星期一) 晚上11:46 @.>; @.@.>; 主题: Re: [NUISTGY/UNet-Pytorch] 单通道可以修改为三通道吗? (Issue #2) 我试过,直接修改的话会报错的,数据处理方式是按单通道处理的。 RuntimeError: Given groups=1, weight of size [64, 3, 3, 3], expected input[1, 512, 512, 3] to have 3 channels, but got 512 channels instead … 根据你的报错,貌似你的输入为512通道。另外,还需修改utils文件夹内dataset文件的28~31行,将通道数进行修改 — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>

28,29行的颜色空间转换改为RGB而不是GRAY,30,31行reshape第一个数字改成3

👌