mirror of
https://github.com/huggingface/transformers.git
synced 2025-07-03 12:50:06 +06:00
Try to avoid/reduce some remaining CI job failures (#37202)
* try * try * Update tests/pipelines/test_pipelines_video_classification.py Co-authored-by: Joao Gante <joaofranciscocardosogante@gmail.com> --------- Co-authored-by: ydshieh <ydshieh@users.noreply.github.com> Co-authored-by: Joao Gante <joaofranciscocardosogante@gmail.com>
This commit is contained in:
parent
6f5dc9c82e
commit
adfc91cd46
@ -19,6 +19,7 @@ from huggingface_hub import VideoClassificationOutputElement, hf_hub_download
|
|||||||
from transformers import MODEL_FOR_VIDEO_CLASSIFICATION_MAPPING, VideoMAEFeatureExtractor
|
from transformers import MODEL_FOR_VIDEO_CLASSIFICATION_MAPPING, VideoMAEFeatureExtractor
|
||||||
from transformers.pipelines import VideoClassificationPipeline, pipeline
|
from transformers.pipelines import VideoClassificationPipeline, pipeline
|
||||||
from transformers.testing_utils import (
|
from transformers.testing_utils import (
|
||||||
|
_run_pipeline_tests,
|
||||||
compare_pipeline_output_to_hub_spec,
|
compare_pipeline_output_to_hub_spec,
|
||||||
is_pipeline_test,
|
is_pipeline_test,
|
||||||
nested_simplify,
|
nested_simplify,
|
||||||
@ -39,6 +40,11 @@ from .test_pipelines_common import ANY
|
|||||||
class VideoClassificationPipelineTests(unittest.TestCase):
|
class VideoClassificationPipelineTests(unittest.TestCase):
|
||||||
model_mapping = MODEL_FOR_VIDEO_CLASSIFICATION_MAPPING
|
model_mapping = MODEL_FOR_VIDEO_CLASSIFICATION_MAPPING
|
||||||
|
|
||||||
|
if _run_pipeline_tests:
|
||||||
|
example_video_filepath = hf_hub_download(
|
||||||
|
repo_id="nateraw/video-demo", filename="archery.mp4", repo_type="dataset"
|
||||||
|
)
|
||||||
|
|
||||||
def get_test_pipeline(
|
def get_test_pipeline(
|
||||||
self,
|
self,
|
||||||
model,
|
model,
|
||||||
@ -48,9 +54,6 @@ class VideoClassificationPipelineTests(unittest.TestCase):
|
|||||||
processor=None,
|
processor=None,
|
||||||
torch_dtype="float32",
|
torch_dtype="float32",
|
||||||
):
|
):
|
||||||
example_video_filepath = hf_hub_download(
|
|
||||||
repo_id="nateraw/video-demo", filename="archery.mp4", repo_type="dataset"
|
|
||||||
)
|
|
||||||
video_classifier = VideoClassificationPipeline(
|
video_classifier = VideoClassificationPipeline(
|
||||||
model=model,
|
model=model,
|
||||||
tokenizer=tokenizer,
|
tokenizer=tokenizer,
|
||||||
@ -61,8 +64,9 @@ class VideoClassificationPipelineTests(unittest.TestCase):
|
|||||||
top_k=2,
|
top_k=2,
|
||||||
)
|
)
|
||||||
examples = [
|
examples = [
|
||||||
example_video_filepath,
|
self.example_video_filepath,
|
||||||
"https://huggingface.co/datasets/nateraw/video-demo/resolve/main/archery.mp4",
|
# TODO: re-enable this once we have a stable hub solution for CI
|
||||||
|
# "https://huggingface.co/datasets/nateraw/video-demo/resolve/main/archery.mp4",
|
||||||
]
|
]
|
||||||
return video_classifier, examples
|
return video_classifier, examples
|
||||||
|
|
||||||
|
@ -39,6 +39,9 @@ if is_librosa_available():
|
|||||||
|
|
||||||
|
|
||||||
class AudioUtilsFunctionTester(unittest.TestCase):
|
class AudioUtilsFunctionTester(unittest.TestCase):
|
||||||
|
# will be set in `def _load_datasamples`
|
||||||
|
_dataset = None
|
||||||
|
|
||||||
def test_hertz_to_mel(self):
|
def test_hertz_to_mel(self):
|
||||||
self.assertEqual(hertz_to_mel(0.0), 0.0)
|
self.assertEqual(hertz_to_mel(0.0), 0.0)
|
||||||
self.assertAlmostEqual(hertz_to_mel(100), 150.48910241)
|
self.assertAlmostEqual(hertz_to_mel(100), 150.48910241)
|
||||||
@ -274,8 +277,9 @@ class AudioUtilsFunctionTester(unittest.TestCase):
|
|||||||
def _load_datasamples(self, num_samples):
|
def _load_datasamples(self, num_samples):
|
||||||
from datasets import load_dataset
|
from datasets import load_dataset
|
||||||
|
|
||||||
ds = load_dataset("hf-internal-testing/librispeech_asr_dummy", "clean", split="validation")
|
if self._dataset is None:
|
||||||
speech_samples = ds.sort("id").select(range(num_samples))[:num_samples]["audio"]
|
self._dataset = load_dataset("hf-internal-testing/librispeech_asr_dummy", "clean", split="validation")
|
||||||
|
speech_samples = self._dataset.sort("id").select(range(num_samples))[:num_samples]["audio"]
|
||||||
return [x["array"] for x in speech_samples]
|
return [x["array"] for x in speech_samples]
|
||||||
|
|
||||||
def test_spectrogram_impulse(self):
|
def test_spectrogram_impulse(self):
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
from huggingface_hub import hf_hub_download
|
||||||
|
|
||||||
from transformers.testing_utils import _run_pipeline_tests
|
from transformers.testing_utils import _run_pipeline_tests
|
||||||
|
|
||||||
|
|
||||||
@ -7,3 +9,4 @@ if __name__ == "__main__":
|
|||||||
|
|
||||||
_ = datasets.load_dataset("hf-internal-testing/librispeech_asr_dummy", "clean", split="validation")
|
_ = datasets.load_dataset("hf-internal-testing/librispeech_asr_dummy", "clean", split="validation")
|
||||||
_ = datasets.load_dataset("hf-internal-testing/fixtures_image_utils", split="test", revision="refs/pr/1")
|
_ = datasets.load_dataset("hf-internal-testing/fixtures_image_utils", split="test", revision="refs/pr/1")
|
||||||
|
_ = hf_hub_download(repo_id="nateraw/video-demo", filename="archery.mp4", repo_type="dataset")
|
||||||
|
Loading…
Reference in New Issue
Block a user