源码链接:
GitHub - justchenhao/BIT_CD: Official Pytorch Implementation of "Remote Sensing Image Change Detection with Transformers"Official Pytorch Implementation of "Remote Sensing Image Change Detection with Transformers" - GitHub - justchenhao/BIT_CD: Official Pytorch Implementation of "Remote Sensing Image Change Detection with Transformers"
https://github.com/justchenhao/BIT_CD这个复现很简单,模型效果在公共数据集还不错,下面简单说下我测试的过程
1.数据说明
数据下载链接:
LEVIR-CD | LEVIR-CD is a new large-scale remote sensing binary change detection dataset, which would help develop novel deep learning-based algorithms for remote sensing image change detection.LEVIR-CD is a new large-scale remote sensing binary change detection dataset, which would help develop novel deep learning-based algorithms for remote sensing image change detection.
https://justchenhao.github.io/LEVIR/里面有百度网盘的链接,下载出问题可以去我上一篇变化检测的复现,里面有下载的较详细说明。
2.数据结构
![](https://i-blog.csdnimg.cn/blog_migrate/a14e046f64c34bbc07f6306905f50b07.png)
A里面放了第一期影像的训练、验证、测试数据,B里面放了 第二期影像的训练、验证、测试数据,label里面是标签,list 里面放了train.txt、val.txt、test.txt
![](https://i-blog.csdnimg.cn/blog_migrate/b2b97ab6357326a7bf797bc865aa7909.png)
![](https://i-blog.csdnimg.cn/blog_migrate/da6998144b6886b753d40b59aaac3098.png)
上面的结构意思就是所有数据放一起,通过写txt来控制训练、验证、预测图像
3.训练
![](https://i-blog.csdnimg.cn/blog_migrate/65fa1b0851bec186819a9027981b1bb1.png)
说明:
1.gpu_ids GPU id ,一个显卡就默认是0
2.project_name 项目名称,每次跑整个不一样的名字,整个名字后面预测的时候要对应起来
3.checkpoint_root 路径,放置模型,训练过程记录,最终的eval结构
![](https://i-blog.csdnimg.cn/blog_migrate/cbfd549a591a453ad1d9c8039d14f163.png)
4.num_workers , 加载数据的线程可以在utils.py中加载数据的地方看到
5.dataset, 数据集名字,这个目前只有一个,可以自己加新的
6.data_name 这个参数在项目里有点绕,这个默认得不要改就行,先看utils.py就发现,这个参数关系到训练数据的路径,接着看data_config.py文件发现,训练集的根目录要自己给出
![](https://i-blog.csdnimg.cn/blog_migrate/cea97f79dbb4429b2392db07d0848d79.png)
7.batch_size 默认
8.split, split_val 这两个默认就行
9.img_size 图像会被resize
10.类别默认
后面的参数就不说了,应该都认识
改完上面的参数就可以直接训练了
4.预测
预测用demo.py这个文件,文件的逻辑和训练的逻辑一致,参数基本都要和训练保持一致,那个output_folder可以换成存放结果的地方
![](https://i-blog.csdnimg.cn/blog_migrate/551599d7a208079065a1437162ceefe6.png)
用来验证效果的测试数据放在了quik_start控制的路径下,数据结构和训练数据结构是一样的。
![](https://i-blog.csdnimg.cn/blog_migrate/c3ac4b5652943288bddfa3afe2918b7e.png)
![](https://i-blog.csdnimg.cn/blog_migrate/98e2c296edd21e7f6ad166394bd13653.png)
注意这个训练完预测的demo是需要加标签的,因为源码默认的读图函数要求输入。
训练效果
![](https://i-blog.csdnimg.cn/blog_migrate/ca941eb4ca36d61344841a5c19e9e91e.png)