lee-zq / 3DUNet-Pytorch

3DUNet implemented with pytorch
484 stars 108 forks source link

我已解决test_dice极低的问题 | I have resolved the problem that the test_dice is extremely low #39

Open LambdaLi opened 9 months ago

LambdaLi commented 9 months ago

4219d3454a33e3d8670b9c5962935a49

d7ed6caf4221afffec5cf90fbb07ef42_720

这个代码我跑了四次,最后发现是自己对题主的意思理解错误导致,然后我花了几天时间逐行阅读代码,希望我的遭遇能够帮助到各位:`

①不要预处理‘测试集(test)’!!!不要预处理‘测试集(test)’!!!不要预处理‘测试集(test)’!!!重要的事情说三遍,只需要预处理训练集(train),dataset_lits_test.py会对测试(test)集图像进行处理。

②前面前辈说到的ResUNet.py里135-161行的map里的upsample里的scale参数后两位减半。

③把test.py第25行的注释给取消注释,该行的作用看注释的注释,做完后便!!!不!!!需要像前辈之前说的运行test.py时把②里说到的减半参数->进行恢复。

I ran this code four times and finally realized that it was due to my incorrect understanding of the author's meaning. I spent a few days reading the code line by line, hoping that my experience can help everyone: ① Do not preprocess the 'test set'!!! Do not preprocess the 'test set'!!! Do not preprocess the 'test set'!!! Say important things three times, just preprocess the training set, dataset Lits Test. py will process the test set images. ② The last two digits of the scale parameter in the upsample in the map from lines 135 to 161 of ResUNet. py mentioned by the previous generation are halved. ③ Uncomment the 25th line of test.py. The purpose of this line depends on the annotation. Once it is done, it will be ready.We don't need to restore the parameters halved mentioned in ② when running test. py.

zz10001 commented 9 months ago

厉害了👍

zhouyizhuo commented 9 months ago

@LambdaLi @zz10001 您好,我想问一下slice_down_scale的含义具体是什么。我现在想将此网络应用于新的数据集,如果我更改min_slicesslice_down_scale的值,我需要更改模型的其他参数吗? image

LambdaLi commented 9 months ago

@LambdaLi @zz10001 您好,我想问一下slice_down_scale的含义具体是什么。我现在想将此网络应用于新的数据集,如果我更改min_slicesslice_down_scale的值,我需要更改模型的其他参数吗? image

slice_down_scale这个是处理CT的Z轴切片,它和上面xy_down_scale作用应该是一样,我个人理解的是可以在x, y轴上缩放(下采样)来降低图片尺寸,Z轴由于是3D分割所以维持原状,毕竟要找到肝脏的首部和尾部,改变之后影不影响分割性能我也不太清楚,min_slices我看了相关文章"To maximize the use of GPU video memory, 48 consecutive slices were randomly selected from these as network model inputs with a size of 48×256×256.",这个是每次送进去多少切片,具体怎么改自己斟酌一下吧,有误的地方还请谅解。

zhouyizhuo commented 9 months ago

好的,非常感谢您的回复。还想再问一下,在训练的时候没有问题,但是在val处理某个文件时,报了以下错误,请问可能会是什么原因? image image

其余的没有问题 image

LambdaLi commented 9 months ago

好的,非常感谢您的回复。还想再问一下,在训练的时候没有问题,但是在val处理某个文件时,报了以下错误,请问可能会是什么原因? image image

其余的没有问题 image

突然出问题确实很奇怪,分辨率也太不正常检查一下 下采和上采吧

zz10001 commented 9 months ago

好的,非常感谢您的回复。还想再问一下,在训练的时候没有问题,但是在val处理某个文件时,报了以下错误,请问可能会是什么原因?

不好意思这份代码太久没看了有点忘记了,只是之前参考了另一份类似的代码处理规则;顺便推荐下可以参考我空间2d的处理,希望对你有帮助

zhouyizhuo commented 9 months ago

@LambdaLi 您好,感谢您的帮助,我已经解决了无法开始训练的问题。目前我遇到了训练中突然loss变得很高的问题,请问这是正常的吗?顺便我想问一下, 我的训练集有250个左右,我应该设置多少个epoch才比较合适? image

LambdaLi commented 9 months ago

@zhouyizhuo 很不正常,我跑了几次这个模型loss是持续降低的,而且你看你两个dice低的离谱,由于这个只是我练手用的,所以我没有关闭他的早停功能,3080ti跑了60左右的epoch就停了,A4000跑了100多个epoch吧,但是我觉得问题不是出在epoch上,还是检查代码,是不是模型预测的结果和真实标签的不对应。

RY-97 commented 5 months ago

好的,非常感谢您的回复。还想再问一下,在训练的时候没有问题,但是在val处理某个文件时,报了以下错误,请问可能会是什么原因? image image

其余的没有问题 image

请问你可以给我你的代码一份?

RY-97 commented 5 months ago

@zhouyizhuo 很不正常,我跑了几次这个模型loss是持续降低的,而且你看你两个dice低的离谱,由于这个只是我练手用的,所以我没有关闭他的早停功能,3080ti跑了60左右的epoch就停了,A4000跑了100多个epoch吧,但是我觉得问题不是出在epoch上,还是检查代码,是不是模型预测的结果和真实标签的不对应。

可以共享一份代码吗?