{
  "id": 356022,
  "title": "Has anyone been able to get a good score using MMsegmentation ?",
  "url": "/competitions/hubmap-organ-segmentation/discussion/356022",
  "author_name": "",
  "post_date": "2022-09-29T03:43:40.126333100Z",
  "votes": 2,
  "comment_count": 1,
  "views": 0,
  "content": "<p>Thanks for the competition. I had a lot to learn.</p>\n<p>Has anyone been able to get a good score using mmseg?<br>\nI trained  Swin using mmseg with Stain Normalization and other aug.<br>\nCV was 0.75+ but LB is not even close to 0.5.<br>\nI think I am using this tool in the wrong way.<br>\nIf anyone has done well using mmseg, I would be glad to see your configuration files and inference notes.</p>\n<p><a href=\"https://www.kaggle.com/code/tomp1121/mmsegmentation-inference/notebook\" target=\"_blank\">inference note</a></p>\n<p>config file:</p>\n<pre><code>c_size = 768\nst_size = 256\nPROJECT_NAME = 'Swin_768_stain'\ntrain_size = (2000, 2000)\ntest_size = (2000, 2000)\ncrop_size = (768, 768)\nstride_size = (256, 256)\nwork_dir = 'hubmap/checkpoints/Swin_768_stain'\nnorm_cfg = dict(type='SyncBN', requires_grad=True)\nbackbone_norm_cfg = dict(type='LN', requires_grad=True)\nmodel = dict(\n    type='EncoderDecoder',\n    pretrained=None,\n    backbone=dict(\n        type='SwinTransformer',\n        pretrain_img_size=224,\n        embed_dims=128,\n        patch_size=4,\n        window_size=7,\n        mlp_ratio=4,\n        depths=[2, 2, 18, 2],\n        num_heads=[4, 8, 16, 32],\n        strides=(4, 2, 2, 2),\n        out_indices=(0, 1, 2, 3),\n        qkv_bias=True,\n        qk_scale=None,\n        patch_norm=True,\n        drop_rate=0.0,\n        attn_drop_rate=0.0,\n        drop_path_rate=0.3,\n        use_abs_pos_embed=False,\n        act_cfg=dict(type='GELU'),\n        norm_cfg=dict(type='LN', requires_grad=True),\n        init_cfg=dict(\n            type='Pretrained',\n            checkpoint=\n            'https://download.openmmlab.com/mmsegmentation/v0.5/pretrain/swin/swin_base_patch4_window7_224_20220317-e9b98025.pth'\n        )),\n    decode_head=dict(\n        type='UPerHead',\n        in_channels=[128, 256, 512, 1024],\n        in_index=[0, 1, 2, 3],\n        pool_scales=(1, 2, 3, 6),\n        channels=512,\n        dropout_ratio=0.1,\n        num_classes=6,\n        norm_cfg=dict(type='SyncBN', requires_grad=True),\n        align_corners=False,\n        loss_decode=dict(\n            type='CrossEntropyLoss', use_sigmoid=False, loss_weight=1.0)),\n    auxiliary_head=dict(\n        type='FCNHead',\n        in_channels=512,\n        in_index=2,\n        channels=256,\n        num_convs=1,\n        concat_input=False,\n        dropout_ratio=0.1,\n        num_classes=150,\n        norm_cfg=dict(type='SyncBN', requires_grad=True),\n        align_corners=False,\n        loss_decode=dict(\n            type='CrossEntropyLoss', use_sigmoid=False, loss_weight=0.4)),\n    train_cfg=dict(),\n    test_cfg=dict(mode='slide', crop_size=(768, 768), stride=(256, 256)))\ndataset_type = 'CustomDataset'\ndata_root = 'mmseg_data/'\nclasses = [\n    'background', 'kidney', 'prostate', 'largeintestine', 'spleen', 'lung'\n]\npalette = [[0, 0, 0], [255, 0, 0], [0, 255, 0], [0, 0, 255], [255, 255, 0],\n           [255, 0, 255]]\nimg_norm_cfg = dict(\n    mean=[216.75, 180.32, 196.0], std=[49.38, 83.52, 68.55], to_rgb=True)\ntrain_pipeline = [\n    dict(type='LoadImageFromFile'),\n    dict(type='LoadAnnotations'),\n    dict(type='Resize', img_scale=(2000, 2000), ratio_range=(0.5, 2.0)),\n    dict(type='RandomCrop', crop_size=(768, 768), cat_max_ratio=0.9),\n    dict(type='RandomFlip', prob=0.5, direction='horizontal'),\n    dict(type='RandomFlip', prob=0.5, direction='vertical'),\n    dict(type='RandomRotate', prob=0.5, degree=90),\n    dict(type='PhotoMetricDistortion'),\n    dict(\n        type='Normalize',\n        mean=[216.75, 180.32, 196.0],\n        std=[49.38, 83.52, 68.55],\n        to_rgb=True),\n    dict(type='Pad', size=(768, 768), pad_val=0, seg_pad_val=255),\n    dict(type='DefaultFormatBundle'),\n    dict(type='Collect', keys=['img', 'gt_semantic_seg'])\n]\nval_pipeline = [\n    dict(type='LoadImageFromFile'),\n    dict(\n        type='MultiScaleFlipAug',\n        img_scale=(2000, 2000),\n        flip=False,\n        transforms=[\n            dict(type='Resize', keep_ratio=True),\n            dict(type='RandomFlip'),\n            dict(\n                type='Normalize',\n                mean=[216.75, 180.32, 196.0],\n                std=[49.38, 83.52, 68.55],\n                to_rgb=True),\n            dict(type='ImageToTensor', keys=['img']),\n            dict(type='Collect', keys=['img'])\n        ])\n]\ntest_pipeline = [\n    dict(type='LoadImageFromFile'),\n    dict(\n        type='MultiScaleFlipAug',\n        img_scale=(2000, 2000),\n        flip=False,\n        transforms=[\n            dict(type='Resize', keep_ratio=True),\n            dict(type='RandomFlip'),\n            dict(\n                type='Normalize',\n                mean=[216.75, 180.32, 196.0],\n                std=[49.38, 83.52, 68.55],\n                to_rgb=True),\n            dict(type='ImageToTensor', keys=['img']),\n            dict(type='Collect', keys=['img'])\n        ])\n]\ndata = dict(\n    samples_per_gpu=4,\n    workers_per_gpu=2,\n    train=dict(\n        type='CustomDataset',\n        data_root='mmseg_data/',\n        img_dir='train_images_w_stain',\n        ann_dir='original_masks',\n        img_suffix='.png',\n        seg_map_suffix='.png',\n        split='splits/fold_0.txt',\n        classes=[\n            'background', 'kidney', 'prostate', 'largeintestine', 'spleen',\n            'lung'\n        ],\n        palette=[[0, 0, 0], [255, 0, 0], [0, 255, 0], [0, 0, 255],\n                 [255, 255, 0], [255, 0, 255]],\n        pipeline=[\n            dict(type='LoadImageFromFile'),\n            dict(type='LoadAnnotations'),\n            dict(\n                type='Resize', img_scale=(2000, 2000), ratio_range=(0.5, 2.0)),\n            dict(type='RandomCrop', crop_size=(768, 768), cat_max_ratio=0.9),\n            dict(type='RandomFlip', prob=0.5, direction='horizontal'),\n            dict(type='RandomFlip', prob=0.5, direction='vertical'),\n            dict(type='RandomRotate', prob=0.5, degree=90),\n            dict(type='PhotoMetricDistortion'),\n            dict(\n                type='Normalize',\n                mean=[216.75, 180.32, 196.0],\n                std=[49.38, 83.52, 68.55],\n                to_rgb=True),\n            dict(type='Pad', size=(768, 768), pad_val=0, seg_pad_val=255),\n            dict(type='DefaultFormatBundle'),\n            dict(type='Collect', keys=['img', 'gt_semantic_seg'])\n        ]),\n    val=dict(\n        type='CustomDataset',\n        data_root='mmseg_data/',\n        img_dir='train_images_w_stain',\n        ann_dir='original_masks',\n        img_suffix='.png',\n        seg_map_suffix='.png',\n        split='splits/valid_0.txt',\n        classes=[\n            'background', 'kidney', 'prostate', 'largeintestine', 'spleen',\n            'lung'\n        ],\n        palette=[[0, 0, 0], [255, 0, 0], [0, 255, 0], [0, 0, 255],\n                 [255, 255, 0], [255, 0, 255]],\n        pipeline=[\n            dict(type='LoadImageFromFile'),\n            dict(\n                type='MultiScaleFlipAug',\n                img_scale=(2000, 2000),\n                flip=False,\n                transforms=[\n                    dict(type='Resize', keep_ratio=True),\n                    dict(type='RandomFlip'),\n                    dict(\n                        type='Normalize',\n                        mean=[216.75, 180.32, 196.0],\n                        std=[49.38, 83.52, 68.55],\n                        to_rgb=True),\n                    dict(type='ImageToTensor', keys=['img']),\n                    dict(type='Collect', keys=['img'])\n                ])\n        ]),\n    test=dict(\n        type='CustomDataset',\n        data_root='mmseg_data/',\n        test_mode=True,\n        img_dir='train_images_w_stain',\n        ann_dir='original_masks',\n        img_suffix='.png',\n        seg_map_suffix='.png',\n        classes=[\n            'background', 'kidney', 'prostate', 'largeintestine', 'spleen',\n            'lung'\n        ],\n        palette=[[0, 0, 0], [255, 0, 0], [0, 255, 0], [0, 0, 255],\n                 [255, 255, 0], [255, 0, 255]],\n        pipeline=[\n            dict(type='LoadImageFromFile'),\n            dict(\n                type='MultiScaleFlipAug',\n                img_scale=(2000, 2000),\n                flip=False,\n                transforms=[\n                    dict(type='Resize', keep_ratio=True),\n                    dict(type='RandomFlip'),\n                    dict(\n                        type='Normalize',\n                        mean=[216.75, 180.32, 196.0],\n                        std=[49.38, 83.52, 68.55],\n                        to_rgb=True),\n                    dict(type='ImageToTensor', keys=['img']),\n                    dict(type='Collect', keys=['img'])\n                ])\n        ]))\nlog_config = dict(\n    interval=100,\n    hooks=[\n        dict(type='TextLoggerHook', by_epoch=False),\n        dict(\n            type='MMSegWandbHook',\n            with_step=False,\n            by_epoch=False,\n            init_kwargs=dict(project='hubmap', name='Swin_768_stain'),\n            log_checkpoint=True,\n            log_checkpoint_metadata=True,\n            num_eval_images=10)\n    ])\ndist_params = dict(backend='nccl')\nlog_level = 'INFO'\nload_from = None\nresume_from = None\nworkflow = [('train', 1)]\ncudnn_benchmark = True\noptimizer = dict(\n    type='AdamW',\n    lr=0.001,\n    betas=(0.9, 0.999),\n    weight_decay=0.05,\n    paramwise_cfg=dict(\n        custom_keys=dict(\n            absolute_pos_embed=dict(decay_mult=0.0),\n            relative_position_bias_table=dict(decay_mult=0.0),\n            norm=dict(decay_mult=0.0))))\noptimizer_config = dict(type='Fp16OptimizerHook', loss_scale='dynamic')\nlr_config = dict(\n    policy='poly',\n    warmup='linear',\n    warmup_iters=500,\n    warmup_ratio=1e-06,\n    power=1.0,\n    min_lr=0.0,\n    by_epoch=False)\nrunner = dict(type='IterBasedRunner', max_iters=60000)\ncheckpoint_config = dict(\n    by_epoch=False, interval=1000, max_keep_ckpts=1, save_optimizer=True)\nevaluation = dict(\n    interval=1000,\n    metric='mDice',\n    pre_eval=True,\n    by_epoch=False,\n    save_best='mDice')\ncheckpoint_file = 'https://download.openmmlab.com/mmsegmentation/v0.5/pretrain/swin/swin_base_patch4_window7_224_20220317-e9b98025.pth'\nsize = 768\ntotal_iters = 60000\nfind_unused_parameters = True\nfp16 = dict()\ngpu_ids = [0]\nauto_resume = False\n</code></pre>\n<p>Thank you</p>",
  "messages": [
    {
      "id": "1961157",
      "postDate": "09/29/2022 03:43:40",
      "content": "<p>Thanks for the competition. I had a lot to learn.</p>\n<p>Has anyone been able to get a good score using mmseg?<br>\nI trained  Swin using mmseg with Stain Normalization and other aug.<br>\nCV was 0.75+ but LB is not even close to 0.5.<br>\nI think I am using this tool in the wrong way.<br>\nIf anyone has done well using mmseg, I would be glad to see your configuration files and inference notes.</p>\n<p><a href=\"https://www.kaggle.com/code/tomp1121/mmsegmentation-inference/notebook\" target=\"_blank\">inference note</a></p>\n<p>config file:</p>\n<pre><code>c_size = 768\nst_size = 256\nPROJECT_NAME = 'Swin_768_stain'\ntrain_size = (2000, 2000)\ntest_size = (2000, 2000)\ncrop_size = (768, 768)\nstride_size = (256, 256)\nwork_dir = 'hubmap/checkpoints/Swin_768_stain'\nnorm_cfg = dict(type='SyncBN', requires_grad=True)\nbackbone_norm_cfg = dict(type='LN', requires_grad=True)\nmodel = dict(\n    type='EncoderDecoder',\n    pretrained=None,\n    backbone=dict(\n        type='SwinTransformer',\n        pretrain_img_size=224,\n        embed_dims=128,\n        patch_size=4,\n        window_size=7,\n        mlp_ratio=4,\n        depths=[2, 2, 18, 2],\n        num_heads=[4, 8, 16, 32],\n        strides=(4, 2, 2, 2),\n        out_indices=(0, 1, 2, 3),\n        qkv_bias=True,\n        qk_scale=None,\n        patch_norm=True,\n        drop_rate=0.0,\n        attn_drop_rate=0.0,\n        drop_path_rate=0.3,\n        use_abs_pos_embed=False,\n        act_cfg=dict(type='GELU'),\n        norm_cfg=dict(type='LN', requires_grad=True),\n        init_cfg=dict(\n            type='Pretrained',\n            checkpoint=\n            'https://download.openmmlab.com/mmsegmentation/v0.5/pretrain/swin/swin_base_patch4_window7_224_20220317-e9b98025.pth'\n        )),\n    decode_head=dict(\n        type='UPerHead',\n        in_channels=[128, 256, 512, 1024],\n        in_index=[0, 1, 2, 3],\n        pool_scales=(1, 2, 3, 6),\n        channels=512,\n        dropout_ratio=0.1,\n        num_classes=6,\n        norm_cfg=dict(type='SyncBN', requires_grad=True),\n        align_corners=False,\n        loss_decode=dict(\n            type='CrossEntropyLoss', use_sigmoid=False, loss_weight=1.0)),\n    auxiliary_head=dict(\n        type='FCNHead',\n        in_channels=512,\n        in_index=2,\n        channels=256,\n        num_convs=1,\n        concat_input=False,\n        dropout_ratio=0.1,\n        num_classes=150,\n        norm_cfg=dict(type='SyncBN', requires_grad=True),\n        align_corners=False,\n        loss_decode=dict(\n            type='CrossEntropyLoss', use_sigmoid=False, loss_weight=0.4)),\n    train_cfg=dict(),\n    test_cfg=dict(mode='slide', crop_size=(768, 768), stride=(256, 256)))\ndataset_type = 'CustomDataset'\ndata_root = 'mmseg_data/'\nclasses = [\n    'background', 'kidney', 'prostate', 'largeintestine', 'spleen', 'lung'\n]\npalette = [[0, 0, 0], [255, 0, 0], [0, 255, 0], [0, 0, 255], [255, 255, 0],\n           [255, 0, 255]]\nimg_norm_cfg = dict(\n    mean=[216.75, 180.32, 196.0], std=[49.38, 83.52, 68.55], to_rgb=True)\ntrain_pipeline = [\n    dict(type='LoadImageFromFile'),\n    dict(type='LoadAnnotations'),\n    dict(type='Resize', img_scale=(2000, 2000), ratio_range=(0.5, 2.0)),\n    dict(type='RandomCrop', crop_size=(768, 768), cat_max_ratio=0.9),\n    dict(type='RandomFlip', prob=0.5, direction='horizontal'),\n    dict(type='RandomFlip', prob=0.5, direction='vertical'),\n    dict(type='RandomRotate', prob=0.5, degree=90),\n    dict(type='PhotoMetricDistortion'),\n    dict(\n        type='Normalize',\n        mean=[216.75, 180.32, 196.0],\n        std=[49.38, 83.52, 68.55],\n        to_rgb=True),\n    dict(type='Pad', size=(768, 768), pad_val=0, seg_pad_val=255),\n    dict(type='DefaultFormatBundle'),\n    dict(type='Collect', keys=['img', 'gt_semantic_seg'])\n]\nval_pipeline = [\n    dict(type='LoadImageFromFile'),\n    dict(\n        type='MultiScaleFlipAug',\n        img_scale=(2000, 2000),\n        flip=False,\n        transforms=[\n            dict(type='Resize', keep_ratio=True),\n            dict(type='RandomFlip'),\n            dict(\n                type='Normalize',\n                mean=[216.75, 180.32, 196.0],\n                std=[49.38, 83.52, 68.55],\n                to_rgb=True),\n            dict(type='ImageToTensor', keys=['img']),\n            dict(type='Collect', keys=['img'])\n        ])\n]\ntest_pipeline = [\n    dict(type='LoadImageFromFile'),\n    dict(\n        type='MultiScaleFlipAug',\n        img_scale=(2000, 2000),\n        flip=False,\n        transforms=[\n            dict(type='Resize', keep_ratio=True),\n            dict(type='RandomFlip'),\n            dict(\n                type='Normalize',\n                mean=[216.75, 180.32, 196.0],\n                std=[49.38, 83.52, 68.55],\n                to_rgb=True),\n            dict(type='ImageToTensor', keys=['img']),\n            dict(type='Collect', keys=['img'])\n        ])\n]\ndata = dict(\n    samples_per_gpu=4,\n    workers_per_gpu=2,\n    train=dict(\n        type='CustomDataset',\n        data_root='mmseg_data/',\n        img_dir='train_images_w_stain',\n        ann_dir='original_masks',\n        img_suffix='.png',\n        seg_map_suffix='.png',\n        split='splits/fold_0.txt',\n        classes=[\n            'background', 'kidney', 'prostate', 'largeintestine', 'spleen',\n            'lung'\n        ],\n        palette=[[0, 0, 0], [255, 0, 0], [0, 255, 0], [0, 0, 255],\n                 [255, 255, 0], [255, 0, 255]],\n        pipeline=[\n            dict(type='LoadImageFromFile'),\n            dict(type='LoadAnnotations'),\n            dict(\n                type='Resize', img_scale=(2000, 2000), ratio_range=(0.5, 2.0)),\n            dict(type='RandomCrop', crop_size=(768, 768), cat_max_ratio=0.9),\n            dict(type='RandomFlip', prob=0.5, direction='horizontal'),\n            dict(type='RandomFlip', prob=0.5, direction='vertical'),\n            dict(type='RandomRotate', prob=0.5, degree=90),\n            dict(type='PhotoMetricDistortion'),\n            dict(\n                type='Normalize',\n                mean=[216.75, 180.32, 196.0],\n                std=[49.38, 83.52, 68.55],\n                to_rgb=True),\n            dict(type='Pad', size=(768, 768), pad_val=0, seg_pad_val=255),\n            dict(type='DefaultFormatBundle'),\n            dict(type='Collect', keys=['img', 'gt_semantic_seg'])\n        ]),\n    val=dict(\n        type='CustomDataset',\n        data_root='mmseg_data/',\n        img_dir='train_images_w_stain',\n        ann_dir='original_masks',\n        img_suffix='.png',\n        seg_map_suffix='.png',\n        split='splits/valid_0.txt',\n        classes=[\n            'background', 'kidney', 'prostate', 'largeintestine', 'spleen',\n            'lung'\n        ],\n        palette=[[0, 0, 0], [255, 0, 0], [0, 255, 0], [0, 0, 255],\n                 [255, 255, 0], [255, 0, 255]],\n        pipeline=[\n            dict(type='LoadImageFromFile'),\n            dict(\n                type='MultiScaleFlipAug',\n                img_scale=(2000, 2000),\n                flip=False,\n                transforms=[\n                    dict(type='Resize', keep_ratio=True),\n                    dict(type='RandomFlip'),\n                    dict(\n                        type='Normalize',\n                        mean=[216.75, 180.32, 196.0],\n                        std=[49.38, 83.52, 68.55],\n                        to_rgb=True),\n                    dict(type='ImageToTensor', keys=['img']),\n                    dict(type='Collect', keys=['img'])\n                ])\n        ]),\n    test=dict(\n        type='CustomDataset',\n        data_root='mmseg_data/',\n        test_mode=True,\n        img_dir='train_images_w_stain',\n        ann_dir='original_masks',\n        img_suffix='.png',\n        seg_map_suffix='.png',\n        classes=[\n            'background', 'kidney', 'prostate', 'largeintestine', 'spleen',\n            'lung'\n        ],\n        palette=[[0, 0, 0], [255, 0, 0], [0, 255, 0], [0, 0, 255],\n                 [255, 255, 0], [255, 0, 255]],\n        pipeline=[\n            dict(type='LoadImageFromFile'),\n            dict(\n                type='MultiScaleFlipAug',\n                img_scale=(2000, 2000),\n                flip=False,\n                transforms=[\n                    dict(type='Resize', keep_ratio=True),\n                    dict(type='RandomFlip'),\n                    dict(\n                        type='Normalize',\n                        mean=[216.75, 180.32, 196.0],\n                        std=[49.38, 83.52, 68.55],\n                        to_rgb=True),\n                    dict(type='ImageToTensor', keys=['img']),\n                    dict(type='Collect', keys=['img'])\n                ])\n        ]))\nlog_config = dict(\n    interval=100,\n    hooks=[\n        dict(type='TextLoggerHook', by_epoch=False),\n        dict(\n            type='MMSegWandbHook',\n            with_step=False,\n            by_epoch=False,\n            init_kwargs=dict(project='hubmap', name='Swin_768_stain'),\n            log_checkpoint=True,\n            log_checkpoint_metadata=True,\n            num_eval_images=10)\n    ])\ndist_params = dict(backend='nccl')\nlog_level = 'INFO'\nload_from = None\nresume_from = None\nworkflow = [('train', 1)]\ncudnn_benchmark = True\noptimizer = dict(\n    type='AdamW',\n    lr=0.001,\n    betas=(0.9, 0.999),\n    weight_decay=0.05,\n    paramwise_cfg=dict(\n        custom_keys=dict(\n            absolute_pos_embed=dict(decay_mult=0.0),\n            relative_position_bias_table=dict(decay_mult=0.0),\n            norm=dict(decay_mult=0.0))))\noptimizer_config = dict(type='Fp16OptimizerHook', loss_scale='dynamic')\nlr_config = dict(\n    policy='poly',\n    warmup='linear',\n    warmup_iters=500,\n    warmup_ratio=1e-06,\n    power=1.0,\n    min_lr=0.0,\n    by_epoch=False)\nrunner = dict(type='IterBasedRunner', max_iters=60000)\ncheckpoint_config = dict(\n    by_epoch=False, interval=1000, max_keep_ckpts=1, save_optimizer=True)\nevaluation = dict(\n    interval=1000,\n    metric='mDice',\n    pre_eval=True,\n    by_epoch=False,\n    save_best='mDice')\ncheckpoint_file = 'https://download.openmmlab.com/mmsegmentation/v0.5/pretrain/swin/swin_base_patch4_window7_224_20220317-e9b98025.pth'\nsize = 768\ntotal_iters = 60000\nfind_unused_parameters = True\nfp16 = dict()\ngpu_ids = [0]\nauto_resume = False\n</code></pre>\n<p>Thank you</p>",
      "rawMarkdown": "Thanks for the competition. I had a lot to learn.\n\nHas anyone been able to get a good score using mmseg?\nI trained  Swin using mmseg with Stain Normalization and other aug.\nCV was 0.75+ but LB is not even close to 0.5.\nI think I am using this tool in the wrong way.\nIf anyone has done well using mmseg, I would be glad to see your configuration files and inference notes.\n\n\n[inference note](https://www.kaggle.com/code/tomp1121/mmsegmentation-inference/notebook)\n\nconfig file:\n```\nc_size = 768\nst_size = 256\nPROJECT_NAME = 'Swin_768_stain'\ntrain_size = (2000, 2000)\ntest_size = (2000, 2000)\ncrop_size = (768, 768)\nstride_size = (256, 256)\nwork_dir = 'hubmap/checkpoints/Swin_768_stain'\nnorm_cfg = dict(type='SyncBN', requires_grad=True)\nbackbone_norm_cfg = dict(type='LN', requires_grad=True)\nmodel = dict(\n    type='EncoderDecoder',\n    pretrained=None,\n    backbone=dict(\n        type='SwinTransformer',\n        pretrain_img_size=224,\n        embed_dims=128,\n        patch_size=4,\n        window_size=7,\n        mlp_ratio=4,\n        depths=[2, 2, 18, 2],\n        num_heads=[4, 8, 16, 32],\n        strides=(4, 2, 2, 2),\n        out_indices=(0, 1, 2, 3),\n        qkv_bias=True,\n        qk_scale=None,\n        patch_norm=True,\n        drop_rate=0.0,\n        attn_drop_rate=0.0,\n        drop_path_rate=0.3,\n        use_abs_pos_embed=False,\n        act_cfg=dict(type='GELU'),\n        norm_cfg=dict(type='LN', requires_grad=True),\n        init_cfg=dict(\n            type='Pretrained',\n            checkpoint=\n            'https://download.openmmlab.com/mmsegmentation/v0.5/pretrain/swin/swin_base_patch4_window7_224_20220317-e9b98025.pth'\n        )),\n    decode_head=dict(\n        type='UPerHead',\n        in_channels=[128, 256, 512, 1024],\n        in_index=[0, 1, 2, 3],\n        pool_scales=(1, 2, 3, 6),\n        channels=512,\n        dropout_ratio=0.1,\n        num_classes=6,\n        norm_cfg=dict(type='SyncBN', requires_grad=True),\n        align_corners=False,\n        loss_decode=dict(\n            type='CrossEntropyLoss', use_sigmoid=False, loss_weight=1.0)),\n    auxiliary_head=dict(\n        type='FCNHead',\n        in_channels=512,\n        in_index=2,\n        channels=256,\n        num_convs=1,\n        concat_input=False,\n        dropout_ratio=0.1,\n        num_classes=150,\n        norm_cfg=dict(type='SyncBN', requires_grad=True),\n        align_corners=False,\n        loss_decode=dict(\n            type='CrossEntropyLoss', use_sigmoid=False, loss_weight=0.4)),\n    train_cfg=dict(),\n    test_cfg=dict(mode='slide', crop_size=(768, 768), stride=(256, 256)))\ndataset_type = 'CustomDataset'\ndata_root = 'mmseg_data/'\nclasses = [\n    'background', 'kidney', 'prostate', 'largeintestine', 'spleen', 'lung'\n]\npalette = [[0, 0, 0], [255, 0, 0], [0, 255, 0], [0, 0, 255], [255, 255, 0],\n           [255, 0, 255]]\nimg_norm_cfg = dict(\n    mean=[216.75, 180.32, 196.0], std=[49.38, 83.52, 68.55], to_rgb=True)\ntrain_pipeline = [\n    dict(type='LoadImageFromFile'),\n    dict(type='LoadAnnotations'),\n    dict(type='Resize', img_scale=(2000, 2000), ratio_range=(0.5, 2.0)),\n    dict(type='RandomCrop', crop_size=(768, 768), cat_max_ratio=0.9),\n    dict(type='RandomFlip', prob=0.5, direction='horizontal'),\n    dict(type='RandomFlip', prob=0.5, direction='vertical'),\n    dict(type='RandomRotate', prob=0.5, degree=90),\n    dict(type='PhotoMetricDistortion'),\n    dict(\n        type='Normalize',\n        mean=[216.75, 180.32, 196.0],\n        std=[49.38, 83.52, 68.55],\n        to_rgb=True),\n    dict(type='Pad', size=(768, 768), pad_val=0, seg_pad_val=255),\n    dict(type='DefaultFormatBundle'),\n    dict(type='Collect', keys=['img', 'gt_semantic_seg'])\n]\nval_pipeline = [\n    dict(type='LoadImageFromFile'),\n    dict(\n        type='MultiScaleFlipAug',\n        img_scale=(2000, 2000),\n        flip=False,\n        transforms=[\n            dict(type='Resize', keep_ratio=True),\n            dict(type='RandomFlip'),\n            dict(\n                type='Normalize',\n                mean=[216.75, 180.32, 196.0],\n                std=[49.38, 83.52, 68.55],\n                to_rgb=True),\n            dict(type='ImageToTensor', keys=['img']),\n            dict(type='Collect', keys=['img'])\n        ])\n]\ntest_pipeline = [\n    dict(type='LoadImageFromFile'),\n    dict(\n        type='MultiScaleFlipAug',\n        img_scale=(2000, 2000),\n        flip=False,\n        transforms=[\n            dict(type='Resize', keep_ratio=True),\n            dict(type='RandomFlip'),\n            dict(\n                type='Normalize',\n                mean=[216.75, 180.32, 196.0],\n                std=[49.38, 83.52, 68.55],\n                to_rgb=True),\n            dict(type='ImageToTensor', keys=['img']),\n            dict(type='Collect', keys=['img'])\n        ])\n]\ndata = dict(\n    samples_per_gpu=4,\n    workers_per_gpu=2,\n    train=dict(\n        type='CustomDataset',\n        data_root='mmseg_data/',\n        img_dir='train_images_w_stain',\n        ann_dir='original_masks',\n        img_suffix='.png',\n        seg_map_suffix='.png',\n        split='splits/fold_0.txt',\n        classes=[\n            'background', 'kidney', 'prostate', 'largeintestine', 'spleen',\n            'lung'\n        ],\n        palette=[[0, 0, 0], [255, 0, 0], [0, 255, 0], [0, 0, 255],\n                 [255, 255, 0], [255, 0, 255]],\n        pipeline=[\n            dict(type='LoadImageFromFile'),\n            dict(type='LoadAnnotations'),\n            dict(\n                type='Resize', img_scale=(2000, 2000), ratio_range=(0.5, 2.0)),\n            dict(type='RandomCrop', crop_size=(768, 768), cat_max_ratio=0.9),\n            dict(type='RandomFlip', prob=0.5, direction='horizontal'),\n            dict(type='RandomFlip', prob=0.5, direction='vertical'),\n            dict(type='RandomRotate', prob=0.5, degree=90),\n            dict(type='PhotoMetricDistortion'),\n            dict(\n                type='Normalize',\n                mean=[216.75, 180.32, 196.0],\n                std=[49.38, 83.52, 68.55],\n                to_rgb=True),\n            dict(type='Pad', size=(768, 768), pad_val=0, seg_pad_val=255),\n            dict(type='DefaultFormatBundle'),\n            dict(type='Collect', keys=['img', 'gt_semantic_seg'])\n        ]),\n    val=dict(\n        type='CustomDataset',\n        data_root='mmseg_data/',\n        img_dir='train_images_w_stain',\n        ann_dir='original_masks',\n        img_suffix='.png',\n        seg_map_suffix='.png',\n        split='splits/valid_0.txt',\n        classes=[\n            'background', 'kidney', 'prostate', 'largeintestine', 'spleen',\n            'lung'\n        ],\n        palette=[[0, 0, 0], [255, 0, 0], [0, 255, 0], [0, 0, 255],\n                 [255, 255, 0], [255, 0, 255]],\n        pipeline=[\n            dict(type='LoadImageFromFile'),\n            dict(\n                type='MultiScaleFlipAug',\n                img_scale=(2000, 2000),\n                flip=False,\n                transforms=[\n                    dict(type='Resize', keep_ratio=True),\n                    dict(type='RandomFlip'),\n                    dict(\n                        type='Normalize',\n                        mean=[216.75, 180.32, 196.0],\n                        std=[49.38, 83.52, 68.55],\n                        to_rgb=True),\n                    dict(type='ImageToTensor', keys=['img']),\n                    dict(type='Collect', keys=['img'])\n                ])\n        ]),\n    test=dict(\n        type='CustomDataset',\n        data_root='mmseg_data/',\n        test_mode=True,\n        img_dir='train_images_w_stain',\n        ann_dir='original_masks',\n        img_suffix='.png',\n        seg_map_suffix='.png',\n        classes=[\n            'background', 'kidney', 'prostate', 'largeintestine', 'spleen',\n            'lung'\n        ],\n        palette=[[0, 0, 0], [255, 0, 0], [0, 255, 0], [0, 0, 255],\n                 [255, 255, 0], [255, 0, 255]],\n        pipeline=[\n            dict(type='LoadImageFromFile'),\n            dict(\n                type='MultiScaleFlipAug',\n                img_scale=(2000, 2000),\n                flip=False,\n                transforms=[\n                    dict(type='Resize', keep_ratio=True),\n                    dict(type='RandomFlip'),\n                    dict(\n                        type='Normalize',\n                        mean=[216.75, 180.32, 196.0],\n                        std=[49.38, 83.52, 68.55],\n                        to_rgb=True),\n                    dict(type='ImageToTensor', keys=['img']),\n                    dict(type='Collect', keys=['img'])\n                ])\n        ]))\nlog_config = dict(\n    interval=100,\n    hooks=[\n        dict(type='TextLoggerHook', by_epoch=False),\n        dict(\n            type='MMSegWandbHook',\n            with_step=False,\n            by_epoch=False,\n            init_kwargs=dict(project='hubmap', name='Swin_768_stain'),\n            log_checkpoint=True,\n            log_checkpoint_metadata=True,\n            num_eval_images=10)\n    ])\ndist_params = dict(backend='nccl')\nlog_level = 'INFO'\nload_from = None\nresume_from = None\nworkflow = [('train', 1)]\ncudnn_benchmark = True\noptimizer = dict(\n    type='AdamW',\n    lr=0.001,\n    betas=(0.9, 0.999),\n    weight_decay=0.05,\n    paramwise_cfg=dict(\n        custom_keys=dict(\n            absolute_pos_embed=dict(decay_mult=0.0),\n            relative_position_bias_table=dict(decay_mult=0.0),\n            norm=dict(decay_mult=0.0))))\noptimizer_config = dict(type='Fp16OptimizerHook', loss_scale='dynamic')\nlr_config = dict(\n    policy='poly',\n    warmup='linear',\n    warmup_iters=500,\n    warmup_ratio=1e-06,\n    power=1.0,\n    min_lr=0.0,\n    by_epoch=False)\nrunner = dict(type='IterBasedRunner', max_iters=60000)\ncheckpoint_config = dict(\n    by_epoch=False, interval=1000, max_keep_ckpts=1, save_optimizer=True)\nevaluation = dict(\n    interval=1000,\n    metric='mDice',\n    pre_eval=True,\n    by_epoch=False,\n    save_best='mDice')\ncheckpoint_file = 'https://download.openmmlab.com/mmsegmentation/v0.5/pretrain/swin/swin_base_patch4_window7_224_20220317-e9b98025.pth'\nsize = 768\ntotal_iters = 60000\nfind_unused_parameters = True\nfp16 = dict()\ngpu_ids = [0]\nauto_resume = False\n\n```\n\nThank you",
      "votes": null
    },
    {
      "id": "1965295",
      "postDate": "10/01/2022 08:40:15",
      "content": "<p>I also want to know why my use of \"MM segmentation\" is not good</p>",
      "rawMarkdown": "I also want to know why my use of \"MM segmentation\" is not good",
      "votes": null
    }
  ],
  "comments": [
    {
      "id": 1965295,
      "author_name": "fredhaha",
      "author_url": "",
      "post_date": "10/01/2022 08:40:15",
      "content": "<p>I also want to know why my use of \"MM segmentation\" is not good</p>",
      "votes": null,
      "replies": []
    }
  ],
  "raw_markdown_by_id": {
    "1961157": "Thanks for the competition. I had a lot to learn.\n\nHas anyone been able to get a good score using mmseg?\nI trained  Swin using mmseg with Stain Normalization and other aug.\nCV was 0.75+ but LB is not even close to 0.5.\nI think I am using this tool in the wrong way.\nIf anyone has done well using mmseg, I would be glad to see your configuration files and inference notes.\n\n\n[inference note](https://www.kaggle.com/code/tomp1121/mmsegmentation-inference/notebook)\n\nconfig file:\n```\nc_size = 768\nst_size = 256\nPROJECT_NAME = 'Swin_768_stain'\ntrain_size = (2000, 2000)\ntest_size = (2000, 2000)\ncrop_size = (768, 768)\nstride_size = (256, 256)\nwork_dir = 'hubmap/checkpoints/Swin_768_stain'\nnorm_cfg = dict(type='SyncBN', requires_grad=True)\nbackbone_norm_cfg = dict(type='LN', requires_grad=True)\nmodel = dict(\n    type='EncoderDecoder',\n    pretrained=None,\n    backbone=dict(\n        type='SwinTransformer',\n        pretrain_img_size=224,\n        embed_dims=128,\n        patch_size=4,\n        window_size=7,\n        mlp_ratio=4,\n        depths=[2, 2, 18, 2],\n        num_heads=[4, 8, 16, 32],\n        strides=(4, 2, 2, 2),\n        out_indices=(0, 1, 2, 3),\n        qkv_bias=True,\n        qk_scale=None,\n        patch_norm=True,\n        drop_rate=0.0,\n        attn_drop_rate=0.0,\n        drop_path_rate=0.3,\n        use_abs_pos_embed=False,\n        act_cfg=dict(type='GELU'),\n        norm_cfg=dict(type='LN', requires_grad=True),\n        init_cfg=dict(\n            type='Pretrained',\n            checkpoint=\n            'https://download.openmmlab.com/mmsegmentation/v0.5/pretrain/swin/swin_base_patch4_window7_224_20220317-e9b98025.pth'\n        )),\n    decode_head=dict(\n        type='UPerHead',\n        in_channels=[128, 256, 512, 1024],\n        in_index=[0, 1, 2, 3],\n        pool_scales=(1, 2, 3, 6),\n        channels=512,\n        dropout_ratio=0.1,\n        num_classes=6,\n        norm_cfg=dict(type='SyncBN', requires_grad=True),\n        align_corners=False,\n        loss_decode=dict(\n            type='CrossEntropyLoss', use_sigmoid=False, loss_weight=1.0)),\n    auxiliary_head=dict(\n        type='FCNHead',\n        in_channels=512,\n        in_index=2,\n        channels=256,\n        num_convs=1,\n        concat_input=False,\n        dropout_ratio=0.1,\n        num_classes=150,\n        norm_cfg=dict(type='SyncBN', requires_grad=True),\n        align_corners=False,\n        loss_decode=dict(\n            type='CrossEntropyLoss', use_sigmoid=False, loss_weight=0.4)),\n    train_cfg=dict(),\n    test_cfg=dict(mode='slide', crop_size=(768, 768), stride=(256, 256)))\ndataset_type = 'CustomDataset'\ndata_root = 'mmseg_data/'\nclasses = [\n    'background', 'kidney', 'prostate', 'largeintestine', 'spleen', 'lung'\n]\npalette = [[0, 0, 0], [255, 0, 0], [0, 255, 0], [0, 0, 255], [255, 255, 0],\n           [255, 0, 255]]\nimg_norm_cfg = dict(\n    mean=[216.75, 180.32, 196.0], std=[49.38, 83.52, 68.55], to_rgb=True)\ntrain_pipeline = [\n    dict(type='LoadImageFromFile'),\n    dict(type='LoadAnnotations'),\n    dict(type='Resize', img_scale=(2000, 2000), ratio_range=(0.5, 2.0)),\n    dict(type='RandomCrop', crop_size=(768, 768), cat_max_ratio=0.9),\n    dict(type='RandomFlip', prob=0.5, direction='horizontal'),\n    dict(type='RandomFlip', prob=0.5, direction='vertical'),\n    dict(type='RandomRotate', prob=0.5, degree=90),\n    dict(type='PhotoMetricDistortion'),\n    dict(\n        type='Normalize',\n        mean=[216.75, 180.32, 196.0],\n        std=[49.38, 83.52, 68.55],\n        to_rgb=True),\n    dict(type='Pad', size=(768, 768), pad_val=0, seg_pad_val=255),\n    dict(type='DefaultFormatBundle'),\n    dict(type='Collect', keys=['img', 'gt_semantic_seg'])\n]\nval_pipeline = [\n    dict(type='LoadImageFromFile'),\n    dict(\n        type='MultiScaleFlipAug',\n        img_scale=(2000, 2000),\n        flip=False,\n        transforms=[\n            dict(type='Resize', keep_ratio=True),\n            dict(type='RandomFlip'),\n            dict(\n                type='Normalize',\n                mean=[216.75, 180.32, 196.0],\n                std=[49.38, 83.52, 68.55],\n                to_rgb=True),\n            dict(type='ImageToTensor', keys=['img']),\n            dict(type='Collect', keys=['img'])\n        ])\n]\ntest_pipeline = [\n    dict(type='LoadImageFromFile'),\n    dict(\n        type='MultiScaleFlipAug',\n        img_scale=(2000, 2000),\n        flip=False,\n        transforms=[\n            dict(type='Resize', keep_ratio=True),\n            dict(type='RandomFlip'),\n            dict(\n                type='Normalize',\n                mean=[216.75, 180.32, 196.0],\n                std=[49.38, 83.52, 68.55],\n                to_rgb=True),\n            dict(type='ImageToTensor', keys=['img']),\n            dict(type='Collect', keys=['img'])\n        ])\n]\ndata = dict(\n    samples_per_gpu=4,\n    workers_per_gpu=2,\n    train=dict(\n        type='CustomDataset',\n        data_root='mmseg_data/',\n        img_dir='train_images_w_stain',\n        ann_dir='original_masks',\n        img_suffix='.png',\n        seg_map_suffix='.png',\n        split='splits/fold_0.txt',\n        classes=[\n            'background', 'kidney', 'prostate', 'largeintestine', 'spleen',\n            'lung'\n        ],\n        palette=[[0, 0, 0], [255, 0, 0], [0, 255, 0], [0, 0, 255],\n                 [255, 255, 0], [255, 0, 255]],\n        pipeline=[\n            dict(type='LoadImageFromFile'),\n            dict(type='LoadAnnotations'),\n            dict(\n                type='Resize', img_scale=(2000, 2000), ratio_range=(0.5, 2.0)),\n            dict(type='RandomCrop', crop_size=(768, 768), cat_max_ratio=0.9),\n            dict(type='RandomFlip', prob=0.5, direction='horizontal'),\n            dict(type='RandomFlip', prob=0.5, direction='vertical'),\n            dict(type='RandomRotate', prob=0.5, degree=90),\n            dict(type='PhotoMetricDistortion'),\n            dict(\n                type='Normalize',\n                mean=[216.75, 180.32, 196.0],\n                std=[49.38, 83.52, 68.55],\n                to_rgb=True),\n            dict(type='Pad', size=(768, 768), pad_val=0, seg_pad_val=255),\n            dict(type='DefaultFormatBundle'),\n            dict(type='Collect', keys=['img', 'gt_semantic_seg'])\n        ]),\n    val=dict(\n        type='CustomDataset',\n        data_root='mmseg_data/',\n        img_dir='train_images_w_stain',\n        ann_dir='original_masks',\n        img_suffix='.png',\n        seg_map_suffix='.png',\n        split='splits/valid_0.txt',\n        classes=[\n            'background', 'kidney', 'prostate', 'largeintestine', 'spleen',\n            'lung'\n        ],\n        palette=[[0, 0, 0], [255, 0, 0], [0, 255, 0], [0, 0, 255],\n                 [255, 255, 0], [255, 0, 255]],\n        pipeline=[\n            dict(type='LoadImageFromFile'),\n            dict(\n                type='MultiScaleFlipAug',\n                img_scale=(2000, 2000),\n                flip=False,\n                transforms=[\n                    dict(type='Resize', keep_ratio=True),\n                    dict(type='RandomFlip'),\n                    dict(\n                        type='Normalize',\n                        mean=[216.75, 180.32, 196.0],\n                        std=[49.38, 83.52, 68.55],\n                        to_rgb=True),\n                    dict(type='ImageToTensor', keys=['img']),\n                    dict(type='Collect', keys=['img'])\n                ])\n        ]),\n    test=dict(\n        type='CustomDataset',\n        data_root='mmseg_data/',\n        test_mode=True,\n        img_dir='train_images_w_stain',\n        ann_dir='original_masks',\n        img_suffix='.png',\n        seg_map_suffix='.png',\n        classes=[\n            'background', 'kidney', 'prostate', 'largeintestine', 'spleen',\n            'lung'\n        ],\n        palette=[[0, 0, 0], [255, 0, 0], [0, 255, 0], [0, 0, 255],\n                 [255, 255, 0], [255, 0, 255]],\n        pipeline=[\n            dict(type='LoadImageFromFile'),\n            dict(\n                type='MultiScaleFlipAug',\n                img_scale=(2000, 2000),\n                flip=False,\n                transforms=[\n                    dict(type='Resize', keep_ratio=True),\n                    dict(type='RandomFlip'),\n                    dict(\n                        type='Normalize',\n                        mean=[216.75, 180.32, 196.0],\n                        std=[49.38, 83.52, 68.55],\n                        to_rgb=True),\n                    dict(type='ImageToTensor', keys=['img']),\n                    dict(type='Collect', keys=['img'])\n                ])\n        ]))\nlog_config = dict(\n    interval=100,\n    hooks=[\n        dict(type='TextLoggerHook', by_epoch=False),\n        dict(\n            type='MMSegWandbHook',\n            with_step=False,\n            by_epoch=False,\n            init_kwargs=dict(project='hubmap', name='Swin_768_stain'),\n            log_checkpoint=True,\n            log_checkpoint_metadata=True,\n            num_eval_images=10)\n    ])\ndist_params = dict(backend='nccl')\nlog_level = 'INFO'\nload_from = None\nresume_from = None\nworkflow = [('train', 1)]\ncudnn_benchmark = True\noptimizer = dict(\n    type='AdamW',\n    lr=0.001,\n    betas=(0.9, 0.999),\n    weight_decay=0.05,\n    paramwise_cfg=dict(\n        custom_keys=dict(\n            absolute_pos_embed=dict(decay_mult=0.0),\n            relative_position_bias_table=dict(decay_mult=0.0),\n            norm=dict(decay_mult=0.0))))\noptimizer_config = dict(type='Fp16OptimizerHook', loss_scale='dynamic')\nlr_config = dict(\n    policy='poly',\n    warmup='linear',\n    warmup_iters=500,\n    warmup_ratio=1e-06,\n    power=1.0,\n    min_lr=0.0,\n    by_epoch=False)\nrunner = dict(type='IterBasedRunner', max_iters=60000)\ncheckpoint_config = dict(\n    by_epoch=False, interval=1000, max_keep_ckpts=1, save_optimizer=True)\nevaluation = dict(\n    interval=1000,\n    metric='mDice',\n    pre_eval=True,\n    by_epoch=False,\n    save_best='mDice')\ncheckpoint_file = 'https://download.openmmlab.com/mmsegmentation/v0.5/pretrain/swin/swin_base_patch4_window7_224_20220317-e9b98025.pth'\nsize = 768\ntotal_iters = 60000\nfind_unused_parameters = True\nfp16 = dict()\ngpu_ids = [0]\nauto_resume = False\n\n```\n\nThank you",
    "1965295": "I also want to know why my use of \"MM segmentation\" is not good"
  },
  "source": "meta"
}