"...git@developer.sourcefind.cn:chenpangpang/transformers.git" did not exist on "40cfc355f145fdb1c0fef3281d0861b3b849028e"
Unverified Commit 96ae92be authored by NielsRogge's avatar NielsRogge Committed by GitHub
Browse files

[SegFormer] Add deprecation warning (#15889)



* Add deprecation warning

* Remove from docs and hide in kwargs

* Improve implementation
Co-authored-by: default avatarNiels Rogge <nielsrogge@Nielss-MacBook-Pro.local>
parent 8fd47310
...@@ -14,6 +14,8 @@ ...@@ -14,6 +14,8 @@
# limitations under the License. # limitations under the License.
""" SegFormer model configuration""" """ SegFormer model configuration"""
import warnings
from ...configuration_utils import PretrainedConfig from ...configuration_utils import PretrainedConfig
from ...utils import logging from ...utils import logging
...@@ -78,9 +80,6 @@ class SegformerConfig(PretrainedConfig): ...@@ -78,9 +80,6 @@ class SegformerConfig(PretrainedConfig):
The epsilon used by the layer normalization layers. The epsilon used by the layer normalization layers.
decoder_hidden_size (`int`, *optional*, defaults to 256): decoder_hidden_size (`int`, *optional*, defaults to 256):
The dimension of the all-MLP decode head. The dimension of the all-MLP decode head.
reshape_last_stage (`bool`, *optional*, defaults to `True`):
Whether to reshape the features of the last stage back to `(batch_size, num_channels, height, width)`. Only
required for the semantic segmentation model.
semantic_loss_ignore_index (`int`, *optional*, defaults to 255): semantic_loss_ignore_index (`int`, *optional*, defaults to 255):
The index that is ignored by the loss function of the semantic segmentation model. The index that is ignored by the loss function of the semantic segmentation model.
...@@ -122,12 +121,18 @@ class SegformerConfig(PretrainedConfig): ...@@ -122,12 +121,18 @@ class SegformerConfig(PretrainedConfig):
layer_norm_eps=1e-6, layer_norm_eps=1e-6,
decoder_hidden_size=256, decoder_hidden_size=256,
is_encoder_decoder=False, is_encoder_decoder=False,
reshape_last_stage=True,
semantic_loss_ignore_index=255, semantic_loss_ignore_index=255,
**kwargs **kwargs
): ):
super().__init__(**kwargs) super().__init__(**kwargs)
if "reshape_last_stage" in kwargs and kwargs["reshape_last_stage"] is False:
warnings.warn(
"Reshape_last_stage is set to False in this config. This argument is deprecated and will soon be removed, "
"as the behaviour will default to that of reshape_last_stage = True.",
FutureWarning,
)
self.image_size = image_size self.image_size = image_size
self.num_channels = num_channels self.num_channels = num_channels
self.num_encoder_blocks = num_encoder_blocks self.num_encoder_blocks = num_encoder_blocks
...@@ -147,5 +152,5 @@ class SegformerConfig(PretrainedConfig): ...@@ -147,5 +152,5 @@ class SegformerConfig(PretrainedConfig):
self.drop_path_rate = drop_path_rate self.drop_path_rate = drop_path_rate
self.layer_norm_eps = layer_norm_eps self.layer_norm_eps = layer_norm_eps
self.decoder_hidden_size = decoder_hidden_size self.decoder_hidden_size = decoder_hidden_size
self.reshape_last_stage = reshape_last_stage self.reshape_last_stage = kwargs.get("reshape_last_stage", True)
self.semantic_loss_ignore_index = semantic_loss_ignore_index self.semantic_loss_ignore_index = semantic_loss_ignore_index
...@@ -45,7 +45,7 @@ _FEAT_EXTRACTOR_FOR_DOC = "SegformerFeatureExtractor" ...@@ -45,7 +45,7 @@ _FEAT_EXTRACTOR_FOR_DOC = "SegformerFeatureExtractor"
# Base docstring # Base docstring
_CHECKPOINT_FOR_DOC = "nvidia/mit-b0" _CHECKPOINT_FOR_DOC = "nvidia/mit-b0"
_EXPECTED_OUTPUT_SHAPE = [1, 256, 256] _EXPECTED_OUTPUT_SHAPE = [1, 256, 16, 16]
# Image classification docstring # Image classification docstring
_IMAGE_CLASS_CHECKPOINT = "nvidia/mit-b0" _IMAGE_CLASS_CHECKPOINT = "nvidia/mit-b0"
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment