Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CodeCamp #139 [Feature] Support REFUGE dataset. #2420

Closed
wants to merge 71 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
71 commits
Select commit Hold shift + click to select a range
f2b8d2f
doc
BLUE-coconut Nov 30, 2022
67b51b7
[Doc]Translate the 1_config.md and modify a wrong statement in 1_conf…
pofengdenihong Dec 2, 2022
4287fd2
Translate the 1_config.md and modify a wrong statement in 1_config.md
pofengdenihong Dec 2, 2022
5668182
modify part of content
BLUE-coconut Dec 3, 2022
ad470a3
Modify some expressions
pofengdenihong Dec 5, 2022
104a24d
changed parts of content
BLUE-coconut Dec 5, 2022
cc6a175
add code for convert refuge datasets
liuruiqiang Dec 5, 2022
b0e57c6
Apply suggestions from code review
MeowZheng Dec 6, 2022
9750c97
Merge pull request #2371 from pofengdenihong/dev-1.x
MeowZheng Dec 6, 2022
8a3d6cd
[Doc] Add ZN datasets.md in dev-1.x
MengzhangLI Dec 6, 2022
dc2c986
add refuge dataset in datasets
liuruiqiang Dec 6, 2022
3d1f8b7
modified
BLUE-coconut Dec 7, 2022
bdf85d8
add REFUGEdATASET in __init__.py
liuruiqiang Dec 7, 2022
addd38d
fix typo
MengzhangLI Dec 7, 2022
372a6ce
Update docs/zh_cn/user_guides/4_train_test.md
BLUE-coconut Dec 7, 2022
07462c3
delete redundant code
liuruiqiang Dec 7, 2022
dc8aa35
CodeCamp #1562 [Doc] update `overview.md`
tianleiSHI Dec 10, 2022
dddf093
Update overview.md
tianleiSHI Dec 10, 2022
44577d4
add refuge config
liuruiqiang Dec 10, 2022
5a96573
add new change for training
liuruiqiang Dec 11, 2022
ed1195a
fix bugs in config
liuruiqiang Dec 11, 2022
d179b87
fix config
liuruiqiang Dec 11, 2022
5383ea6
add init code for transforms
liuruiqiang Dec 11, 2022
e11c76f
debug
liuruiqiang Dec 12, 2022
7edb141
Merge pull request #2355 from BLUE-coconut/master
MeowZheng Dec 12, 2022
b770884
Add torch1.13 in CI
xiexinch Dec 12, 2022
02030b1
use mim install mm packages
xiexinch Dec 12, 2022
d755707
Update docs/zh_cn/overview.md
tianleiSHI Dec 12, 2022
c2042f3
Update docs/zh_cn/overview.md
tianleiSHI Dec 12, 2022
fdd1b95
install all requirements
xiexinch Dec 12, 2022
7537987
Merge pull request #2397 from tianleiSHI/dev-1.x
MeowZheng Dec 12, 2022
e2e70c3
add flip transforms
liuruiqiang Dec 12, 2022
492313b
install wheel
xiexinch Dec 13, 2022
815b24e
add ref
xiexinch Dec 13, 2022
d7b85aa
Merge pull request #2402 from xiexinch/add-torch1.13-in-ci-1.x
MeowZheng Dec 13, 2022
164fd3f
fix
MengzhangLI Dec 13, 2022
e88489e
fix
MengzhangLI Dec 13, 2022
eeee12e
Merge pull request #2387 from MengzhangLI/zn_datasets_1.x
MeowZheng Dec 13, 2022
f5b4c12
add example project
xiexinch Dec 15, 2022
81da7aa
add ci ignore
xiexinch Dec 15, 2022
69048c2
fix transforms
liuruiqiang Dec 15, 2022
adceec3
fix transforms
liuruiqiang Dec 15, 2022
532ff5b
DOC
tianleiSHI Dec 17, 2022
88945e3
train successfully
liuruiqiang Dec 18, 2022
0d59440
train successfully
liuruiqiang Dec 19, 2022
0631053
check code
liuruiqiang Dec 19, 2022
107e964
add revised code
liuruiqiang Dec 19, 2022
ab690bd
Update docs/zh_cn/get_started.md
tianleiSHI Dec 20, 2022
ca68b00
Merge pull request #2417 from tianleiSHI/get_started_doc
MeowZheng Dec 20, 2022
0529df3
fix confilcts in transforms
liuruiqiang Dec 20, 2022
534b27b
add version limits
xiexinch Dec 20, 2022
8539e22
Merge pull request #2412 from xiexinch/mmseg_projects
MeowZheng Dec 20, 2022
d6bf98c
XMerge branch 'dev-1.x' of github.com:liuruiqiang/mmsegmentation into…
MengzhangLI Dec 20, 2022
b667b60
fix code for converting data again and add notes in dataset_converter…
liuruiqiang Dec 21, 2022
6f90a93
fix code for converting data again and add notes in dataset_converter…
liuruiqiang Dec 21, 2022
2846e5a
Merge branch 'dev-1.x' of github.com:liuruiqiang/mmsegmentation into …
MengzhangLI Dec 23, 2022
df45c11
delete background in REFUGEDataset for training
liuruiqiang Dec 27, 2022
680d5e7
delete unnecessary code
liuruiqiang Dec 27, 2022
f1e74dd
Merge branch 'dev-1.x' of github.com:liuruiqiang/mmsegmentation into …
MengzhangLI Jan 5, 2023
882ceae
resolve conflicts & fix pre-commit problem
MengzhangLI Jan 5, 2023
5af7bd9
resolve conflicts
liuruiqiang Jan 6, 2023
d968cbc
Merge branch 'dev-1.x' of github.com:open-mmlab/mmsegmentation into r…
liuruiqiang Jan 6, 2023
62258f4
resolve conflicts
liuruiqiang Jan 6, 2023
b368bdd
refine refuge pr
MengzhangLI Jan 9, 2023
87c8a8d
add ut
MengzhangLI Jan 9, 2023
385a481
Merge branch 'dev-1.x' of github.com:open-mmlab/mmsegmentation into r…
liuruiqiang Jan 9, 2023
6790131
Merge branch 'dev-1.x' of github.com:liuruiqiang/mmsegmentation into …
liuruiqiang Jan 12, 2023
1cc2209
resolve conflicts
liuruiqiang Jan 12, 2023
45a8e34
update upstream dev-1.x & use smaller dataset example in ut
MengzhangLI Jan 16, 2023
fc584cd
update upstream dev-1.x & use smaller dataset example in ut
MengzhangLI Jan 16, 2023
1c16532
fix doc
MengzhangLI Feb 1, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
resolve conflicts
  • Loading branch information
liuruiqiang committed Jan 6, 2023
commit 5af7bd990c7e15ffbbaadb95326df44998f5554c
13 changes: 5 additions & 8 deletions .github/workflows/merge_stage_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,6 @@ jobs:
run: |
pip install pip --upgrade
pip install wheel
- name: Install Pillow
run: pip install Pillow==6.2.2
if: ${{matrix.torchvision == '0.4.2'}}
- name: Install PyTorch
run: pip install torch==${{matrix.torch}}+cpu torchvision==${{matrix.torchvision}}+cpu -f https://download.pytorch.org/whl/torch_stable.html
- name: Install mmseg dependencies
Expand All @@ -65,7 +62,8 @@ jobs:
strategy:
matrix:
python-version: [3.7]
torch: [1.6.0, 1.7.1, 1.8.1, 1.9.1, 1.10.1, 1.11.0, 1.12.1, 1.13.0]
torch: [1.6.0, 1.7.1, 1.8.1, 1.9.1, 1.10.1, 1.11.0, 1.12.0]
# torch: [1.6.0, 1.7.1, 1.8.1, 1.9.1, 1.10.1, 1.11.0, 1.12.0, 1.13.0]
include:
- torch: 1.6.0
torchvision: 0.7.0
Expand All @@ -79,10 +77,10 @@ jobs:
torchvision: 0.11.2
- torch: 1.11.0
torchvision: 0.12.0
- torch: 1.12.1
- torch: 1.12.0
torchvision: 0.13.0
- torch: 1.13.0
torchvision:
# - torch: 1.13.0
# torchvision: 0.14.0
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
Expand Down Expand Up @@ -160,7 +158,6 @@ jobs:
apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/machine-learning/repos/ubuntu1804/x86_64/7fa2af80.pub
- name: Install Python-dev
run: apt-get update && apt-get install -y python${{matrix.python-version}}-dev
if: ${{matrix.python-version != 3.9}}
- name: Install system dependencies
run: |
apt-get update && apt-get install -y ffmpeg libsm6 libxext6 git ninja-build libglib2.0-0 libsm6 libxrender-dev libxext6
Expand Down
2 changes: 1 addition & 1 deletion docs/zh_cn/advanced_guides/datasets.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# 数据集
# 数据集

在 MMSegmentation 算法库中, 所有 Dataset 类的功能有两个: 加载[预处理](https://github.com/open-mmlab/mmsegmentation/blob/dev-1.x/docs/en/user_guides/2_dataset_prepare.md) 之后的数据集的信息, 和将数据送入[数据集变换流水线](https://github.com/open-mmlab/mmsegmentation/blob/dev-1.x/mmseg/datasets/basesegdataset.py#L141) 中, 进行[数据变换操作](https://github.com/open-mmlab/mmsegmentation/blob/dev-1.x/docs/zh_cn/advanced_guides/transforms.md). 加载的数据集信息包括两类: 元信息 (meta information), 数据集本身的信息, 例如数据集总共的类别, 和它们对应调色盘信息: 数据信息 (data information) 是指每组数据中图片和对应标签的路径. 下文中介绍了 MMSegmentation 1.x 中数据集的常用接口, 和 mmseg 数据集基类中数据信息加载与修改数据集类别的逻辑, 以及数据集与数据变换流水线 (pipeline) 的关系.

Expand Down
26 changes: 14 additions & 12 deletions mmseg/datasets/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
from .decathlon import DecathlonDataset
from .drive import DRIVEDataset
from .hrf import HRFDataset
from .refuge import REFUGEDataset
from .isaid import iSAIDDataset
from .isprs import ISPRSDataset
from .lip import LIPDataset
Expand All @@ -28,20 +27,23 @@
PackSegInputs, PhotoMetricDistortion, RandomCrop,
RandomCutOut, RandomMosaic, RandomRotate, Rerange,
ResizeShortestEdge, ResizeToMultiple, RGB2Gray,
SegRescale,Rot90,ColorJitter,RandomFlipud,RandomFliplr)
SegRescale)
from .voc import PascalVOCDataset

# yapf: enable
__all__ = [
'BaseSegDataset', 'CityscapesDataset', 'PascalVOCDataset', 'ADE20KDataset',
'PascalContextDataset', 'PascalContextDataset59', 'ChaseDB1Dataset',
'DRIVEDataset', 'HRFDataset', 'STAREDataset', 'DarkZurichDataset',
'NightDrivingDataset', 'COCOStuffDataset', 'LoveDADataset',
'MultiImageMixDataset', 'iSAIDDataset', 'ISPRSDataset', 'PotsdamDataset',
'LoadAnnotations', 'RandomCrop', 'SegRescale', 'PhotoMetricDistortion',
'RandomRotate', 'AdjustGamma', 'CLAHE', 'Rerange', 'RGB2Gray','ColorJitter',
'RandomCutOut', 'RandomMosaic', 'PackSegInputs', 'ResizeToMultiple',
'LoadImageFromNDArray', 'LoadBiomedicalImageFromFile','Rot90','RandomFlipud','RandomFliplr',
'BaseSegDataset', 'BioMedical3DRandomCrop', 'CityscapesDataset',
'PascalVOCDataset', 'ADE20KDataset', 'PascalContextDataset',
'PascalContextDataset59', 'ChaseDB1Dataset', 'DRIVEDataset', 'HRFDataset',
'STAREDataset', 'DarkZurichDataset', 'NightDrivingDataset',
'COCOStuffDataset', 'LoveDADataset', 'MultiImageMixDataset',
'iSAIDDataset', 'ISPRSDataset', 'PotsdamDataset', 'LoadAnnotations',
'RandomCrop', 'SegRescale', 'PhotoMetricDistortion', 'RandomRotate',
'AdjustGamma', 'CLAHE', 'Rerange', 'RGB2Gray', 'RandomCutOut',
'RandomMosaic', 'PackSegInputs', 'ResizeToMultiple',
'LoadImageFromNDArray', 'LoadBiomedicalImageFromFile',
'LoadBiomedicalAnnotation', 'LoadBiomedicalData', 'GenerateEdge',
'DecathlonDataset', 'LIPDataset', 'ResizeShortestEdge','REFUGEDataset'
'DecathlonDataset', 'LIPDataset', 'ResizeShortestEdge',
'BioMedicalGaussianNoise', 'BioMedicalGaussianBlur',
'BioMedicalRandomGamma'
]
5 changes: 3 additions & 2 deletions mmseg/datasets/transforms/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
PhotoMetricDistortion, RandomCrop, RandomCutOut,
RandomMosaic, RandomRotate, Rerange,
ResizeShortestEdge, ResizeToMultiple, RGB2Gray,
SegRescale,Rot90,ColorJitter,RandomFlipud,RandomFliplr)
SegRescale)

# yapf: enable
__all__ = [
Expand All @@ -19,5 +19,6 @@
'RGB2Gray', 'RandomCutOut', 'RandomMosaic', 'PackSegInputs',
'ResizeToMultiple', 'LoadImageFromNDArray', 'LoadBiomedicalImageFromFile',
'LoadBiomedicalAnnotation', 'LoadBiomedicalData', 'GenerateEdge',
'ResizeShortestEdge','Rot90','ColorJitter','RandomFliplr','RandomFlipud'
'ResizeShortestEdge', 'BioMedicalGaussianNoise', 'BioMedicalGaussianBlur',
'BioMedicalRandomGamma'
]
212 changes: 2 additions & 210 deletions mmseg/datasets/transforms/transforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,15 @@
import copy
import warnings
from typing import Dict, Sequence, Tuple, Union
from PIL import Image

import cv2
import mmcv
import numpy as np
from mmcv.transforms.base import BaseTransform
from mmcv.transforms.utils import cache_randomness
from mmengine.utils import is_tuple_of
from numpy import random
from torchvision import transforms
import imgaug.augmenters as iaa
import imgaug as ia
from scipy.ndimage import gaussian_filter

from mmseg.datasets.dataset_wrappers import MultiImageMixDataset
from mmseg.registry import TRANSFORMS
Expand Down Expand Up @@ -86,212 +84,6 @@ def __repr__(self):
return repr_str


@TRANSFORMS.register_module()
class Rot90(BaseTransform):
"""rotate img and gt with 90,180 or 270 degree.

Required Keys:

- img
- gt_seg_map

Modified Keys:
- img
- seg_fields

Args:
degree_range (tuple): degree range for rotate.

"""

def __init__(self, degree_range: tuple):
self.degree_range = degree_range
# self.interpolation = interpolation
self.rot90 = iaa.Rot90(degree_range)

def transform(self, results: dict) -> dict:
"""rotate img and gt with 90,180 or 270 degree.
Args:
results (dict): Result dict from loading pipeline.

Returns:
dict: Rotated results.
"""
# Align image to multiple of size divisor.
img = results['img']

gt_segs = []
# Align segmentation map to multiple of size divisor.
for key in results.get('seg_fields', []):
gt_segs.append(results[key])
imgs = [img]+gt_segs
roted_imgs = self.rot90.augment_images(imgs)
results['img'] = roted_imgs[0].astype(np.float32)
for i,key in enumerate(results.get('seg_fields', [])):
results[key] = roted_imgs[i+1].astype(np.float32)

return results

def __repr__(self):
repr_str = self.__class__.__name__
repr_str += (f'(degree_range={self.degree_range})')
return repr_str


@TRANSFORMS.register_module()
class RandomFliplr(BaseTransform):
"""flip img and gt Horizontally.

Required Keys:

- img
- gt_seg_map

Modified Keys:
- img
- seg_fields

Args:
prob (float): probability for flip Horizontally.

"""

def __init__(self, prob: float):
self.prob = prob
self.fliplr = iaa.Fliplr(prob)

def transform(self, results: dict) -> dict:
"""flip img and gt Horizontally.
Args:
results (dict): Result dict from loading pipeline.

Returns:
dict: Flipped results.
"""
img = results['img']

gt_segs = []

for key in results.get('seg_fields', []):
gt_segs.append(results[key])
imgs = [img] + gt_segs
flipped_imgs = self.fliplr.augment_images(imgs)
results['img'] = flipped_imgs[0].astype(np.float32)
for i, key in enumerate(results.get('seg_fields', [])):
results[key] = flipped_imgs[i + 1].astype(np.float32)

return results

def __repr__(self):
repr_str = self.__class__.__name__
repr_str += (f'(prob={self.prob})')
return repr_str

@TRANSFORMS.register_module()
class RandomFlipud(BaseTransform):
"""flip img and gt vertivally.

Required Keys:

- img
- gt_seg_map

Modified Keys:
- img
- seg_fields

Args:
prob (float): probability for flip vertivally.

"""

def __init__(self, prob: float):
self.prob = prob
self.flipud = iaa.Flipud(prob)

def transform(self, results: dict) -> dict:
"""flip img and gt Horizontally.
Args:
results (dict): Result dict from loading pipeline.

Returns:
dict: Flipped results.
"""
img = results['img']

gt_segs = []

for key in results.get('seg_fields', []):
gt_segs.append(results[key])
imgs = [img] + gt_segs
flipped_imgs = self.flipud.augment_images(imgs)
results['img'] = flipped_imgs[0].astype(np.float32)
for i, key in enumerate(results.get('seg_fields', [])):
results[key] = flipped_imgs[i + 1].astype(np.float32)

return results

def __repr__(self):
repr_str = self.__class__.__name__
repr_str += (f'(prob={self.prob})')
return repr_str


@TRANSFORMS.register_module()
class ColorJitter(BaseTransform):
"""transform img's brightness,contrast,saturation and hue.

Required Keys:
- img

Modified Keys:
- img
Args:
brightness (float): brightness.
contrast (float): contrast.
saturation (float): saturation.
hue (float): hue.

"""

def __init__(self, brightness: float=None,contrast: float=None,saturation: float=None,hue: float=None):
self.brightness = brightness
self.contrast = contrast
self.saturation = saturation
self.hue = hue
color_params = ['brightness','contrast','saturation','hue']
self.color_params = {}
for param in color_params:
if eval(param) is not None:
self.color_params.update({param:eval(param)})
self.color_jitter = transforms.ColorJitter(**self.color_params)

def transform(self, results: dict) -> dict:
"""transform img's brightness,contrast,saturation and hue .
Args:
results (dict): Result dict from loading pipeline.

Returns:
dict: transformed results.
"""

img = results['img']
img = Image.fromarray(np.uint8(img))
aug_img = self.color_jitter(img)
results['img'] = np.array(aug_img,dtype=np.float32)

return results

def __repr__(self):
repr_str = self.__class__.__name__
repr_str += (f'(brightness={self.brightness},'
f'contrast={self.contrast},'
f'saturation={self.saturation},'
f'hue={self.hue})')
return repr_str



@TRANSFORMS.register_module()
class Rerange(BaseTransform):
"""Rerange the image pixel value.
Expand Down
You are viewing a condensed version of this merge commit. You can view the full changes here.