Skip to content

Fix bug about accessing model.config when model is None in pipeline#301

Merged
regisss merged 3 commits into
huggingface:mainfrom
regisss:fix_bug_pipeline
Jul 18, 2022
Merged

Fix bug about accessing model.config when model is None in pipeline#301
regisss merged 3 commits into
huggingface:mainfrom
regisss:fix_bug_pipeline

Conversation

@regisss
Copy link
Copy Markdown
Contributor

@regisss regisss commented Jul 17, 2022

What does this PR do?

This PR fixes the issue mentioned in #297: when instantiating a pipeline with pipe = pipeline(task=my_task), the given model is None and we get the following error:

Traceback (most recent call last):
  File "test_yolos.py", line 3, in <module>
    classifier = pipeline(task="zero-shot-classification", accelerator="ort")
  File "/home/regis/HuggingFace/dev/tmp_venv/lib/python3.8/site-packages/optimum/pipelines.py", line 113, in pipeline
    load_tokenizer = type(model.config) in TOKENIZER_MAPPING or model.config.tokenizer_class is not None
AttributeError: 'NoneType' object has no attribute 'config'

With this PR, model.config is not accessed anymore to set load_tokenizer and load_feature_extractor. Tests have been added to automatically check this behaviour.

Also:

  • the current version number is bumped,
  • we were using the pipeline method from Transformers in tests/onnxruntime/test_modeling.py, this is changed for the pipeline method of Optimum.

Before submitting

  • This PR fixes a typo or improves the docs (you can dismiss the other checks if that's the case).
  • Did you make sure to update the documentation with your changes?
  • Did you write any new necessary tests?

@HuggingFaceDocBuilderDev
Copy link
Copy Markdown

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint.

Copy link
Copy Markdown
Contributor

@philschmid philschmid left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@regisss regisss requested a review from philschmid July 18, 2022 09:27
Copy link
Copy Markdown
Contributor

@philschmid philschmid left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Nice that you reused the transformer's things of doing it. ✅

@regisss regisss merged commit fab5d45 into huggingface:main Jul 18, 2022
@regisss regisss deleted the fix_bug_pipeline branch July 18, 2022 16:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants