当前位置:网站首页>Train your dataset with swinunet
Train your dataset with swinunet
2022-07-07 08:23:00 【I am a little rice】
Refer to the post : https://blog.csdn.net/qq_37652891/article/details/123932772
Data set preparation
Multi category semantic segmentation of remote sensing images , The total is divided into 7 class ( Including background )
image:
label_rgb
label( It's not all black here , The value of the category is 0,1,2,3,4,5,6), Later training uses such data 
Data address
Baidu cloud :https://pan.baidu.com/s/1zZHnZfBgVWxs6TJW4yjeeQ
Extraction code :2022
SwinUNet Code address
Dataset processing
Data sets image and label, This data set should provide rgb Format labels and include 0,1,2,3,4,5,6 Label of the value ,SwinUNet The use is to include 0,1,2,3,4,5,6 Label image for ;
1. Data sets
Data sets are stored in SwinUNet The root directory ,image Middle is the original image ,label Middle is the label image ( common 7 class , Its tag value is 0,1,2,3,4,5,6,7);
If you use other data sets , Pay attention to the value of the label . For example, if it is a second category . The label 0 or 255, It needs to be replaced with 0 or 1
—SwinUNet
---------configs
---------img_datas
---------------train
--------------------image
--------------------label
---------------test
--------------------image
--------------------label
2. stay SwinUnet Created in the root directory npz.py file , function npz.py file
import glob
import cv2
import numpy as np
import os
def npz(im, la, s):
images_path = im
labels_path = la
path2 = s
images = os.listdir(images_path)
for s in images:
image_path = os.path.join(images_path, s)
label_path = os.path.join(labels_path, s)
image = cv2.imread(image_path)
image = cv2.cvtColor(image,cv2.COLOR_BGR2RGB)
# Labels are converted from three channels to single channels
label = cv2.imread(label_path, flags=0)
# preservation npz file
np.savez(path2+s[:-4]+".npz",image=image,label=label)
npz('./img_datas/train/image/', './img_datas/train/label/', './data/Synapse/train_npz')
npz('./img_datas/test/image/', './img_datas/test/label/', './data/Synapse/test_vol_h5')
3. stay SwinUnet Created in the root directory txt.py file , function txt.py file
The goal is to generate ./list/list_Synapse/train.txt and ./list/list_Synapse/test_vol.txt file
import os
def write_name(np, tx):
#npz File path
files = os.listdir(np)
#txt File path
f = open(tx, 'w')
for i in files:
#name = i.split('\\')[-1]
name = i[:-4]+'\n'
f.write(name)
write_name('./data/Synapse/train_npz', './lists/lists_Synapse/train.txt')
write_name('./data/Synapse/test_vol_h5', './lists/lists_Synapse/test_vol.txt')
4. Download Pre Workout weights , Put it in SwinUnet In the catalog pretrained_ckpt Under the folder
link :https://pan.baidu.com/s/1-hYwJRlr95Fv08e9AEARww
Extraction code :2022

Modify the network
1. modify train.py file

Here's the important thing Number of categories , Others depend on the situation 
2. modify ./datasets/dataset_synapse.py file

3. modify trainer.py file
I don't know why 
4. Run code
This information can be passed in as a super parameter , If not , Then you can use default= To write the default value 
If you set the default value , So run python train.py That's all right. 
边栏推荐
- Explore creativity in steam art design
- Uniapp mobile terminal forced update function
- Unityhub cracking & unity cracking
- Using helm to install rainbow in various kubernetes
- 探索STEAM艺术设计中的创造力
- Leetcode 187 Repeated DNA sequence (2022.07.06)
- 接口作为参数(接口回调)
- Tuowei information uses the cloud native landing practice of rainbow
- Quick analysis of Intranet penetration helps the foreign trade management industry cope with a variety of challenges
- [quick start of Digital IC Verification] 10. Verilog RTL design must know FIFO
猜你喜欢

Practice of combining rook CEPH and rainbow, a cloud native storage solution

Rainbond 5.6 版本发布,增加多种安装方式,优化拓扑图操作体验

藏书馆App基于Rainbond实现云原生DevOps的实践

云原生存储解决方案Rook-Ceph与Rainbond结合的实践

Hisense TV starts the developer mode

Xcit learning notes

Réplication de vulnérabilité - désrialisation fastjson

使用 Nocalhost 开发 Rainbond 上的微服务应用

One click installation of highly available Nacos clusters in rainbow

Splunk子查询模糊匹配csv中字段值为*
随机推荐
Full text query classification
【无标题】
CCTV is so warm-hearted that it teaches you to write HR's favorite resume hand in hand
解析创新教育体系中的创客教育
藏书馆App基于Rainbond实现云原生DevOps的实践
柯基数据通过Rainbond完成云原生改造,实现离线持续交付客户
rsync远程同步
Quick analysis of Intranet penetration helps the foreign trade management industry cope with a variety of challenges
通俗易懂单点登录SSO
Vulnerability recurrence easy_ tornado
Function extension, attribute extension and non empty type extension in kotlin
Don't stop chasing the wind and the moon. Spring mountain is at the end of Pingwu
GFS distributed file system
ZCMU--1396: 队列问题(2)
Real time monitoring of dog walking and rope pulling AI recognition helps smart city
机器人教育在动手实践中的真理
Rainbond 5.7.1 支持对接多家公有云和集群异常报警
[step on the pit series] H5 cross domain problem of uniapp
Detailed explanation of apply, also, let, run functions and principle analysis of internal source code in kotlin
Leetcode medium question my schedule I