



"""simple docstring"""

import unittest

from huggingface_hub import hf_hub_download

from transformers import MODEL_FOR_VIDEO_CLASSIFICATION_MAPPING, VideoMAEFeatureExtractor
from transformers.pipelines import VideoClassificationPipeline, pipeline
from transformers.testing_utils import (
    is_pipeline_test,
    nested_simplify,
    require_decord,
    require_tf,
    require_torch,
    require_torch_or_tf,
    require_vision,
)

from .test_pipelines_common import ANY




@is_pipeline_test
@require_torch_or_tf
@require_vision
@require_decord
class SCREAMING_SNAKE_CASE__					(		unittest.TestCase      ):
						_lowerCAmelCase							=					MODEL_FOR_VIDEO_CLASSIFICATION_MAPPING



						def     lowerCAmelCase__(self						,     _lowercase						,     _lowercase						,     _lowercase							):





													'''simple docstring'''

													__a		:		str									=       hf_hub_download(
													    repo_id="""nateraw/video-demo"""						,     filename="""archery.mp4"""						,     repo_type="""dataset"""							)
													__a		:		str									=       VideoClassificationPipeline(model=_lowercase						,     image_processor=_lowercase						,     top_k=2							)
													__a		:		Any									=       [
													    example_video_filepath,
													    """https://huggingface.co/datasets/nateraw/video-demo/resolve/main/archery.mp4""",
													]
													return video_classifier, examples



						def     lowerCAmelCase__(self						,     _lowercase						,     _lowercase							):





													'''simple docstring'''

													for example in examples:
																				__a		:		Dict									=       video_classifier(_lowercase							)

																				self.assertEqual(
																				    _lowercase						,     [
																				        {"""score""": ANY(_lowercase							), """label""": ANY(_lowercase							)},
																				        {"""score""": ANY(_lowercase							), """label""": ANY(_lowercase							)},
																				    ]						,     )



						@require_torch
						def     lowerCAmelCase__(self							):





													'''simple docstring'''

													__a		:		Optional[Any]									=       """hf-internal-testing/tiny-random-VideoMAEForVideoClassification"""
													__a		:		Tuple									=       VideoMAEFeatureExtractor(
													    size={"""shortest_edge""": 10}						,     crop_size={"""height""": 10, """width""": 10}							)
													__a		:		Any									=       pipeline(
													    """video-classification"""						,     model=_lowercase						,     feature_extractor=_lowercase						,     frame_sampling_rate=4							)

													__a		:		Dict									=       hf_hub_download(repo_id="""nateraw/video-demo"""						,     filename="""archery.mp4"""						,     repo_type="""dataset"""							)
													__a		:		str									=       video_classifier(_lowercase						,     top_k=2							)
													self.assertEqual(
													    nested_simplify(_lowercase						,     decimals=4							)						,     [{"""score""": 0.5199, """label""": """LABEL_0"""}, {"""score""": 0.4801, """label""": """LABEL_1"""}]						,     )

													__a		:		List[Any]									=       video_classifier(
													    [
													        video_file_path,
													        video_file_path,
													    ]						,     top_k=2						,     )
													self.assertEqual(
													    nested_simplify(_lowercase						,     decimals=4							)						,     [
													        [{"""score""": 0.5199, """label""": """LABEL_0"""}, {"""score""": 0.4801, """label""": """LABEL_1"""}],
													        [{"""score""": 0.5199, """label""": """LABEL_0"""}, {"""score""": 0.4801, """label""": """LABEL_1"""}],
													    ]						,     )





						@require_tf
						def     lowerCAmelCase__(self							):





													'''simple docstring'''

													pass






"""simple docstring"""

from dataclasses import dataclass
from enum import Enum
from typing import List, Optional, Union

import numpy as np
import PIL
from PIL import Image

from ...utils import BaseOutput, is_torch_available, is_transformers_available




@dataclass
class SCREAMING_SNAKE_CASE__					(		__snake_case      ):
						_lowerCAmelCase							=					42
						_lowerCAmelCase							=					42


if is_transformers_available() and is_torch_available():
	from .pipeline_semantic_stable_diffusion import SemanticStableDiffusionPipeline

