Skip to content

Commit 3cc9d30

Browse files
authored
[Project] Medical semantic seg dataset: ISIC-2017 Task1 (open-mmlab#2709)
1 parent b24f422 commit 3cc9d30

File tree

7 files changed

+407
-0
lines changed

7 files changed

+407
-0
lines changed
Lines changed: 158 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,158 @@
1+
# ISIC-2017 Task1
2+
3+
## Description
4+
5+
This project support **`ISIC-2017 Task1 `**, and the dataset used in this project can be downloaded from [here](https://challenge.isic-archive.com/data/#2017).
6+
7+
### Dataset Overview
8+
9+
The goal of the challenge is to help participants develop image analysis tools to enable the automated diagnosis of melanoma from dermoscopic images.
10+
11+
This challenge provides training data (~2000 images) for participants to engage in all 3 components of lesion image analysis. A separate public validation dataset (~150 images) and blind held-out test dataset (~600 images) will be provided for participants to generate and submit automated results.
12+
13+
### Original Statistic Information
14+
15+
| Dataset name | Anatomical region | Task type | Modality | Num. Classes | Train/Val/Test Images | Train/Val/Test Labeled | Release Date | License |
16+
| ---------------------------------------------------------------- | ----------------- | ------------ | ---------- | ------------ | --------------------- | ---------------------- | ------------ | ---------------------------------------------------------------------- |
17+
| [ISIC-2017 Task1](https://challenge.isic-archive.com/data/#2017) | full body | segmentation | dermoscopy | 2 | 2000/150/600 | yes/yes/yes | 2017 | [CC-0](https://creativecommons.org/share-your-work/public-domain/cc0/) |
18+
19+
| Class Name | Num. Train | Pct. Train | Num. Val | Pct. Val | Num. Test | Pct. Test |
20+
| :---------: | :--------: | :--------: | :------: | :------: | :-------: | :-------: |
21+
| normal | 2000 | 82.86 | 150 | 73.88 | 600 | 70.62 |
22+
| skin lesion | 2000 | 17.14 | 150 | 26.12 | 600 | 29.38 |
23+
24+
Note:
25+
26+
- `Pct` means percentage of pixels in this category in all pixels.
27+
28+
### Visualization
29+
30+
![bac](https://raw.githubusercontent.com/uni-medical/medical-datasets-visualization/main/2d/semantic_seg/dermoscopy/isic2017_task1/isic2017_task1.png)
31+
32+
### Prerequisites
33+
34+
- Python 3.8
35+
- PyTorch 1.10.0
36+
- pillow(PIL) 9.3.0
37+
- scikit-learn(sklearn) 1.2.0
38+
- [MIM](https://github.com/open-mmlab/mim) v0.3.4
39+
- [MMCV](https://github.com/open-mmlab/mmcv) v2.0.0rc4
40+
- [MMEngine](https://github.com/open-mmlab/mmengine) v0.2.0 or higher
41+
- [MMSegmentation](https://github.com/open-mmlab/mmsegmentation) v1.0.0rc5
42+
43+
All the commands below rely on the correct configuration of PYTHONPATH, which should point to the project's directory so that Python can locate the module files. In isic2017_task1/ root directory, run the following line to add the current directory to PYTHONPATH:
44+
45+
```shell
46+
export PYTHONPATH=`pwd`:$PYTHONPATH
47+
```
48+
49+
### Dataset preparing
50+
51+
- download dataset from [here](https://challenge.isic-archive.com/data/#2017) and decompression data to path 'data/'.
52+
- run script `"python tools/prepare_dataset.py"` to split dataset and change folder structure as below.
53+
- run script `"python ../../tools/split_seg_dataset.py"` to split dataset and generate `train.txt` and `test.txt`. If the label of official validation set and test set can't be obtained, we generate `train.txt` and `val.txt` from the training set randomly.
54+
55+
```none
56+
mmsegmentation
57+
├── mmseg
58+
├── projects
59+
│ ├── medical
60+
│ │ ├── 2d_image
61+
│ │ │ ├── dermoscopy
62+
│ │ │ │ ├── isic2017_task1
63+
│ │ │ │ │ ├── configs
64+
│ │ │ │ │ ├── datasets
65+
│ │ │ │ │ ├── tools
66+
│ │ │ │ │ ├── data
67+
│ │ │ │ │ │ ├── train.txt
68+
│ │ │ │ │ │ ├── val.txt
69+
│ │ │ │ │ │ ├── test.txt
70+
│ │ │ │ │ │ ├── images
71+
│ │ │ │ │ │ │ ├── train
72+
│ │ │ │ | │ │ │ ├── xxx.png
73+
│ │ │ │ | │ │ │ ├── ...
74+
│ │ │ │ | │   │   │ └── xxx.png
75+
│ │ │ │ │ │ │ ├── val
76+
│ │ │ │ | │ │ │ ├── yyy.png
77+
│ │ │ │ | │ │ │ ├── ...
78+
│ │ │ │ | │   │   │ └── yyy.png
79+
│ │ │ │ │ │ │ ├── test
80+
│ │ │ │ | │ │ │ ├── yyy.png
81+
│ │ │ │ | │ │ │ ├── ...
82+
│ │ │ │ | │   │   │ └── yyy.png
83+
│ │ │ │ │ │ ├── masks
84+
│ │ │ │ │ │ │ ├── train
85+
│ │ │ │ | │ │ │ ├── xxx.png
86+
│ │ │ │ | │ │ │ ├── ...
87+
│ │ │ │ | │   │   │ └── xxx.png
88+
│ │ │ │ │ │ │ ├── val
89+
│ │ │ │ | │ │ │ ├── yyy.png
90+
│ │ │ │ | │ │ │ ├── ...
91+
│ │ │ │ | │   │   │ └── yyy.png
92+
│ │ │ │ │ │ │ ├── test
93+
│ │ │ │ | │ │ │ ├── yyy.png
94+
│ │ │ │ | │ │ │ ├── ...
95+
│ │ │ │ | │   │   │ └── yyy.png
96+
```
97+
98+
### Training commands
99+
100+
```shell
101+
mim train mmseg ./configs/${CONFIG_PATH}
102+
```
103+
104+
To train on multiple GPUs, e.g. 8 GPUs, run the following command:
105+
106+
```shell
107+
mim train mmseg ./configs/${CONFIG_PATH} --launcher pytorch --gpus 8
108+
```
109+
110+
### Testing commands
111+
112+
```shell
113+
mim test mmseg ./configs/${CONFIG_PATH} --checkpoint ${CHECKPOINT_PATH}
114+
```
115+
116+
<!-- List the results as usually done in other model's README. [Example](https://github.com/open-mmlab/mmsegmentation/tree/dev-1.x/configs/fcn#results-and-models)
117+
118+
You should claim whether this is based on the pre-trained weights, which are converted from the official release; or it's a reproduced result obtained from retraining the model in this project. -->
119+
120+
## Results
121+
122+
### ISIC-2017 Task1
123+
124+
| Method | Backbone | Crop Size | lr | mIoU | mDice | config |
125+
| :-------------: | :------: | :-------: | :----: | :--: | :---: | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: |
126+
| fcn_unet_s5-d16 | unet | 512x512 | 0.01 | - | - | [config](https://github.com/open-mmlab/mmsegmentation/tree/dev-1.x/projects/medical/2d_image/dermoscopy/isic2017_task1/configs/fcn-unet-s5-d16_unet_1xb16-0.01-20k_isic2017-task1-512x512.py) |
127+
| fcn_unet_s5-d16 | unet | 512x512 | 0.001 | - | - | [config](https://github.com/open-mmlab/mmsegmentation/tree/dev-1.x/projects/medical/2d_image/dermoscopy/isic2017_task1/configs/fcn-unet-s5-d16_unet_1xb16-0.001-20k_isic2017-task1-512x512.py) |
128+
| fcn_unet_s5-d16 | unet | 512x512 | 0.0001 | - | - | [config](https://github.com/open-mmlab/mmsegmentation/tree/dev-1.x/projects/medical/2d_image/dermoscopy/isic2017_task1/configs/fcn-unet-s5-d16_unet_1xb16-0.0001-20k_isic2017-task1-512x512.py) |
129+
130+
## Checklist
131+
132+
- [x] Milestone 1: PR-ready, and acceptable to be one of the `projects/`.
133+
134+
- [x] Finish the code
135+
136+
- [x] Basic docstrings & proper citation
137+
138+
- [ ] Test-time correctness
139+
140+
- [x] A full README
141+
142+
- [ ] Milestone 2: Indicates a successful model implementation.
143+
144+
- [ ] Training-time correctness
145+
146+
- [ ] Milestone 3: Good to be a part of our core package!
147+
148+
- [ ] Type hints and docstrings
149+
150+
- [ ] Unit tests
151+
152+
- [ ] Code polishing
153+
154+
- [ ] Metafile.yml
155+
156+
- [ ] Move your modules into the core package following the codebase's file hierarchy structure.
157+
158+
- [ ] Refactor your modules into the core package following the codebase's file hierarchy structure.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
_base_ = [
2+
'mmseg::_base_/models/fcn_unet_s5-d16.py', './isic2017-task1_512x512.py',
3+
'mmseg::_base_/default_runtime.py',
4+
'mmseg::_base_/schedules/schedule_20k.py'
5+
]
6+
custom_imports = dict(imports='datasets.isic2017-task1_dataset')
7+
img_scale = (512, 512)
8+
data_preprocessor = dict(size=img_scale)
9+
optimizer = dict(lr=0.0001)
10+
optim_wrapper = dict(optimizer=optimizer)
11+
model = dict(
12+
data_preprocessor=data_preprocessor,
13+
decode_head=dict(num_classes=2),
14+
auxiliary_head=None,
15+
test_cfg=dict(mode='whole', _delete_=True))
16+
vis_backends = None
17+
visualizer = dict(vis_backends=vis_backends)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
_base_ = [
2+
'mmseg::_base_/models/fcn_unet_s5-d16.py', './isic2017-task1_512x512.py',
3+
'mmseg::_base_/default_runtime.py',
4+
'mmseg::_base_/schedules/schedule_20k.py'
5+
]
6+
custom_imports = dict(imports='datasets.isic2017-task1_dataset')
7+
img_scale = (512, 512)
8+
data_preprocessor = dict(size=img_scale)
9+
optimizer = dict(lr=0.001)
10+
optim_wrapper = dict(optimizer=optimizer)
11+
model = dict(
12+
data_preprocessor=data_preprocessor,
13+
decode_head=dict(num_classes=2),
14+
auxiliary_head=None,
15+
test_cfg=dict(mode='whole', _delete_=True))
16+
vis_backends = None
17+
visualizer = dict(vis_backends=vis_backends)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
_base_ = [
2+
'mmseg::_base_/models/fcn_unet_s5-d16.py', './isic2017-task1_512x512.py',
3+
'mmseg::_base_/default_runtime.py',
4+
'mmseg::_base_/schedules/schedule_20k.py'
5+
]
6+
custom_imports = dict(imports='datasets.isic2017-task1_dataset')
7+
img_scale = (512, 512)
8+
data_preprocessor = dict(size=img_scale)
9+
optimizer = dict(lr=0.01)
10+
optim_wrapper = dict(optimizer=optimizer)
11+
model = dict(
12+
data_preprocessor=data_preprocessor,
13+
decode_head=dict(num_classes=2),
14+
auxiliary_head=None,
15+
test_cfg=dict(mode='whole', _delete_=True))
16+
vis_backends = None
17+
visualizer = dict(vis_backends=vis_backends)
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
dataset_type = 'ISIC2017Task1'
2+
data_root = 'data/'
3+
img_scale = (512, 512)
4+
train_pipeline = [
5+
dict(type='LoadImageFromFile'),
6+
dict(type='LoadAnnotations'),
7+
dict(type='Resize', scale=img_scale, keep_ratio=False),
8+
dict(type='RandomFlip', prob=0.5),
9+
dict(type='PhotoMetricDistortion'),
10+
dict(type='PackSegInputs')
11+
]
12+
test_pipeline = [
13+
dict(type='LoadImageFromFile'),
14+
dict(type='Resize', scale=img_scale, keep_ratio=False),
15+
dict(type='LoadAnnotations'),
16+
dict(type='PackSegInputs')
17+
]
18+
train_dataloader = dict(
19+
batch_size=16,
20+
num_workers=4,
21+
persistent_workers=True,
22+
sampler=dict(type='InfiniteSampler', shuffle=True),
23+
dataset=dict(
24+
type=dataset_type,
25+
data_root=data_root,
26+
data_prefix=dict(
27+
img_path='images/train/', seg_map_path='masks/train/'),
28+
pipeline=train_pipeline))
29+
val_dataloader = dict(
30+
batch_size=1,
31+
num_workers=4,
32+
persistent_workers=True,
33+
sampler=dict(type='DefaultSampler', shuffle=False),
34+
dataset=dict(
35+
type=dataset_type,
36+
data_root=data_root,
37+
data_prefix=dict(img_path='images/val/', seg_map_path='masks/val/'),
38+
pipeline=test_pipeline))
39+
test_dataloader = val_dataloader
40+
val_evaluator = dict(type='IoUMetric', iou_metrics=['mIoU', 'mDice'])
41+
test_evaluator = dict(type='IoUMetric', iou_metrics=['mIoU', 'mDice'])
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
from mmseg.datasets import BaseSegDataset
2+
from mmseg.registry import DATASETS
3+
4+
5+
@DATASETS.register_module()
6+
class ISIC2017Task1(BaseSegDataset):
7+
"""ISIC2017Task1 dataset.
8+
9+
In segmentation map annotation for ISIC2017Task1,
10+
``reduce_zero_label`` is fixed to False. The ``img_suffix``
11+
is fixed to '.png' and ``seg_map_suffix`` is fixed to '.png'.
12+
13+
Args:
14+
img_suffix (str): Suffix of images. Default: '.png'
15+
seg_map_suffix (str): Suffix of segmentation maps. Default: '.png'
16+
reduce_zero_label (bool): Whether to mark label zero as ignored.
17+
Default to False.
18+
"""
19+
METAINFO = dict(classes=('normal', 'skin lesion'))
20+
21+
def __init__(self,
22+
img_suffix='.png',
23+
seg_map_suffix='.png',
24+
reduce_zero_label=False,
25+
**kwargs) -> None:
26+
super().__init__(
27+
img_suffix=img_suffix,
28+
seg_map_suffix=seg_map_suffix,
29+
reduce_zero_label=reduce_zero_label,
30+
**kwargs)

0 commit comments

Comments
 (0)