



"""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  snake_case     (							unittest.TestCase   ):
							UpperCAmelCase__						     =      MODEL_FOR_VIDEO_CLASSIFICATION_MAPPING

							def _lowercase					(self       ,       SCREAMING_SNAKE_CASE_       ,       SCREAMING_SNAKE_CASE_       ,       SCREAMING_SNAKE_CASE_    ):

									"""simple docstring"""







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

							def _lowercase					(self       ,       SCREAMING_SNAKE_CASE_       ,       SCREAMING_SNAKE_CASE_    ):

									"""simple docstring"""







									for example in examples:
											SCREAMING_SNAKE_CASE_						 = video_classifier(_A    )

											self.assertEqual(
											    _A       ,       [
											        {'''score''': ANY(_A    ), '''label''': ANY(_A    )},
											        {'''score''': ANY(_A    ), '''label''': ANY(_A    )},
											    ]       ,       )

							@require_torch
							def _lowercase					(self    ):

									"""simple docstring"""







									SCREAMING_SNAKE_CASE_						 = '''hf-internal-testing/tiny-random-VideoMAEForVideoClassification'''
									SCREAMING_SNAKE_CASE_						 = VideoMAEFeatureExtractor(
									    size={'''shortest_edge''': 10}       ,       crop_size={'''height''': 10, '''width''': 10}    )
									SCREAMING_SNAKE_CASE_						 = pipeline(
									    '''video-classification'''       ,       model=_A       ,       feature_extractor=_A       ,       frame_sampling_rate=4    )

									SCREAMING_SNAKE_CASE_						 = hf_hub_download(repo_id='''nateraw/video-demo'''       ,       filename='''archery.mp4'''       ,       repo_type='''dataset'''    )
									SCREAMING_SNAKE_CASE_						 = video_classifier(_A       ,       top_k=2    )
									self.assertEqual(
									    nested_simplify(_A       ,       decimals=4    )       ,       [{'''score''': 0.51_99, '''label''': '''LABEL_0'''}, {'''score''': 0.48_01, '''label''': '''LABEL_1'''}]       ,       )

									SCREAMING_SNAKE_CASE_						 = video_classifier(
									    [
									        video_file_path,
									        video_file_path,
									    ]       ,       top_k=2       ,       )
									self.assertEqual(
									    nested_simplify(_A       ,       decimals=4    )       ,       [
									        [{'''score''': 0.51_99, '''label''': '''LABEL_0'''}, {'''score''': 0.48_01, '''label''': '''LABEL_1'''}],
									        [{'''score''': 0.51_99, '''label''': '''LABEL_0'''}, {'''score''': 0.48_01, '''label''': '''LABEL_1'''}],
									    ]       ,       )







							@require_tf
							def _lowercase					(self    ):

									"""simple docstring"""







									pass

"""simple docstring"""




from ...configuration_utils import PretrainedConfig
from ...utils import logging


lowerCAmelCase__							=				logging.get_logger(__name__)

lowerCAmelCase__							=				{
    'vinvino02/glpn-kitti': 'https://huggingface.co/vinvino02/glpn-kitti/resolve/main/config.json',
    # See all GLPN models at https://huggingface.co/models?filter=glpn
}





class  snake_case     (							__lowercase   ):
							UpperCAmelCase__						     =      '''glpn'''

							def __init__(self       ,       SCREAMING_SNAKE_CASE_=3       ,       SCREAMING_SNAKE_CASE_=4       ,       SCREAMING_SNAKE_CASE_=[2, 2, 2, 2]       ,       SCREAMING_SNAKE_CASE_=[8, 4, 2, 1]       ,       SCREAMING_SNAKE_CASE_=[32, 64, 1_60, 2_56]       ,       SCREAMING_SNAKE_CASE_=[7, 3, 3, 3]       ,       SCREAMING_SNAKE_CASE_=[4, 2, 2, 2]       ,       SCREAMING_SNAKE_CASE_=[1, 2, 5, 8]       ,       SCREAMING_SNAKE_CASE_=[4, 4, 4, 4]       ,       SCREAMING_SNAKE_CASE_="gelu"       ,       SCREAMING_SNAKE_CASE_=0.0       ,       SCREAMING_SNAKE_CASE_=0.0       ,       SCREAMING_SNAKE_CASE_=0.02       ,       SCREAMING_SNAKE_CASE_=0.1       ,       SCREAMING_SNAKE_CASE_=1e-6       ,       SCREAMING_SNAKE_CASE_=64       ,       SCREAMING_SNAKE_CASE_=10       ,       SCREAMING_SNAKE_CASE_=-1       ,       **SCREAMING_SNAKE_CASE_       ,       ):

									"""simple docstring"""







									super().__init__(**SCREAMING_SNAKE_CASE_    )

									SCREAMING_SNAKE_CASE_						 = num_channels
									SCREAMING_SNAKE_CASE_						 = num_encoder_blocks
									SCREAMING_SNAKE_CASE_						 = depths
									SCREAMING_SNAKE_CASE_						 = sr_ratios
									SCREAMING_SNAKE_CASE_						 = hidden_sizes
									SCREAMING_SNAKE_CASE_						 = patch_sizes
									SCREAMING_SNAKE_CASE_						 = strides
									SCREAMING_SNAKE_CASE_						 = mlp_ratios
									SCREAMING_SNAKE_CASE_						 = num_attention_heads
									SCREAMING_SNAKE_CASE_						 = hidden_act
									SCREAMING_SNAKE_CASE_						 = hidden_dropout_prob
									SCREAMING_SNAKE_CASE_						 = attention_probs_dropout_prob
									SCREAMING_SNAKE_CASE_						 = initializer_range
									SCREAMING_SNAKE_CASE_						 = drop_path_rate
									SCREAMING_SNAKE_CASE_						 = layer_norm_eps
									SCREAMING_SNAKE_CASE_						 = decoder_hidden_size
									SCREAMING_SNAKE_CASE_						 = max_depth
									SCREAMING_SNAKE_CASE_						 = head_in_index