sssegmentation
sssegmentation copied to clipboard
关于支持的数据集
您好,感谢您开源的代码核突出贡献,我希望可以在自己的数据集上训练语义分割模型,为了保证一致性,请问您对数据集做了哪些预处理?我希望将我的数据集处理到和您在百度网盘中提供的数据集相同的程度。
没有什么特别的处理,只是把train images, val images, test images的id存在了txt里方便读取
感谢您的回答!!在您的工具箱的帮助下,我已经成功复现了论文中的结果。但是现在我想在自己的数据集(文件夹格式与voc相同)上训练MCIBI++,我仿照sssegmentation/ssseg/modules/datasets/voc.py在同路径下编写了数据集接口,并且编写了相应的config文件,但是训练效果极差,请问我是不是漏掉了其他需要修改的文件? 此外在debug过程中我导出了数据集接口生成的图片路径,是正确的路径。
可视化出来看下?
这是我的数据集接口,可以运行起来,但是miou仅有十几 `import os import pandas as pd from .base import BaseDataset
'''gaofenDataset''' class gaofenDataset(BaseDataset): num_classes = 9 classnames = [ 'impervious surfaces','tree','grass','road','building','transportation','bare land', 'water','others' ] assert num_classes == len(classnames) def init(self, mode, logger_handle, dataset_cfg): super(gaofenDataset, self).init(mode, logger_handle, dataset_cfg) # obtain the dirs rootdir = dataset_cfg['rootdir'] self.image_dir = os.path.join(rootdir, 'Images') self.segclass_dir = os.path.join(rootdir, 'Segmentation') self.set_dir = os.path.join(rootdir, 'ImageSets', 'Segmentation') # obatin imageids df = pd.read_csv(os.path.join(self.set_dir, dataset_cfg['set']+'.txt'), names=['imageids']) self.imageids = df['imageids'].values self.imageids = [str(_id) for _id in self.imageids] '''pull item''' def getitem(self, index): imageid = self.imageids[index] imagepath = os.path.join(self.image_dir, imageid+'.png') annpath = os.path.join(self.segclass_dir, imageid+'.png')
sample = self.read(imagepath, annpath, self.dataset_cfg.get('with_ann', True))
sample.update({'id': imageid})
if self.mode == 'TRAIN':
sample = self.synctransform(sample, 'without_totensor_normalize_pad')
sample['edge'] = self.generateedge(sample['segmentation'].copy())
sample = self.synctransform(sample, 'only_totensor_normalize_pad')
else:
sample = self.synctransform(sample, 'all')
return sample
'''length'''
def __len__(self):
return len(self.imageids)`
这是我的config文件 `import os from .base_cfg import *
modify dataset config
DATASET_CFG = DATASET_CFG.copy() DATASET_CFG.update({ 'type': 'gaofen', 'rootdir': os.path.join(os.getcwd(), 'gaofen'), }) DATASET_CFG['train']['set'] = 'train'
modify dataloader config
DATALOADER_CFG = DATALOADER_CFG.copy()
modify optimizer config
OPTIMIZER_CFG = OPTIMIZER_CFG.copy()
modify scheduler config
SCHEDULER_CFG = SCHEDULER_CFG.copy() SCHEDULER_CFG.update({ 'max_epochs': 60 })
modify losses config
LOSSES_CFG = LOSSES_CFG.copy()
modify segmentor config
SEGMENTOR_CFG = SEGMENTOR_CFG.copy() SEGMENTOR_CFG.update({ 'num_classes': 9, }) SEGMENTOR_CFG['head']['fpn'] = { 'in_channels_list': [256, 512, 1024, 2048], 'feats_channels': 1024, 'out_channels': 512, } SEGMENTOR_CFG['head']['decoder'] = { 'pr': {'in_channels': 512, 'out_channels': 512, 'dropout': 0.1}, 'cwi': {'in_channels': 512, 'out_channels': 512, 'dropout': 0.1}, 'cls': {'in_channels': 2560, 'out_channels': 512, 'dropout': 0.1, 'kernel_size': 3, 'padding': 1}, } SEGMENTOR_CFG['head']['context_within_image']['type'] = 'ppm' SEGMENTOR_CFG['head']['context_within_image']['is_on'] = True SEGMENTOR_CFG['head']['context_within_image']['use_self_attention'] = False
modify inference config
--single-scale
INFERENCE_CFG = INFERENCE_CFG.copy()
--multi-scale
''' INFERENCE_CFG = { 'mode': 'whole', 'opts': {}, 'tricks': { 'multiscale': [0.5, 0.75, 1.0, 1.25, 1.5, 1.75], 'flip': True, 'use_probs_before_resize': True } } '''
modify common config
COMMON_CFG = COMMON_CFG.copy() COMMON_CFG['work_dir'] = 'memorynetv2_upernet_resnet101os8_gaofen' COMMON_CFG['logfilepath'] = 'memorynetv2_upernet_resnet101os8_gaofen/memorynetv2_upernet_resnet101os8_gaofen.log' COMMON_CFG['resultsavepath'] = 'memorynetv2_upernet_resnet101os8_gaofen/memorynetv2_upernet_resnet101os8_gaofen_results.pkl'`
请问您说的可视化是指把哪些内容提供给您?