Image Feature Extraction pipeline (#28216)
* Draft pipeline * Fixup * Fix docstrings * Update doctest * Update pipeline_model_mapping * Update docstring * Update tests * Update src/transformers/pipelines/image_feature_extraction.py Co-authored-by: Omar Sanseviero <osanseviero@gmail.com> * Fix docstrings - review comments * Remove pipeline mapping for composite vision models * Add to pipeline tests * Remove for flava (multimodal) * safe pil import * Add requirements for pipeline run * Account for super slow efficientnet * Review comments * Fix tests * Swap order of kwargs * Use build_pipeline_init_args * Add back FE pipeline for Vilt * Include image_processor_kwargs in docstring * Mark test as flaky * Update TODO * Update tests/pipelines/test_pipelines_image_feature_extraction.py Co-authored-by: Arthur <48595927+ArthurZucker@users.noreply.github.com> * Add license header --------- Co-authored-by: Omar Sanseviero <osanseviero@gmail.com> Co-authored-by: Arthur <48595927+ArthurZucker@users.noreply.github.com>
This commit is contained in:
@@ -242,7 +242,7 @@ class BeitModelTest(ModelTesterMixin, PipelineTesterMixin, unittest.TestCase):
|
||||
)
|
||||
pipeline_model_mapping = (
|
||||
{
|
||||
"feature-extraction": BeitModel,
|
||||
"image-feature-extraction": BeitModel,
|
||||
"image-classification": BeitForImageClassification,
|
||||
"image-segmentation": BeitForSemanticSegmentation,
|
||||
}
|
||||
|
||||
@@ -162,7 +162,7 @@ class BitModelTest(ModelTesterMixin, PipelineTesterMixin, unittest.TestCase):
|
||||
|
||||
all_model_classes = (BitModel, BitForImageClassification, BitBackbone) if is_torch_available() else ()
|
||||
pipeline_model_mapping = (
|
||||
{"feature-extraction": BitModel, "image-classification": BitForImageClassification}
|
||||
{"image-feature-extraction": BitModel, "image-classification": BitForImageClassification}
|
||||
if is_torch_available()
|
||||
else {}
|
||||
)
|
||||
|
||||
@@ -429,7 +429,10 @@ class BlipModelTester:
|
||||
class BlipModelTest(ModelTesterMixin, PipelineTesterMixin, unittest.TestCase):
|
||||
all_model_classes = (BlipModel,) if is_torch_available() else ()
|
||||
pipeline_model_mapping = (
|
||||
{"feature-extraction": BlipModel, "image-to-text": BlipForConditionalGeneration}
|
||||
{
|
||||
"feature-extraction": BlipModel,
|
||||
"image-to-text": BlipForConditionalGeneration,
|
||||
}
|
||||
if is_torch_available()
|
||||
else {}
|
||||
)
|
||||
|
||||
@@ -477,7 +477,9 @@ class CLIPModelTester:
|
||||
@require_torch
|
||||
class CLIPModelTest(ModelTesterMixin, PipelineTesterMixin, unittest.TestCase):
|
||||
all_model_classes = (CLIPModel,) if is_torch_available() else ()
|
||||
pipeline_model_mapping = {"feature-extraction": CLIPModel} if is_torch_available() else {}
|
||||
pipeline_model_mapping = (
|
||||
{"feature-extraction": CLIPModel, "image-feature-extraction": CLIPVisionModel} if is_torch_available() else {}
|
||||
)
|
||||
fx_compatible = True
|
||||
test_head_masking = False
|
||||
test_pruning = False
|
||||
|
||||
@@ -185,7 +185,7 @@ class ConditionalDetrModelTest(ModelTesterMixin, GenerationTesterMixin, Pipeline
|
||||
else ()
|
||||
)
|
||||
pipeline_model_mapping = (
|
||||
{"feature-extraction": ConditionalDetrModel, "object-detection": ConditionalDetrForObjectDetection}
|
||||
{"image-feature-extraction": ConditionalDetrModel, "object-detection": ConditionalDetrForObjectDetection}
|
||||
if is_torch_available()
|
||||
else {}
|
||||
)
|
||||
|
||||
@@ -172,7 +172,7 @@ class ConvNextModelTest(ModelTesterMixin, PipelineTesterMixin, unittest.TestCase
|
||||
else ()
|
||||
)
|
||||
pipeline_model_mapping = (
|
||||
{"feature-extraction": ConvNextModel, "image-classification": ConvNextForImageClassification}
|
||||
{"image-feature-extraction": ConvNextModel, "image-classification": ConvNextForImageClassification}
|
||||
if is_torch_available()
|
||||
else {}
|
||||
)
|
||||
|
||||
@@ -180,7 +180,7 @@ class ConvNextV2ModelTest(ModelTesterMixin, PipelineTesterMixin, unittest.TestCa
|
||||
else ()
|
||||
)
|
||||
pipeline_model_mapping = (
|
||||
{"feature-extraction": ConvNextV2Model, "image-classification": ConvNextV2ForImageClassification}
|
||||
{"image-feature-extraction": ConvNextV2Model, "image-classification": ConvNextV2ForImageClassification}
|
||||
if is_torch_available()
|
||||
else {}
|
||||
)
|
||||
|
||||
@@ -151,7 +151,7 @@ class CvtModelTest(ModelTesterMixin, PipelineTesterMixin, unittest.TestCase):
|
||||
|
||||
all_model_classes = (CvtModel, CvtForImageClassification) if is_torch_available() else ()
|
||||
pipeline_model_mapping = (
|
||||
{"feature-extraction": CvtModel, "image-classification": CvtForImageClassification}
|
||||
{"image-feature-extraction": CvtModel, "image-classification": CvtForImageClassification}
|
||||
if is_torch_available()
|
||||
else {}
|
||||
)
|
||||
|
||||
@@ -178,7 +178,7 @@ class Data2VecVisionModelTest(ModelTesterMixin, PipelineTesterMixin, unittest.Te
|
||||
)
|
||||
pipeline_model_mapping = (
|
||||
{
|
||||
"feature-extraction": Data2VecVisionModel,
|
||||
"image-feature-extraction": Data2VecVisionModel,
|
||||
"image-classification": Data2VecVisionForImageClassification,
|
||||
"image-segmentation": Data2VecVisionForSemanticSegmentation,
|
||||
}
|
||||
|
||||
@@ -191,7 +191,7 @@ class DeformableDetrModelTester:
|
||||
class DeformableDetrModelTest(ModelTesterMixin, GenerationTesterMixin, PipelineTesterMixin, unittest.TestCase):
|
||||
all_model_classes = (DeformableDetrModel, DeformableDetrForObjectDetection) if is_torch_available() else ()
|
||||
pipeline_model_mapping = (
|
||||
{"feature-extraction": DeformableDetrModel, "object-detection": DeformableDetrForObjectDetection}
|
||||
{"image-feature-extraction": DeformableDetrModel, "object-detection": DeformableDetrForObjectDetection}
|
||||
if is_torch_available()
|
||||
else {}
|
||||
)
|
||||
|
||||
@@ -206,7 +206,7 @@ class DeiTModelTest(ModelTesterMixin, PipelineTesterMixin, unittest.TestCase):
|
||||
)
|
||||
pipeline_model_mapping = (
|
||||
{
|
||||
"feature-extraction": DeiTModel,
|
||||
"image-feature-extraction": DeiTModel,
|
||||
"image-classification": (DeiTForImageClassification, DeiTForImageClassificationWithTeacher),
|
||||
}
|
||||
if is_torch_available()
|
||||
|
||||
@@ -217,7 +217,7 @@ class DetaModelTester:
|
||||
class DetaModelTest(ModelTesterMixin, GenerationTesterMixin, PipelineTesterMixin, unittest.TestCase):
|
||||
all_model_classes = (DetaModel, DetaForObjectDetection) if is_torchvision_available() else ()
|
||||
pipeline_model_mapping = (
|
||||
{"feature-extraction": DetaModel, "object-detection": DetaForObjectDetection}
|
||||
{"image-feature-extraction": DetaModel, "object-detection": DetaForObjectDetection}
|
||||
if is_torchvision_available()
|
||||
else {}
|
||||
)
|
||||
|
||||
@@ -182,7 +182,7 @@ class DetrModelTest(ModelTesterMixin, GenerationTesterMixin, PipelineTesterMixin
|
||||
)
|
||||
pipeline_model_mapping = (
|
||||
{
|
||||
"feature-extraction": DetrModel,
|
||||
"image-feature-extraction": DetrModel,
|
||||
"image-segmentation": DetrForSegmentation,
|
||||
"object-detection": DetrForObjectDetection,
|
||||
}
|
||||
|
||||
@@ -207,7 +207,7 @@ class DinatModelTest(ModelTesterMixin, PipelineTesterMixin, unittest.TestCase):
|
||||
else ()
|
||||
)
|
||||
pipeline_model_mapping = (
|
||||
{"feature-extraction": DinatModel, "image-classification": DinatForImageClassification}
|
||||
{"image-feature-extraction": DinatModel, "image-classification": DinatForImageClassification}
|
||||
if is_torch_available()
|
||||
else {}
|
||||
)
|
||||
|
||||
@@ -217,7 +217,7 @@ class Dinov2ModelTest(ModelTesterMixin, PipelineTesterMixin, unittest.TestCase):
|
||||
else ()
|
||||
)
|
||||
pipeline_model_mapping = (
|
||||
{"feature-extraction": Dinov2Model, "image-classification": Dinov2ForImageClassification}
|
||||
{"image-feature-extraction": Dinov2Model, "image-classification": Dinov2ForImageClassification}
|
||||
if is_torch_available()
|
||||
else {}
|
||||
)
|
||||
|
||||
@@ -145,7 +145,7 @@ class DonutSwinModelTester:
|
||||
@require_torch
|
||||
class DonutSwinModelTest(ModelTesterMixin, PipelineTesterMixin, unittest.TestCase):
|
||||
all_model_classes = (DonutSwinModel,) if is_torch_available() else ()
|
||||
pipeline_model_mapping = {"feature-extraction": DonutSwinModel} if is_torch_available() else {}
|
||||
pipeline_model_mapping = {"image-feature-extraction": DonutSwinModel} if is_torch_available() else {}
|
||||
fx_compatible = True
|
||||
|
||||
test_pruning = False
|
||||
|
||||
@@ -163,7 +163,7 @@ class DPTModelTest(ModelTesterMixin, PipelineTesterMixin, unittest.TestCase):
|
||||
pipeline_model_mapping = (
|
||||
{
|
||||
"depth-estimation": DPTForDepthEstimation,
|
||||
"feature-extraction": DPTModel,
|
||||
"image-feature-extraction": DPTModel,
|
||||
"image-segmentation": DPTForSemanticSegmentation,
|
||||
}
|
||||
if is_torch_available()
|
||||
|
||||
@@ -190,7 +190,7 @@ class EfficientFormerModelTest(ModelTesterMixin, PipelineTesterMixin, unittest.T
|
||||
)
|
||||
pipeline_model_mapping = (
|
||||
{
|
||||
"feature-extraction": EfficientFormerModel,
|
||||
"image-feature-extraction": EfficientFormerModel,
|
||||
"image-classification": (
|
||||
EfficientFormerForImageClassification,
|
||||
EfficientFormerForImageClassificationWithTeacher,
|
||||
|
||||
@@ -130,7 +130,7 @@ class EfficientNetModelTest(ModelTesterMixin, PipelineTesterMixin, unittest.Test
|
||||
|
||||
all_model_classes = (EfficientNetModel, EfficientNetForImageClassification) if is_torch_available() else ()
|
||||
pipeline_model_mapping = (
|
||||
{"feature-extraction": EfficientNetModel, "image-classification": EfficientNetForImageClassification}
|
||||
{"image-feature-extraction": EfficientNetModel, "image-classification": EfficientNetForImageClassification}
|
||||
if is_torch_available()
|
||||
else {}
|
||||
)
|
||||
@@ -216,6 +216,12 @@ class EfficientNetModelTest(ModelTesterMixin, PipelineTesterMixin, unittest.Test
|
||||
model = EfficientNetModel.from_pretrained(model_name)
|
||||
self.assertIsNotNone(model)
|
||||
|
||||
@is_pipeline_test
|
||||
@require_vision
|
||||
@slow
|
||||
def test_pipeline_image_feature_extraction(self):
|
||||
super().test_pipeline_image_feature_extraction()
|
||||
|
||||
@is_pipeline_test
|
||||
@require_vision
|
||||
@slow
|
||||
|
||||
@@ -238,7 +238,7 @@ class FocalNetModelTest(ModelTesterMixin, PipelineTesterMixin, unittest.TestCase
|
||||
else ()
|
||||
)
|
||||
pipeline_model_mapping = (
|
||||
{"feature-extraction": FocalNetModel, "image-classification": FocalNetForImageClassification}
|
||||
{"image-feature-extraction": FocalNetModel, "image-classification": FocalNetForImageClassification}
|
||||
if is_torch_available()
|
||||
else {}
|
||||
)
|
||||
|
||||
@@ -146,7 +146,9 @@ class GLPNModelTester:
|
||||
class GLPNModelTest(ModelTesterMixin, PipelineTesterMixin, unittest.TestCase):
|
||||
all_model_classes = (GLPNModel, GLPNForDepthEstimation) if is_torch_available() else ()
|
||||
pipeline_model_mapping = (
|
||||
{"depth-estimation": GLPNForDepthEstimation, "feature-extraction": GLPNModel} if is_torch_available() else {}
|
||||
{"depth-estimation": GLPNForDepthEstimation, "image-feature-extraction": GLPNModel}
|
||||
if is_torch_available()
|
||||
else {}
|
||||
)
|
||||
|
||||
test_head_masking = False
|
||||
|
||||
@@ -271,7 +271,7 @@ class ImageGPTModelTest(ModelTesterMixin, GenerationTesterMixin, PipelineTesterM
|
||||
)
|
||||
all_generative_model_classes = (ImageGPTForCausalImageModeling,) if is_torch_available() else ()
|
||||
pipeline_model_mapping = (
|
||||
{"feature-extraction": ImageGPTModel, "image-classification": ImageGPTForImageClassification}
|
||||
{"image-feature-extraction": ImageGPTModel, "image-classification": ImageGPTForImageClassification}
|
||||
if is_torch_available()
|
||||
else {}
|
||||
)
|
||||
|
||||
@@ -176,7 +176,7 @@ class LevitModelTest(ModelTesterMixin, PipelineTesterMixin, unittest.TestCase):
|
||||
)
|
||||
pipeline_model_mapping = (
|
||||
{
|
||||
"feature-extraction": LevitModel,
|
||||
"image-feature-extraction": LevitModel,
|
||||
"image-classification": (LevitForImageClassification, LevitForImageClassificationWithTeacher),
|
||||
}
|
||||
if is_torch_available()
|
||||
|
||||
@@ -197,7 +197,7 @@ class Mask2FormerModelTester:
|
||||
@require_torch
|
||||
class Mask2FormerModelTest(ModelTesterMixin, PipelineTesterMixin, unittest.TestCase):
|
||||
all_model_classes = (Mask2FormerModel, Mask2FormerForUniversalSegmentation) if is_torch_available() else ()
|
||||
pipeline_model_mapping = {"feature-extraction": Mask2FormerModel} if is_torch_available() else {}
|
||||
pipeline_model_mapping = {"image-feature-extraction": Mask2FormerModel} if is_torch_available() else {}
|
||||
|
||||
is_encoder_decoder = False
|
||||
test_pruning = False
|
||||
|
||||
@@ -197,7 +197,7 @@ class MaskFormerModelTester:
|
||||
class MaskFormerModelTest(ModelTesterMixin, PipelineTesterMixin, unittest.TestCase):
|
||||
all_model_classes = (MaskFormerModel, MaskFormerForInstanceSegmentation) if is_torch_available() else ()
|
||||
pipeline_model_mapping = (
|
||||
{"feature-extraction": MaskFormerModel, "image-segmentation": MaskFormerForInstanceSegmentation}
|
||||
{"image-feature-extraction": MaskFormerModel, "image-segmentation": MaskFormerForInstanceSegmentation}
|
||||
if is_torch_available()
|
||||
else {}
|
||||
)
|
||||
|
||||
@@ -31,7 +31,7 @@ if is_torch_available():
|
||||
import torch
|
||||
from torch import nn
|
||||
|
||||
from transformers import MgpstrForSceneTextRecognition
|
||||
from transformers import MgpstrForSceneTextRecognition, MgpstrModel
|
||||
|
||||
|
||||
if is_vision_available():
|
||||
@@ -118,7 +118,11 @@ class MgpstrModelTester:
|
||||
@require_torch
|
||||
class MgpstrModelTest(ModelTesterMixin, PipelineTesterMixin, unittest.TestCase):
|
||||
all_model_classes = (MgpstrForSceneTextRecognition,) if is_torch_available() else ()
|
||||
pipeline_model_mapping = {"feature-extraction": MgpstrForSceneTextRecognition} if is_torch_available() else {}
|
||||
pipeline_model_mapping = (
|
||||
{"feature-extraction": MgpstrForSceneTextRecognition, "image-feature-extraction": MgpstrModel}
|
||||
if is_torch_available()
|
||||
else {}
|
||||
)
|
||||
fx_compatible = False
|
||||
|
||||
test_pruning = False
|
||||
|
||||
@@ -147,7 +147,7 @@ class MobileNetV1ModelTest(ModelTesterMixin, PipelineTesterMixin, unittest.TestC
|
||||
|
||||
all_model_classes = (MobileNetV1Model, MobileNetV1ForImageClassification) if is_torch_available() else ()
|
||||
pipeline_model_mapping = (
|
||||
{"feature-extraction": MobileNetV1Model, "image-classification": MobileNetV1ForImageClassification}
|
||||
{"image-feature-extraction": MobileNetV1Model, "image-classification": MobileNetV1ForImageClassification}
|
||||
if is_torch_available()
|
||||
else {}
|
||||
)
|
||||
|
||||
@@ -195,7 +195,7 @@ class MobileNetV2ModelTest(ModelTesterMixin, PipelineTesterMixin, unittest.TestC
|
||||
)
|
||||
pipeline_model_mapping = (
|
||||
{
|
||||
"feature-extraction": MobileNetV2Model,
|
||||
"image-feature-extraction": MobileNetV2Model,
|
||||
"image-classification": MobileNetV2ForImageClassification,
|
||||
"image-segmentation": MobileNetV2ForSemanticSegmentation,
|
||||
}
|
||||
|
||||
@@ -188,7 +188,7 @@ class MobileViTModelTest(ModelTesterMixin, PipelineTesterMixin, unittest.TestCas
|
||||
)
|
||||
pipeline_model_mapping = (
|
||||
{
|
||||
"feature-extraction": MobileViTModel,
|
||||
"image-feature-extraction": MobileViTModel,
|
||||
"image-classification": MobileViTForImageClassification,
|
||||
"image-segmentation": MobileViTForSemanticSegmentation,
|
||||
}
|
||||
|
||||
@@ -190,7 +190,7 @@ class MobileViTV2ModelTest(ModelTesterMixin, PipelineTesterMixin, unittest.TestC
|
||||
|
||||
pipeline_model_mapping = (
|
||||
{
|
||||
"feature-extraction": MobileViTV2Model,
|
||||
"image-feature-extraction": MobileViTV2Model,
|
||||
"image-classification": MobileViTV2ForImageClassification,
|
||||
"image-segmentation": MobileViTV2ForSemanticSegmentation,
|
||||
}
|
||||
|
||||
@@ -204,7 +204,7 @@ class NatModelTest(ModelTesterMixin, PipelineTesterMixin, unittest.TestCase):
|
||||
else ()
|
||||
)
|
||||
pipeline_model_mapping = (
|
||||
{"feature-extraction": NatModel, "image-classification": NatForImageClassification}
|
||||
{"image-feature-extraction": NatModel, "image-classification": NatForImageClassification}
|
||||
if is_torch_available()
|
||||
else {}
|
||||
)
|
||||
|
||||
@@ -433,7 +433,10 @@ class Owlv2ModelTester:
|
||||
class Owlv2ModelTest(ModelTesterMixin, PipelineTesterMixin, unittest.TestCase):
|
||||
all_model_classes = (Owlv2Model,) if is_torch_available() else ()
|
||||
pipeline_model_mapping = (
|
||||
{"feature-extraction": Owlv2Model, "zero-shot-object-detection": Owlv2ForObjectDetection}
|
||||
{
|
||||
"feature-extraction": Owlv2Model,
|
||||
"zero-shot-object-detection": Owlv2ForObjectDetection,
|
||||
}
|
||||
if is_torch_available()
|
||||
else {}
|
||||
)
|
||||
|
||||
@@ -428,7 +428,10 @@ class OwlViTModelTester:
|
||||
class OwlViTModelTest(ModelTesterMixin, PipelineTesterMixin, unittest.TestCase):
|
||||
all_model_classes = (OwlViTModel,) if is_torch_available() else ()
|
||||
pipeline_model_mapping = (
|
||||
{"feature-extraction": OwlViTModel, "zero-shot-object-detection": OwlViTForObjectDetection}
|
||||
{
|
||||
"feature-extraction": OwlViTModel,
|
||||
"zero-shot-object-detection": OwlViTForObjectDetection,
|
||||
}
|
||||
if is_torch_available()
|
||||
else {}
|
||||
)
|
||||
|
||||
@@ -124,7 +124,7 @@ class PoolFormerModelTester:
|
||||
class PoolFormerModelTest(ModelTesterMixin, PipelineTesterMixin, unittest.TestCase):
|
||||
all_model_classes = (PoolFormerModel, PoolFormerForImageClassification) if is_torch_available() else ()
|
||||
pipeline_model_mapping = (
|
||||
{"feature-extraction": PoolFormerModel, "image-classification": PoolFormerForImageClassification}
|
||||
{"image-feature-extraction": PoolFormerModel, "image-classification": PoolFormerForImageClassification}
|
||||
if is_torch_available()
|
||||
else {}
|
||||
)
|
||||
|
||||
@@ -158,7 +158,7 @@ def prepare_img():
|
||||
class PvtModelTest(ModelTesterMixin, PipelineTesterMixin, unittest.TestCase):
|
||||
all_model_classes = (PvtModel, PvtForImageClassification) if is_torch_available() else ()
|
||||
pipeline_model_mapping = (
|
||||
{"feature-extraction": PvtModel, "image-classification": PvtForImageClassification}
|
||||
{"image-feature-extraction": PvtModel, "image-classification": PvtForImageClassification}
|
||||
if is_torch_available()
|
||||
else {}
|
||||
)
|
||||
|
||||
@@ -126,7 +126,7 @@ class RegNetModelTest(ModelTesterMixin, PipelineTesterMixin, unittest.TestCase):
|
||||
|
||||
all_model_classes = (RegNetModel, RegNetForImageClassification) if is_torch_available() else ()
|
||||
pipeline_model_mapping = (
|
||||
{"feature-extraction": RegNetModel, "image-classification": RegNetForImageClassification}
|
||||
{"image-feature-extraction": RegNetModel, "image-classification": RegNetForImageClassification}
|
||||
if is_torch_available()
|
||||
else {}
|
||||
)
|
||||
|
||||
@@ -170,7 +170,7 @@ class ResNetModelTest(ModelTesterMixin, PipelineTesterMixin, unittest.TestCase):
|
||||
else ()
|
||||
)
|
||||
pipeline_model_mapping = (
|
||||
{"feature-extraction": ResNetModel, "image-classification": ResNetForImageClassification}
|
||||
{"image-feature-extraction": ResNetModel, "image-classification": ResNetForImageClassification}
|
||||
if is_torch_available()
|
||||
else {}
|
||||
)
|
||||
|
||||
@@ -171,7 +171,7 @@ class SegformerModelTest(ModelTesterMixin, PipelineTesterMixin, unittest.TestCas
|
||||
)
|
||||
pipeline_model_mapping = (
|
||||
{
|
||||
"feature-extraction": SegformerModel,
|
||||
"image-feature-extraction": SegformerModel,
|
||||
"image-classification": SegformerForImageClassification,
|
||||
"image-segmentation": SegformerForSemanticSegmentation,
|
||||
}
|
||||
|
||||
@@ -139,7 +139,7 @@ class SwiftFormerModelTest(ModelTesterMixin, PipelineTesterMixin, unittest.TestC
|
||||
|
||||
all_model_classes = (SwiftFormerModel, SwiftFormerForImageClassification) if is_torch_available() else ()
|
||||
pipeline_model_mapping = (
|
||||
{"feature-extraction": SwiftFormerModel, "image-classification": SwiftFormerForImageClassification}
|
||||
{"image-feature-extraction": SwiftFormerModel, "image-classification": SwiftFormerForImageClassification}
|
||||
if is_torch_available()
|
||||
else {}
|
||||
)
|
||||
|
||||
@@ -232,7 +232,7 @@ class SwinModelTest(ModelTesterMixin, PipelineTesterMixin, unittest.TestCase):
|
||||
else ()
|
||||
)
|
||||
pipeline_model_mapping = (
|
||||
{"feature-extraction": SwinModel, "image-classification": SwinForImageClassification}
|
||||
{"image-feature-extraction": SwinModel, "image-classification": SwinForImageClassification}
|
||||
if is_torch_available()
|
||||
else {}
|
||||
)
|
||||
|
||||
@@ -162,7 +162,7 @@ class Swin2SRModelTester:
|
||||
class Swin2SRModelTest(ModelTesterMixin, PipelineTesterMixin, unittest.TestCase):
|
||||
all_model_classes = (Swin2SRModel, Swin2SRForImageSuperResolution) if is_torch_available() else ()
|
||||
pipeline_model_mapping = (
|
||||
{"feature-extraction": Swin2SRModel, "image-to-image": Swin2SRForImageSuperResolution}
|
||||
{"image-feature-extraction": Swin2SRModel, "image-to-image": Swin2SRForImageSuperResolution}
|
||||
if is_torch_available()
|
||||
else {}
|
||||
)
|
||||
|
||||
@@ -217,7 +217,7 @@ class Swinv2ModelTest(ModelTesterMixin, PipelineTesterMixin, unittest.TestCase):
|
||||
else ()
|
||||
)
|
||||
pipeline_model_mapping = (
|
||||
{"feature-extraction": Swinv2Model, "image-classification": Swinv2ForImageClassification}
|
||||
{"image-feature-extraction": Swinv2Model, "image-classification": Swinv2ForImageClassification}
|
||||
if is_torch_available()
|
||||
else {}
|
||||
)
|
||||
|
||||
@@ -200,7 +200,7 @@ class TableTransformerModelTest(ModelTesterMixin, GenerationTesterMixin, Pipelin
|
||||
else ()
|
||||
)
|
||||
pipeline_model_mapping = (
|
||||
{"feature-extraction": TableTransformerModel, "object-detection": TableTransformerForObjectDetection}
|
||||
{"image-feature-extraction": TableTransformerModel, "object-detection": TableTransformerForObjectDetection}
|
||||
if is_torch_available()
|
||||
else {}
|
||||
)
|
||||
|
||||
@@ -228,7 +228,7 @@ class ViltModelTest(ModelTesterMixin, PipelineTesterMixin, unittest.TestCase):
|
||||
else ()
|
||||
)
|
||||
pipeline_model_mapping = (
|
||||
{"feature-extraction": ViltModel, "visual-question-answering": ViltForQuestionAnswering}
|
||||
{"image-feature-extraction": ViltModel, "visual-question-answering": ViltForQuestionAnswering}
|
||||
if is_torch_available()
|
||||
else {}
|
||||
)
|
||||
|
||||
@@ -193,7 +193,7 @@ class ViTModelTest(ModelTesterMixin, PipelineTesterMixin, unittest.TestCase):
|
||||
else ()
|
||||
)
|
||||
pipeline_model_mapping = (
|
||||
{"feature-extraction": ViTModel, "image-classification": ViTForImageClassification}
|
||||
{"image-feature-extraction": ViTModel, "image-classification": ViTForImageClassification}
|
||||
if is_torch_available()
|
||||
else {}
|
||||
)
|
||||
|
||||
@@ -156,7 +156,7 @@ class ViTHybridModelTest(ModelTesterMixin, PipelineTesterMixin, unittest.TestCas
|
||||
|
||||
all_model_classes = (ViTHybridModel, ViTHybridForImageClassification) if is_torch_available() else ()
|
||||
pipeline_model_mapping = (
|
||||
{"feature-extraction": ViTHybridModel, "image-classification": ViTHybridForImageClassification}
|
||||
{"image-feature-extraction": ViTHybridModel, "image-classification": ViTHybridForImageClassification}
|
||||
if is_torch_available()
|
||||
else {}
|
||||
)
|
||||
|
||||
@@ -164,7 +164,7 @@ class ViTMAEModelTest(ModelTesterMixin, PipelineTesterMixin, unittest.TestCase):
|
||||
"""
|
||||
|
||||
all_model_classes = (ViTMAEModel, ViTMAEForPreTraining) if is_torch_available() else ()
|
||||
pipeline_model_mapping = {"feature-extraction": ViTMAEModel} if is_torch_available() else {}
|
||||
pipeline_model_mapping = {"image-feature-extraction": ViTMAEModel} if is_torch_available() else {}
|
||||
|
||||
test_pruning = False
|
||||
test_torchscript = False
|
||||
|
||||
@@ -152,7 +152,7 @@ class ViTMSNModelTest(ModelTesterMixin, PipelineTesterMixin, unittest.TestCase):
|
||||
|
||||
all_model_classes = (ViTMSNModel, ViTMSNForImageClassification) if is_torch_available() else ()
|
||||
pipeline_model_mapping = (
|
||||
{"feature-extraction": ViTMSNModel, "image-classification": ViTMSNForImageClassification}
|
||||
{"image-feature-extraction": ViTMSNModel, "image-classification": ViTMSNForImageClassification}
|
||||
if is_torch_available()
|
||||
else {}
|
||||
)
|
||||
|
||||
@@ -168,7 +168,9 @@ class YolosModelTest(ModelTesterMixin, PipelineTesterMixin, unittest.TestCase):
|
||||
|
||||
all_model_classes = (YolosModel, YolosForObjectDetection) if is_torch_available() else ()
|
||||
pipeline_model_mapping = (
|
||||
{"feature-extraction": YolosModel, "object-detection": YolosForObjectDetection} if is_torch_available() else {}
|
||||
{"image-feature-extraction": YolosModel, "object-detection": YolosForObjectDetection}
|
||||
if is_torch_available()
|
||||
else {}
|
||||
)
|
||||
|
||||
test_pruning = False
|
||||
|
||||
Reference in New Issue
Block a user