-
Notifications
You must be signed in to change notification settings - Fork 446
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add supcon seg for regression (#2177)
* Fix iseg e2e (#2173) * Add supcon seg for regression * Fix det e2e (#2176) * Fix det e2e * Fix mypy * Fix precommit * Update otx/algorithms/segmentation/configs/ocr_lite_hrnet_18/supcon/__init__.py * Update otx/algorithms/segmentation/configs/ocr_lite_hrnet_18/supcon/model.py --------- Co-authored-by: Jaeguk Hyun <[email protected]>
- Loading branch information
1 parent
d506b00
commit 85ce846
Showing
6 changed files
with
226 additions
and
0 deletions.
There are no files selected for viewing
15 changes: 15 additions & 0 deletions
15
otx/algorithms/segmentation/configs/ocr_lite_hrnet_18/supcon/__init__.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
"""Initialization of OCR-Lite-HRnet-18 model for SupCon Segmentation Task.""" | ||
|
||
# Copyright (C) 2022 Intel Corporation | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, | ||
# software distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions | ||
# and limitations under the License. |
18 changes: 18 additions & 0 deletions
18
otx/algorithms/segmentation/configs/ocr_lite_hrnet_18/supcon/data_pipeline.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
"""Data Pipeline of HR-Net model for Segmentation Task.""" | ||
|
||
# Copyright (C) 2023 Intel Corporation | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, | ||
# software distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions | ||
# and limitations under the License. | ||
|
||
# pylint: disable=invalid-name | ||
_base_ = ["../../base/data/supcon/data_pipeline.py"] |
8 changes: 8 additions & 0 deletions
8
otx/algorithms/segmentation/configs/ocr_lite_hrnet_18/supcon/hparam.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# Hyperparameters. | ||
hyper_parameters: | ||
parameter_overrides: | ||
learning_parameters: | ||
enable_supcon: | ||
default_value: True | ||
learning_rate_warmup_iters: | ||
default_value: 50 |
85 changes: 85 additions & 0 deletions
85
otx/algorithms/segmentation/configs/ocr_lite_hrnet_18/supcon/model.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
"""Model configuration of OCR-Lite-HRnet-18 model for SupCon Segmentation Task.""" | ||
|
||
|
||
# Copyright (C) 2022 Intel Corporation | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, | ||
# software distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions | ||
# and limitations under the License. | ||
|
||
# pylint: disable=invalid-name | ||
|
||
_base_ = [ | ||
"../../../../../recipes/stages/segmentation/supcon.py", | ||
"../../../../common/adapters/mmcv/configs/backbones/lite_hrnet_18.py", | ||
] | ||
|
||
model = dict( | ||
type="SupConDetConB", | ||
pretrained=( | ||
"https://storage.openvinotoolkit.org/repositories/" | ||
"openvino_training_extensions/models/custom_semantic_segmentation/" | ||
"litehrnet18_imagenet1k_rsc.pth" | ||
), | ||
num_classes=256, | ||
num_samples=16, | ||
downsample=4, | ||
input_transform="resize_concat", | ||
in_index=[0, 1, 2, 3], | ||
neck=dict( | ||
type="SelfSLMLP", | ||
in_channels=600, | ||
hid_channels=256, | ||
out_channels=128, | ||
norm_cfg=dict(type="BN1d", requires_grad=True), | ||
with_avg_pool=False, | ||
), | ||
head=dict( | ||
type="DetConHead", | ||
predictor=dict( | ||
type="SelfSLMLP", | ||
in_channels=128, | ||
hid_channels=256, | ||
out_channels=128, | ||
norm_cfg=dict(type="BN1d", requires_grad=True), | ||
with_avg_pool=False, | ||
), | ||
loss_cfg=dict(type="DetConLoss", temperature=0.1), | ||
), | ||
decode_head=dict( | ||
type="FCNHead", | ||
in_channels=[40, 80, 160, 320], | ||
in_index=[0, 1, 2, 3], | ||
input_transform="multiple_select", | ||
channels=40, | ||
kernel_size=1, | ||
num_convs=1, | ||
concat_input=False, | ||
dropout_ratio=-1, | ||
num_classes=2, | ||
norm_cfg=dict(type="BN", requires_grad=True), | ||
align_corners=False, | ||
enable_aggregator=True, | ||
loss_decode=[ | ||
dict( | ||
type="CrossEntropyLoss", | ||
use_sigmoid=False, | ||
loss_weight=1.0, | ||
), | ||
], | ||
), | ||
) | ||
|
||
load_from = None | ||
|
||
resume_from = None | ||
|
||
fp16 = dict(loss_scale=512.0) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters