1.下载源码。pytorch下SegNet源码链接
https://github.com/meetshah1995/pytorch-semseg
该源码重点针对FCN-8s模型进行了分析测试,我主要是尝试使用SegNet测试自己的数据。
下面首先使用VOC2012数据集小试牛刀!
2.修改配置文件并执行训练。
需要注意一点,每次重新执行训练之前,要清空数据集文件夹中的pre_encoded文件夹,在我电脑里,该文件夹的路径是
D:\SemanticSegmentation\pytorch-semseg\datasets\VOC\VOC2012\SegmentationClass\pre_encoded
配置文件很关键。修改配置文件的主要依据是作者在github上的README,我是将configs文件夹中的fcn8s_pascal.yml复制了一个,改名为segnet_pascal.yml之后,再修改参数。
有一个参数需要特别注意,是sbd_path,需要改成自己工程的路径
之后按照下述命令开始执行
python train.py --config configs/segnet_pascal.yml
3.遇到的错误及相关分析:
(1).错误1
TypeError: expected str, bytes or os.PathLike object, not NoneType
解决方案如下
“The code in NO.47 line, “sbd_path=None” was written in the “pascal_voc_loader.py” file, if you download the project from the github directly. You should code it like this, sbd_path="/…/…/…/benchmark_RELEASE/(the path your saved) ".”
即修改pascal_voc_loader.py文件47行中的参数sbd_path为与yml文件中保持一直即可。
参考链接为
https://github.com/meetshah1995/pytorch-semseg/issues/188
(2).错误2,是在训练过程中出现的错误。
Traceback (most recent call last):
File "train.py", line 229, in <module>
train(cfg, writer, lo