-
Notifications
You must be signed in to change notification settings - Fork 27.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Don't use LayoutLMv2
and LayoutLMv3
in some pipeline tests
#22774
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -289,10 +289,6 @@ class LayoutLMv3ModelTest(ModelTesterMixin, PipelineTesterMixin, unittest.TestCa | |
{ | ||
"document-question-answering": LayoutLMv3ForQuestionAnswering, | ||
"feature-extraction": LayoutLMv3Model, | ||
"question-answering": LayoutLMv3ForQuestionAnswering, | ||
"text-classification": LayoutLMv3ForSequenceClassification, | ||
"token-classification": LayoutLMv3ForTokenClassification, | ||
"zero-shot": LayoutLMv3ForSequenceClassification, | ||
} | ||
if is_torch_available() | ||
else {} | ||
|
@@ -302,6 +298,10 @@ class LayoutLMv3ModelTest(ModelTesterMixin, PipelineTesterMixin, unittest.TestCa | |
def is_pipeline_test_to_skip( | ||
self, pipeline_test_casse_name, config_class, model_architecture, tokenizer_name, processor_name | ||
): | ||
# `DocumentQuestionAnsweringPipeline` is expected to work with this model, but it combines the text and visual | ||
# embedding along the sequence dimension (dim 1), which causes an error during post-processing as `p_mask` has | ||
# the sequence dimension of the text embedding only. | ||
# (see the line `embedding_output = torch.cat([embedding_output, visual_embeddings], dim=1)`) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. cc @NielsRogge We might need to discuss this at some point. |
||
return True | ||
|
||
def setUp(self): | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,11 +34,20 @@ | |
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} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is to avoid the changes of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This also makes things more explicit: those models are not for this pipeline (test) |
||
|
||
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 | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove all these - we just don't add these to be tested in the first place