Compare commits

...

2 Commits

Author SHA1 Message Date
a586984ab6 Black version. 2022-08-01 11:43:59 +02:00
d72ac38772 Adding a better error message when the model is improperly configured
within transformers.
2022-08-01 11:08:05 +02:00
2 changed files with 29 additions and 0 deletions

View File

@ -667,6 +667,19 @@ def pipeline(
# the files could be missing from the hub, instead of failing
# on such repos, we just force to not load it.
load_tokenizer = False
if not load_feature_extractor and task not in NO_FEATURE_EXTRACTOR_TASKS:
raise EnvironmentError(
f"There is a problem in `transformers`. The task {task} requires a feature extractor, however the model"
f" {type(model_config)} seems to not support feature-extractors. Please report this issue. This is likely"
" a misconfiguration in the library, please report this issue."
)
if not load_tokenizer and task not in NO_TOKENIZER_TASKS:
raise EnvironmentError(
f"There is a problem in `transformers`. The task {task} requires a tokenizer, however the model"
f" {type(model_config)} seems to not support tokenizer. This is likely a misconfiguration in the library,"
" please report this issue."
)
if task in NO_FEATURE_EXTRACTOR_TASKS:
load_feature_extractor = False

View File

@ -172,6 +172,22 @@ class ZeroShotImageClassificationPipelineTests(unittest.TestCase, metaclass=Pipe
],
)
@slow
@require_torch
def test_large_model_misconfigured(self):
# XXX this should be a fast test, but the triggering arch
# VisionTextDualEncoderModel is missing for small tests
# https://huggingface.co/hf-internal-testing
# This test will also start to fail, once this architecture
# correctly defines AutoFeatureExtractor. At this point
# we can safely remove this test as we don't really want
# to keep around an invalid model around just for this.
with self.assertRaises(EnvironmentError):
pipeline(
task="zero-shot-image-classification",
model="Bingsu/vitB32_bert_ko_small_clip",
)
@slow
@require_torch
def test_large_model_pt(self):