Make ASR pipeline compliant with Hub spec + add tests (#33769)
* Remove max_new_tokens arg * Add ASR pipeline to testing * make fixup * Factor the output test out into a util * Full error reporting * Full error reporting * Update src/transformers/pipelines/automatic_speech_recognition.py Co-authored-by: Lysandre Debut <hi@lysand.re> * Small comment --------- Co-authored-by: Lysandre Debut <hi@lysand.re>
This commit is contained in:
@@ -13,7 +13,6 @@
|
||||
# limitations under the License.
|
||||
|
||||
import unittest
|
||||
from dataclasses import fields
|
||||
|
||||
import numpy as np
|
||||
from huggingface_hub import AudioClassificationOutputElement
|
||||
@@ -21,6 +20,7 @@ from huggingface_hub import AudioClassificationOutputElement
|
||||
from transformers import MODEL_FOR_AUDIO_CLASSIFICATION_MAPPING, TF_MODEL_FOR_AUDIO_CLASSIFICATION_MAPPING
|
||||
from transformers.pipelines import AudioClassificationPipeline, pipeline
|
||||
from transformers.testing_utils import (
|
||||
compare_pipeline_output_to_hub_spec,
|
||||
is_pipeline_test,
|
||||
nested_simplify,
|
||||
require_tf,
|
||||
@@ -68,10 +68,8 @@ class AudioClassificationPipelineTests(unittest.TestCase):
|
||||
|
||||
self.run_torchaudio(audio_classifier)
|
||||
|
||||
spec_output_keys = {field.name for field in fields(AudioClassificationOutputElement)}
|
||||
for single_output in output:
|
||||
output_keys = set(single_output.keys())
|
||||
self.assertEqual(spec_output_keys, output_keys, msg="Pipeline output keys do not match HF Hub spec!")
|
||||
compare_pipeline_output_to_hub_spec(single_output, AudioClassificationOutputElement)
|
||||
|
||||
@require_torchaudio
|
||||
def run_torchaudio(self, audio_classifier):
|
||||
|
||||
Reference in New Issue
Block a user