Add deprecation warning when image FE instantiated (#20427)

* Add deprecation warning when image FE instantiated

* Update src/transformers/models/beit/feature_extraction_beit.py

Co-authored-by: Sylvain Gugger <35901082+sgugger@users.noreply.github.com>

* Update v2.7 -> v5 and add for new IPs

* Add message to Chinese CLIP

Co-authored-by: Sylvain Gugger <35901082+sgugger@users.noreply.github.com>
This commit is contained in:
amyeroberts 2022-12-08 20:47:35 +00:00 committed by GitHub
parent 183af58b11
commit c56ebbbea6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
28 changed files with 290 additions and 31 deletions

View File

@ -14,10 +14,20 @@
# limitations under the License.
"""Feature extractor class for BEiT."""
import warnings
from ...utils import logging
from .image_processing_beit import BeitImageProcessor
logger = logging.get_logger(__name__)
BeitFeatureExtractor = BeitImageProcessor
class BeitFeatureExtractor(BeitImageProcessor):
def __init__(self, *args, **kwargs) -> None:
warnings.warn(
"The class BeitFeatureExtractor is deprecated and will be removed in version 5 of Transformers. Please"
" use BeitImageProcessor instead.",
FutureWarning,
)
super().__init__(*args, **kwargs)

View File

@ -14,6 +14,8 @@
# limitations under the License.
"""Feature extractor class for Chinese-CLIP."""
import warnings
from ...utils import logging
from .image_processing_chinese_clip import ChineseCLIPImageProcessor
@ -21,4 +23,11 @@ from .image_processing_chinese_clip import ChineseCLIPImageProcessor
logger = logging.get_logger(__name__)
ChineseCLIPFeatureExtractor = ChineseCLIPImageProcessor
class ChineseCLIPFeatureExtractor(ChineseCLIPImageProcessor):
def __init__(self, *args, **kwargs) -> None:
warnings.warn(
"The class ChineseCLIPFeatureExtractor is deprecated and will be removed in version 5 of Transformers."
" Please use ChineseCLIPImageProcessor instead.",
FutureWarning,
)
super().__init__(*args, **kwargs)

View File

@ -14,6 +14,8 @@
# limitations under the License.
"""Feature extractor class for CLIP."""
import warnings
from ...utils import logging
from .image_processing_clip import CLIPImageProcessor
@ -21,4 +23,11 @@ from .image_processing_clip import CLIPImageProcessor
logger = logging.get_logger(__name__)
CLIPFeatureExtractor = CLIPImageProcessor
class CLIPFeatureExtractor(CLIPImageProcessor):
def __init__(self, *args, **kwargs) -> None:
warnings.warn(
"The class CLIPFeatureExtractor is deprecated and will be removed in version 5 of Transformers. Please"
" use CLIPImageProcessor instead.",
FutureWarning,
)
super().__init__(*args, **kwargs)

View File

@ -14,10 +14,20 @@
# limitations under the License.
"""Feature extractor class for Conditional DETR."""
import warnings
from ...utils import logging
from .image_processing_conditional_detr import ConditionalDetrImageProcessor
logger = logging.get_logger(__name__)
ConditionalDetrFeatureExtractor = ConditionalDetrImageProcessor
class ConditionalDetrFeatureExtractor(ConditionalDetrImageProcessor):
def __init__(self, *args, **kwargs) -> None:
warnings.warn(
"The class ConditionalDetrFeatureExtractor is deprecated and will be removed in version 5 of Transformers."
" Please use ConditionalDetrImageProcessor instead.",
FutureWarning,
)
super().__init__(*args, **kwargs)

View File

@ -14,6 +14,8 @@
# limitations under the License.
"""Feature extractor class for ConvNeXT."""
import warnings
from ...utils import logging
from .image_processing_convnext import ConvNextImageProcessor
@ -21,4 +23,11 @@ from .image_processing_convnext import ConvNextImageProcessor
logger = logging.get_logger(__name__)
ConvNextFeatureExtractor = ConvNextImageProcessor
class ConvNextFeatureExtractor(ConvNextImageProcessor):
def __init__(self, *args, **kwargs) -> None:
warnings.warn(
"The class ConvNextFeatureExtractor is deprecated and will be removed in version 5 of Transformers."
" Please use ConvNextImageProcessor instead.",
FutureWarning,
)
super().__init__(*args, **kwargs)

View File

@ -14,10 +14,20 @@
# limitations under the License.
"""Feature extractor class for Deformable DETR."""
import warnings
from ...utils import logging
from .image_processing_deformable_detr import DeformableDetrImageProcessor
logger = logging.get_logger(__name__)
DeformableDetrFeatureExtractor = DeformableDetrImageProcessor
class DeformableDetrFeatureExtractor(DeformableDetrImageProcessor):
def __init__(self, *args, **kwargs) -> None:
warnings.warn(
"The class DeformableDetrFeatureExtractor is deprecated and will be removed in version 5 of Transformers."
" Please use DeformableDetrImageProcessor instead.",
FutureWarning,
)
super().__init__(*args, **kwargs)

View File

@ -14,10 +14,20 @@
# limitations under the License.
"""Feature extractor class for DeiT."""
import warnings
from ...utils import logging
from .image_processing_deit import DeiTImageProcessor
logger = logging.get_logger(__name__)
DeiTFeatureExtractor = DeiTImageProcessor
class DeiTFeatureExtractor(DeiTImageProcessor):
def __init__(self, *args, **kwargs) -> None:
warnings.warn(
"The class DeiTFeatureExtractor is deprecated and will be removed in version 5 of Transformers. Please"
" use DeiTImageProcessor instead.",
FutureWarning,
)
super().__init__(*args, **kwargs)

View File

@ -14,9 +14,20 @@
# limitations under the License.
"""Feature extractor class for DETR."""
import warnings
from ...utils import logging
from .image_processing_detr import DetrImageProcessor
logger = logging.get_logger(__name__)
DetrFeatureExtractor = DetrImageProcessor
class DetrFeatureExtractor(DetrImageProcessor):
def __init__(self, *args, **kwargs) -> None:
warnings.warn(
"The class DetrFeatureExtractor is deprecated and will be removed in version 5 of Transformers."
" Please use DetrImageProcessor instead.",
FutureWarning,
)
super().__init__(*args, **kwargs)

View File

@ -14,6 +14,8 @@
# limitations under the License.
"""Feature extractor class for Donut."""
import warnings
from ...utils import logging
from .image_processing_donut import DonutImageProcessor
@ -21,4 +23,11 @@ from .image_processing_donut import DonutImageProcessor
logger = logging.get_logger(__name__)
DonutFeatureExtractor = DonutImageProcessor
class DonutFeatureExtractor(DonutImageProcessor):
def __init__(self, *args, **kwargs) -> None:
warnings.warn(
"The class DonutFeatureExtractor is deprecated and will be removed in version 5 of Transformers. Please"
" use DonutImageProcessor instead.",
FutureWarning,
)
super().__init__(*args, **kwargs)

View File

@ -14,6 +14,8 @@
# limitations under the License.
"""Feature extractor class for DPT."""
import warnings
from ...utils import logging
from .image_processing_dpt import DPTImageProcessor
@ -21,4 +23,11 @@ from .image_processing_dpt import DPTImageProcessor
logger = logging.get_logger(__name__)
DPTFeatureExtractor = DPTImageProcessor
class DPTFeatureExtractor(DPTImageProcessor):
def __init__(self, *args, **kwargs) -> None:
warnings.warn(
"The class DPTFeatureExtractor is deprecated and will be removed in version 5 of Transformers. Please"
" use DPTImageProcessor instead.",
FutureWarning,
)
super().__init__(*args, **kwargs)

View File

@ -14,10 +14,20 @@
# limitations under the License.
"""Feature extractor class for FLAVA."""
import warnings
from ...utils import logging
from .image_processing_flava import FlavaImageProcessor
logger = logging.get_logger(__name__)
FlavaFeatureExtractor = FlavaImageProcessor
class FlavaFeatureExtractor(FlavaImageProcessor):
def __init__(self, *args, **kwargs) -> None:
warnings.warn(
"The class FlavaFeatureExtractor is deprecated and will be removed in version 5 of Transformers. Please"
" use FlavaImageProcessor instead.",
FutureWarning,
)
super().__init__(*args, **kwargs)

View File

@ -14,11 +14,20 @@
# limitations under the License.
"""Feature extractor class for GLPN."""
import warnings
from ...utils import logging
from .image_processing_glpn import GLPNImageProcessor
logger = logging.get_logger(__name__)
# Feature extractor for GLPN is being replaced by image processor
GLPNFeatureExtractor = GLPNImageProcessor
class GLPNFeatureExtractor(GLPNImageProcessor):
def __init__(self, *args, **kwargs) -> None:
warnings.warn(
"The class GLPNFeatureExtractor is deprecated and will be removed in version 5 of Transformers. Please"
" use GLPNImageProcessor instead.",
FutureWarning,
)
super().__init__(*args, **kwargs)

View File

@ -14,6 +14,8 @@
# limitations under the License.
"""Feature extractor class for ImageGPT."""
import warnings
from ...utils import logging
from .image_processing_imagegpt import ImageGPTImageProcessor
@ -21,4 +23,11 @@ from .image_processing_imagegpt import ImageGPTImageProcessor
logger = logging.get_logger(__name__)
ImageGPTFeatureExtractor = ImageGPTImageProcessor
class ImageGPTFeatureExtractor(ImageGPTImageProcessor):
def __init__(self, *args, **kwargs) -> None:
warnings.warn(
"The class ImageGPTFeatureExtractor is deprecated and will be removed in version 5 of Transformers."
" Please use ImageGPTImageProcessor instead.",
FutureWarning,
)
super().__init__(*args, **kwargs)

View File

@ -16,10 +16,20 @@
Feature extractor class for LayoutLMv2.
"""
import warnings
from ...utils import logging
from .image_processing_layoutlmv2 import LayoutLMv2ImageProcessor
logger = logging.get_logger(__name__)
LayoutLMv2FeatureExtractor = LayoutLMv2ImageProcessor
class LayoutLMv2FeatureExtractor(LayoutLMv2ImageProcessor):
def __init__(self, *args, **kwargs) -> None:
warnings.warn(
"The class LayoutLMv2FeatureExtractor is deprecated and will be removed in version 5 of Transformers."
" Please use LayoutLMv2ImageProcessor instead.",
FutureWarning,
)
super().__init__(*args, **kwargs)

View File

@ -16,6 +16,8 @@
Feature extractor class for LayoutLMv3.
"""
import warnings
from ...utils import logging
from .image_processing_layoutlmv3 import LayoutLMv3ImageProcessor
@ -23,4 +25,11 @@ from .image_processing_layoutlmv3 import LayoutLMv3ImageProcessor
logger = logging.get_logger(__name__)
LayoutLMv3FeatureExtractor = LayoutLMv3ImageProcessor
class LayoutLMv3FeatureExtractor(LayoutLMv3ImageProcessor):
def __init__(self, *args, **kwargs) -> None:
warnings.warn(
"The class LayoutLMv3FeatureExtractor is deprecated and will be removed in version 5 of Transformers."
" Please use LayoutLMv3ImageProcessor instead.",
FutureWarning,
)
super().__init__(*args, **kwargs)

View File

@ -14,6 +14,8 @@
# limitations under the License.
"""Feature extractor class for LeViT."""
import warnings
from ...utils import logging
from .image_processing_levit import LevitImageProcessor
@ -21,5 +23,11 @@ from .image_processing_levit import LevitImageProcessor
logger = logging.get_logger(__name__)
# Feature extractor for Levit is being replaced by image processor
LevitFeatureExtractor = LevitImageProcessor
class LevitFeatureExtractor(LevitImageProcessor):
def __init__(self, *args, **kwargs) -> None:
warnings.warn(
"The class LevitFeatureExtractor is deprecated and will be removed in version 5 of Transformers. Please"
" use LevitImageProcessor instead.",
FutureWarning,
)
super().__init__(*args, **kwargs)

View File

@ -14,6 +14,8 @@
# limitations under the License.
"""Feature extractor class for MaskFormer."""
import warnings
from transformers.utils import logging
from .image_processing_maskformer import MaskFormerImageProcessor
@ -21,4 +23,12 @@ from .image_processing_maskformer import MaskFormerImageProcessor
logger = logging.get_logger(__name__)
MaskFormerFeatureExtractor = MaskFormerImageProcessor
class MaskFormerFeatureExtractor(MaskFormerImageProcessor):
def __init__(self, *args, **kwargs) -> None:
warnings.warn(
"The class MaskFormerFeatureExtractor is deprecated and will be removed in version 5 of Transformers."
" Please use MaskFormerImageProcessor instead.",
FutureWarning,
)
super().__init__(*args, **kwargs)

View File

@ -14,6 +14,8 @@
# limitations under the License.
"""Feature extractor class for MobileNetV1."""
import warnings
from ...utils import logging
from .image_processing_mobilenet_v1 import MobileNetV1ImageProcessor
@ -21,4 +23,11 @@ from .image_processing_mobilenet_v1 import MobileNetV1ImageProcessor
logger = logging.get_logger(__name__)
MobileNetV1FeatureExtractor = MobileNetV1ImageProcessor
class MobileNetV1FeatureExtractor(MobileNetV1ImageProcessor):
def __init__(self, *args, **kwargs) -> None:
warnings.warn(
"The class MobileNetV1FeatureExtractor is deprecated and will be removed in version 5 of Transformers."
" Please use MobileNetV1ImageProcessor instead.",
FutureWarning,
)
super().__init__(*args, **kwargs)

View File

@ -14,6 +14,8 @@
# limitations under the License.
"""Feature extractor class for MobileNetV2."""
import warnings
from ...utils import logging
from .image_processing_mobilenet_v2 import MobileNetV2ImageProcessor
@ -21,4 +23,11 @@ from .image_processing_mobilenet_v2 import MobileNetV2ImageProcessor
logger = logging.get_logger(__name__)
MobileNetV2FeatureExtractor = MobileNetV2ImageProcessor
class MobileNetV2FeatureExtractor(MobileNetV2ImageProcessor):
def __init__(self, *args, **kwargs) -> None:
warnings.warn(
"The class MobileNetV2FeatureExtractor is deprecated and will be removed in version 5 of Transformers."
" Please use MobileNetV2ImageProcessor instead.",
FutureWarning,
)
super().__init__(*args, **kwargs)

View File

@ -14,6 +14,8 @@
# limitations under the License.
"""Feature extractor class for MobileViT."""
import warnings
from ...utils import logging
from .image_processing_mobilevit import MobileViTImageProcessor
@ -21,4 +23,11 @@ from .image_processing_mobilevit import MobileViTImageProcessor
logger = logging.get_logger(__name__)
MobileViTFeatureExtractor = MobileViTImageProcessor
class MobileViTFeatureExtractor(MobileViTImageProcessor):
def __init__(self, *args, **kwargs) -> None:
warnings.warn(
"The class MobileViTFeatureExtractor is deprecated and will be removed in version 5 of Transformers."
" Please use MobileViTImageProcessor instead.",
FutureWarning,
)
super().__init__(*args, **kwargs)

View File

@ -14,6 +14,8 @@
# limitations under the License.
"""Feature extractor class for OwlViT."""
import warnings
from ...utils import logging
from .image_processing_owlvit import OwlViTImageProcessor
@ -21,4 +23,11 @@ from .image_processing_owlvit import OwlViTImageProcessor
logger = logging.get_logger(__name__)
OwlViTFeatureExtractor = OwlViTImageProcessor
class OwlViTFeatureExtractor(OwlViTImageProcessor):
def __init__(self, *args, **kwargs) -> None:
warnings.warn(
"The class OwlViTFeatureExtractor is deprecated and will be removed in version 5 of Transformers. Please"
" use OwlViTImageProcessor instead.",
FutureWarning,
)
super().__init__(*args, **kwargs)

View File

@ -14,6 +14,8 @@
# limitations under the License.
"""Feature extractor class for Perceiver."""
import warnings
from ...utils import logging
from .image_processing_perceiver import PerceiverImageProcessor
@ -21,4 +23,11 @@ from .image_processing_perceiver import PerceiverImageProcessor
logger = logging.get_logger(__name__)
PerceiverFeatureExtractor = PerceiverImageProcessor
class PerceiverFeatureExtractor(PerceiverImageProcessor):
def __init__(self, *args, **kwargs) -> None:
warnings.warn(
"The class PerceiverFeatureExtractor is deprecated and will be removed in version 5 of Transformers."
" Please use PerceiverImageProcessor instead.",
FutureWarning,
)
super().__init__(*args, **kwargs)

View File

@ -14,6 +14,8 @@
# limitations under the License.
"""Feature extractor class for PoolFormer."""
import warnings
from ...utils import logging
from .image_processing_poolformer import PoolFormerImageProcessor
@ -21,4 +23,11 @@ from .image_processing_poolformer import PoolFormerImageProcessor
logger = logging.get_logger(__name__)
PoolFormerFeatureExtractor = PoolFormerImageProcessor
class PoolFormerFeatureExtractor(PoolFormerImageProcessor):
def __init__(self, *args, **kwargs) -> None:
warnings.warn(
"The class PoolFormerFeatureExtractor is deprecated and will be removed in version 5 of Transformers."
" Please use PoolFormerImageProcessor instead.",
FutureWarning,
)
super().__init__(*args, **kwargs)

View File

@ -14,6 +14,8 @@
# limitations under the License.
"""Feature extractor class for SegFormer."""
import warnings
from ...utils import logging
from .image_processing_segformer import SegformerImageProcessor
@ -21,4 +23,11 @@ from .image_processing_segformer import SegformerImageProcessor
logger = logging.get_logger(__name__)
SegformerFeatureExtractor = SegformerImageProcessor
class SegformerFeatureExtractor(SegformerImageProcessor):
def __init__(self, *args, **kwargs) -> None:
warnings.warn(
"The class SegformerFeatureExtractor is deprecated and will be removed in version 5 of Transformers."
" Please use SegformerImageProcessor instead.",
FutureWarning,
)
super().__init__(*args, **kwargs)

View File

@ -14,6 +14,8 @@
# limitations under the License.
"""Feature extractor class for VideoMAE."""
import warnings
from ...utils import logging
from .image_processing_videomae import VideoMAEImageProcessor
@ -21,4 +23,11 @@ from .image_processing_videomae import VideoMAEImageProcessor
logger = logging.get_logger(__name__)
VideoMAEFeatureExtractor = VideoMAEImageProcessor
class VideoMAEFeatureExtractor(VideoMAEImageProcessor):
def __init__(self, *args, **kwargs) -> None:
warnings.warn(
"The class VideoMAEFeatureExtractor is deprecated and will be removed in version 5 of Transformers."
" Please use VideoMAEImageProcessor instead.",
FutureWarning,
)
super().__init__(*args, **kwargs)

View File

@ -14,6 +14,8 @@
# limitations under the License.
"""Feature extractor class for ViLT."""
import warnings
from ...utils import logging
from .image_processing_vilt import ViltImageProcessor
@ -21,4 +23,11 @@ from .image_processing_vilt import ViltImageProcessor
logger = logging.get_logger(__name__)
ViltFeatureExtractor = ViltImageProcessor
class ViltFeatureExtractor(ViltImageProcessor):
def __init__(self, *args, **kwargs) -> None:
warnings.warn(
"The class ViltFeatureExtractor is deprecated and will be removed in version 5 of Transformers. Please"
" use ViltImageProcessor instead.",
FutureWarning,
)
super().__init__(*args, **kwargs)

View File

@ -14,6 +14,8 @@
# limitations under the License.
"""Feature extractor class for ViT."""
import warnings
from ...utils import logging
from .image_processing_vit import ViTImageProcessor
@ -21,5 +23,11 @@ from .image_processing_vit import ViTImageProcessor
logger = logging.get_logger(__name__)
# Feature extractor for ViT is being replaced by image processor
ViTFeatureExtractor = ViTImageProcessor
class ViTFeatureExtractor(ViTImageProcessor):
def __init__(self, *args, **kwargs) -> None:
warnings.warn(
"The class ViTFeatureExtractor is deprecated and will be removed in version 5 of Transformers. Please"
" use ViTImageProcessor instead.",
FutureWarning,
)
super().__init__(*args, **kwargs)

View File

@ -14,6 +14,8 @@
# limitations under the License.
"""Feature extractor class for YOLOS."""
import warnings
from ...utils import logging
from .image_processing_yolos import YolosImageProcessor
@ -21,4 +23,11 @@ from .image_processing_yolos import YolosImageProcessor
logger = logging.get_logger(__name__)
YolosFeatureExtractor = YolosImageProcessor
class YolosFeatureExtractor(YolosImageProcessor):
def __init__(self, *args, **kwargs) -> None:
warnings.warn(
"The class YolosFeatureExtractor is deprecated and will be removed in version 5 of Transformers. Please"
" use YolosImageProcessor instead.",
FutureWarning,
)
super().__init__(*args, **kwargs)