Skip to content

Commit

Permalink
Merge pull request #21 from supervisely-ecosystem/dev-mmseg0.23.0
Browse files Browse the repository at this point in the history
Features:

- Augmentation configs updated
- Supported 3 new models from mmsegmentation 0.22.0 and 0.23.0 (K-Net, BEiT, ConvNeXt)
- You can change parameters from any steps if training failed and you can start new training
- Many little fixes
  • Loading branch information
arzamnik authored Apr 11, 2022
2 parents 8998ea8 + dae490e commit d17f4ee
Show file tree
Hide file tree
Showing 31 changed files with 951 additions and 769 deletions.
12 changes: 10 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
configs
data
.idea
cache
.vscode

train/secret_debug.env
serve/secret_debug.env
configs

serve/.DS_Store
train/.DS_Store
train/src/.DS_Store
.DS_Store
.idea/

serve/src/__pycache__
train/src/__pycache__
train/src/ui/__pycache__
37 changes: 28 additions & 9 deletions models/model_meta.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,25 @@
[
{
"model_name" : "SegFormer",
"model_name" : "ConvNeXt",
"yml_file" : "convnext/convnext.yml",
"paper_from": "CVPR",
"year": 2022
},
{
"model_name" : "BEiT",
"yml_file" : "beit/beit.yml",
"paper_from": "ICLR",
"year": 2022
},

{
"model_name" : "KNet",
"yml_file" : "knet/knet.yml",
"paper_from": "NeurIPS",
"year": 2021
},
{
"model_name" : "Segformer",
"yml_file" : "segformer/segformer.yml",
"paper_from": "NeurIPS",
"year": 2021
Expand Down Expand Up @@ -90,7 +109,7 @@
"year": 2019
},
{
"model_name" : "Fast-SCNN",
"model_name" : "FastSCNN",
"yml_file" : "fastscnn/fastscnn.yml",
"paper_from": "ArXiv",
"year": 2019
Expand Down Expand Up @@ -168,7 +187,7 @@
"year": 2018
},
{
"model_name" : "Non-local Net",
"model_name" : "NonLocalNet",
"yml_file" : "nonlocal_net/nonlocal_net.yml",
"paper_from": "CVPR",
"year": 2018
Expand Down Expand Up @@ -221,18 +240,18 @@
"paper_from": "CVPR",
"year": 2017
},
{
"model_name" : "UNet",
"yml_file" : "unet/unet.yml",
"paper_from": "MICCAI",
"year": 2016
},
{
"model_name" : "ERFNet",
"yml_file" : "erfnet/erfnet.yml",
"paper_from": "T-ITS",
"year": 2017
},
{
"model_name" : "UNet",
"yml_file" : "unet/unet.yml",
"paper_from": "MICCAI",
"year": 2016
},
{
"model_name" : "FCN",
"yml_file" : "fcn/fcn.yml",
Expand Down
2 changes: 0 additions & 2 deletions requirements.txt

This file was deleted.

3 changes: 3 additions & 0 deletions serve/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ Supported backbones:
- [x] [Vision Transformer (ICLR'2021)](https://github.com/open-mmlab/mmsegmentation/tree/master/configs/vit)
- [x] [Swin Transformer (ICCV'2021)](https://github.com/open-mmlab/mmsegmentation/tree/master/configs/swin)
- [x] [Twins (NeurIPS'2021)](https://github.com/open-mmlab/mmsegmentation/tree/master/configs/twins)
- [x] [BEiT (ICLR'2022)](https://github.com/open-mmlab/mmsegmentation/blob/master/configs/beit)
- [x] [ConvNeXt (CVPR'2022)](https://github.com/open-mmlab/mmsegmentation/blob/master/configs/convnext)

Supported methods:

Expand Down Expand Up @@ -80,6 +82,7 @@ Supported methods:
- [x] [DPT (ArXiv'2021)](https://github.com/open-mmlab/mmsegmentation/tree/master/configs/dpt)
- [x] [Segmenter (ICCV'2021)](https://github.com/open-mmlab/mmsegmentation/tree/master/configs/segmenter)
- [x] [SegFormer (NeurIPS'2021)](https://github.com/open-mmlab/mmsegmentation/tree/master/configs/segformer)
- [x] [K-Net (NeurIPS'2021)](https://github.com/open-mmlab/mmsegmentation/blob/master/configs/knet)


# How to Run
Expand Down
2 changes: 1 addition & 1 deletion serve/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"semantic segmentation"
],
"description": "Deploy model as REST API service",
"docker_image": "supervisely/mmseg:1.1.0",
"docker_image": "supervisely/mmseg:1.3.0",
"main_script": "serve/src/sly_serve.py",
"gui_template": "serve/src/gui.html",
"task_location": "application_sessions",
Expand Down
15 changes: 0 additions & 15 deletions serve/src/gui.html
Original file line number Diff line number Diff line change
Expand Up @@ -48,24 +48,9 @@
</el-option>
</el-select>
<span><a :href="data.configLinks[state.pretrainedModel]" target="_blank">Learn more...</a></span>
<!--
<sly-field title="Code"
style="padding-top: 0; padding-bottom: 0; margin: 10px 5px;">
<sly-icon slot="icon" :options="data.github_icon"></sly-icon>
<span><a :href="data.pretrainedModels[state.pretrainedModel]['code_url']" target="_blank">{{state.pretrainedModel}}</a></span>
</sly-field>
<sly-field title="Paper"
style="padding-top: 0; padding-bottom: 0; margin: 10px 5px;">
<sly-icon slot="icon" :options="data.arxiv_icon"></sly-icon>
<span><a :href="data.pretrainedModels[state.pretrainedModel]['paper_url']" target="_blank">{{data.pretrainedModels[state.pretrainedModel]['paper_title']}}</a></span>
</sly-field>
-->
</div>
<div>
<div class="mb10">Pretrained model:</div>
<!-- <div style="font-size: 11px;color: #848484;" class="mb10">See more details in <a :href="data.pretrainedModels[state.pretrainedModel]['config_url']" target="_blank">model config files</a>. </div> -->
<table class="beautiful-table">
<thead>
<tr>
Expand Down
14 changes: 1 addition & 13 deletions serve/src/sly_serve.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ def init_model(api: sly.Api, task_id, context, state, app_logger):


def init_state_and_data(data, state):
state['pretrainedModel'] = 'SegFormer'
state['pretrainedModel'] = 'ConvNeXt'
data["pretrainedModels"], metrics = utils.get_pretrained_models(return_metrics=True)
model_select_info = []
for model_name, params in data["pretrainedModels"].items():
Expand All @@ -139,18 +139,6 @@ def init_state_and_data(data, state):
state["weightsPath"] = ""
state["loading"] = False
state["deployed"] = False
'''
data["github_icon"] = {
"imageUrl": "https://github.githubassets.com/favicons/favicon.png",
"rounded": False,
"bgColor": "rgba(0,0,0,0)"
}
data["arxiv_icon"] = {
"imageUrl": "https://static.arxiv.org/static/browse/0.3.2.8/images/icons/favicon.ico",
"rounded": False,
"bgColor": "rgba(0,0,0,0)"
}
'''


def main():
Expand Down
9 changes: 4 additions & 5 deletions serve/src/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,6 @@ def get_pretrained_models(return_metrics=False):
with open(os.path.join(g.configs_dir, model_meta["yml_file"]), "r") as stream:
model_info = yaml.safe_load(stream)
model_config[model_meta["model_name"]] = {}
# model_config[model_meta["model_name"]]["code_url"] = model_info["Collections"][0]["Code"]["URL"]
# model_config[model_meta["model_name"]]["paper_title"] = model_info["Collections"][0]["Paper"]["Title"]
# model_config[model_meta["model_name"]]["paper_url"] = model_info["Collections"][0]["Paper"]["URL"]
model_config[model_meta["model_name"]]["checkpoints"] = []
model_config[model_meta["model_name"]]["paper_from"] = model_meta["paper_from"]
model_config[model_meta["model_name"]]["year"] = model_meta["year"]
Expand All @@ -64,6 +61,7 @@ def get_pretrained_models(return_metrics=False):
for model in model_info["Models"]:
checkpoint_info = {}
checkpoint_info["name"] = model["Name"]
checkpoint_info["method"] = model["In Collection"]
checkpoint_info["backbone"] = model["Metadata"]["backbone"]
try:
checkpoint_info["inference_time"] = model["Metadata"]["inference time (ms/im)"][0]["value"]
Expand Down Expand Up @@ -95,14 +93,15 @@ def get_table_columns(metrics):
columns = [
{"key": "name", "title": " ", "subtitle": None},
{"key": "backbone", "title": "Backbone", "subtitle": None},
{"key": "method", "title": "Method", "subtitle": None},
{"key": "dataset", "title": "Dataset", "subtitle": None},
{"key": "inference_time", "title": "Inference time", "subtitle": "(ms/im)"},
{"key": "crop_size", "title": "Input size", "subtitle": "(H, W)"},
{"key": "lr_schd", "title": "LR scheduler", "subtitle": "steps"},
{"key": "training_memory", "title": "Training memory", "subtitle": "GB"},
{"key": "training_memory", "title": "Memory", "subtitle": "Training (GB)"},
]
for metric in metrics:
columns.append({"key": metric, "title": f"{metric} score", "subtitle": None})
columns.append({"key": metric, "title": metric, "subtitle": "score"})
return columns


Expand Down
3 changes: 3 additions & 0 deletions train/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ Supported backbones:
- [x] [Vision Transformer (ICLR'2021)](https://github.com/open-mmlab/mmsegmentation/tree/master/configs/vit)
- [x] [Swin Transformer (ICCV'2021)](https://github.com/open-mmlab/mmsegmentation/tree/master/configs/swin)
- [x] [Twins (NeurIPS'2021)](https://github.com/open-mmlab/mmsegmentation/tree/master/configs/twins)
- [x] [BEiT (ICLR'2022)](https://github.com/open-mmlab/mmsegmentation/blob/master/configs/beit)
- [x] [ConvNeXt (CVPR'2022)](https://github.com/open-mmlab/mmsegmentation/blob/master/configs/convnext)

Supported methods:

Expand Down Expand Up @@ -86,6 +88,7 @@ Supported methods:
- [x] [DPT (ArXiv'2021)](https://github.com/open-mmlab/mmsegmentation/tree/master/configs/dpt)
- [x] [Segmenter (ICCV'2021)](https://github.com/open-mmlab/mmsegmentation/tree/master/configs/segmenter)
- [x] [SegFormer (NeurIPS'2021)](https://github.com/open-mmlab/mmsegmentation/tree/master/configs/segformer)
- [x] [K-Net (NeurIPS'2021)](https://github.com/open-mmlab/mmsegmentation/blob/master/configs/knet)


# How to Run
Expand Down
99 changes: 99 additions & 0 deletions train/augs/hard.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
{
"pipeline": [
{
"category": "color",
"name": "MultiplyAndAddToBrightness",
"params": {
"mul": [
0.5,
1.5
],
"add": [
-80,
80
],
"to_colorspace": "YCrCb",
"from_colorspace": "RGB",
"random_order": true
},
"sometimes": 0.5,
"python": "iaa.Sometimes(0.5, iaa.color.MultiplyAndAddToBrightness(mul=(0.5, 1.5), add=(-80, 80), to_colorspace='YCrCb', from_colorspace='RGB', random_order=True))"
},
{
"category": "contrast",
"name": "GammaContrast",
"params": {
"gamma": [
0.5,
2.0
],
"per_channel": true
},
"sometimes": 0.5,
"python": "iaa.Sometimes(0.5, iaa.contrast.GammaContrast(gamma=(0.5, 2.0), per_channel=True))"
},
{
"category": "geometric",
"name": "Affine",
"params": {
"scale": [
0.6,
1.6
],
"translate_percent": {
"x": [-0.3, 0.3],
"y": [-0.3, 0.3]
},
"rotate": [
-90,
90
],
"shear": {
"x": [-45, 45],
"y": [-45, 45]
},
"order": 1,
"cval": 0,
"mode": "constant",
"fit_output": false
},
"sometimes": 0.7,
"python": "iaa.Sometimes(0.7, iaa.geometric.Affine(scale=(0.6, 1.6), translate_percent={'x': (-0.3, 0.3), 'y': (-0.3, 0.3)}, rotate=(-90, 90), shear={'x': (-45, 45), 'y': (-45, 45)}, order=1, cval=0, mode='constant', fit_output=False))"
},
{
"category": "size",
"name": "CropAndPad",
"params": {
"percent": [
-0.3,
0.3
],
"pad_mode": "constant",
"pad_cval": 0,
"keep_size": false,
"sample_independently": true
},
"sometimes": 0.4,
"python": "iaa.Sometimes(0.4, iaa.size.CropAndPad(percent=(-0.3, 0.3), pad_mode='constant', pad_cval=0, keep_size=False, sample_independently=True))"
},
{
"category": "flip",
"name": "Fliplr",
"params": {
"p": 1.0
},
"sometimes": 0.5,
"python": "iaa.Sometimes(0.5, iaa.flip.Fliplr(p=1.0))"
},
{
"category": "flip",
"name": "Flipud",
"params": {
"p": 1.0
},
"sometimes": 0.5,
"python": "iaa.Sometimes(0.5, iaa.flip.Flipud(p=1.0))"
}
],
"random_order": false
}
Loading

0 comments on commit d17f4ee

Please sign in to comment.