Don't use LayoutLMv2 and LayoutLMv3 in some pipeline tests (#22774)
* fix --------- Co-authored-by: ydshieh <ydshieh@users.noreply.github.com>
This commit is contained in:
@@ -34,11 +34,20 @@ from transformers.testing_utils import (
|
||||
from .test_pipelines_common import ANY
|
||||
|
||||
|
||||
# These 2 model types require different inputs than those of the usual text models.
|
||||
_TO_SKIP = {"LayoutLMv2Config", "LayoutLMv3Config"}
|
||||
|
||||
|
||||
@is_pipeline_test
|
||||
class QAPipelineTests(unittest.TestCase):
|
||||
model_mapping = MODEL_FOR_QUESTION_ANSWERING_MAPPING
|
||||
tf_model_mapping = TF_MODEL_FOR_QUESTION_ANSWERING_MAPPING
|
||||
|
||||
if model_mapping is not None:
|
||||
model_mapping = {config: model for config, model in model_mapping.items() if config.__name__ in _TO_SKIP}
|
||||
if tf_model_mapping is not None:
|
||||
tf_model_mapping = {config: model for config, model in tf_model_mapping.items() if config.__name__ in _TO_SKIP}
|
||||
|
||||
def get_test_pipeline(self, model, tokenizer, processor):
|
||||
if isinstance(model.config, LxmertConfig):
|
||||
# This is an bimodal model, we need to find a more consistent way
|
||||
|
||||
@@ -25,11 +25,20 @@ from transformers.testing_utils import is_pipeline_test, nested_simplify, requir
|
||||
from .test_pipelines_common import ANY
|
||||
|
||||
|
||||
# These 2 model types require different inputs than those of the usual text models.
|
||||
_TO_SKIP = {"LayoutLMv2Config", "LayoutLMv3Config"}
|
||||
|
||||
|
||||
@is_pipeline_test
|
||||
class TextClassificationPipelineTests(unittest.TestCase):
|
||||
model_mapping = MODEL_FOR_SEQUENCE_CLASSIFICATION_MAPPING
|
||||
tf_model_mapping = TF_MODEL_FOR_SEQUENCE_CLASSIFICATION_MAPPING
|
||||
|
||||
if model_mapping is not None:
|
||||
model_mapping = {config: model for config, model in model_mapping.items() if config.__name__ in _TO_SKIP}
|
||||
if tf_model_mapping is not None:
|
||||
tf_model_mapping = {config: model for config, model in tf_model_mapping.items() if config.__name__ in _TO_SKIP}
|
||||
|
||||
@require_torch
|
||||
def test_small_model_pt(self):
|
||||
text_classifier = pipeline(
|
||||
|
||||
@@ -39,12 +39,20 @@ from .test_pipelines_common import ANY
|
||||
|
||||
VALID_INPUTS = ["A simple string", ["list of strings", "A simple string that is quite a bit longer"]]
|
||||
|
||||
# These 2 model types require different inputs than those of the usual text models.
|
||||
_TO_SKIP = {"LayoutLMv2Config", "LayoutLMv3Config"}
|
||||
|
||||
|
||||
@is_pipeline_test
|
||||
class TokenClassificationPipelineTests(unittest.TestCase):
|
||||
model_mapping = MODEL_FOR_TOKEN_CLASSIFICATION_MAPPING
|
||||
tf_model_mapping = TF_MODEL_FOR_TOKEN_CLASSIFICATION_MAPPING
|
||||
|
||||
if model_mapping is not None:
|
||||
model_mapping = {config: model for config, model in model_mapping.items() if config.__name__ in _TO_SKIP}
|
||||
if tf_model_mapping is not None:
|
||||
tf_model_mapping = {config: model for config, model in tf_model_mapping.items() if config.__name__ in _TO_SKIP}
|
||||
|
||||
def get_test_pipeline(self, model, tokenizer, processor):
|
||||
token_classifier = TokenClassificationPipeline(model=model, tokenizer=tokenizer)
|
||||
return token_classifier, ["A simple string", "A simple string that is quite a bit longer"]
|
||||
|
||||
@@ -26,11 +26,20 @@ from transformers.testing_utils import is_pipeline_test, nested_simplify, requir
|
||||
from .test_pipelines_common import ANY
|
||||
|
||||
|
||||
# These 2 model types require different inputs than those of the usual text models.
|
||||
_TO_SKIP = {"LayoutLMv2Config", "LayoutLMv3Config"}
|
||||
|
||||
|
||||
@is_pipeline_test
|
||||
class ZeroShotClassificationPipelineTests(unittest.TestCase):
|
||||
model_mapping = MODEL_FOR_SEQUENCE_CLASSIFICATION_MAPPING
|
||||
tf_model_mapping = TF_MODEL_FOR_SEQUENCE_CLASSIFICATION_MAPPING
|
||||
|
||||
if model_mapping is not None:
|
||||
model_mapping = {config: model for config, model in model_mapping.items() if config.__name__ in _TO_SKIP}
|
||||
if tf_model_mapping is not None:
|
||||
tf_model_mapping = {config: model for config, model in tf_model_mapping.items() if config.__name__ in _TO_SKIP}
|
||||
|
||||
def get_test_pipeline(self, model, tokenizer, processor):
|
||||
classifier = ZeroShotClassificationPipeline(
|
||||
model=model, tokenizer=tokenizer, candidate_labels=["polics", "health"]
|
||||
|
||||
Reference in New Issue
Block a user