


'''simple docstring'''







import unittest

from transformers import MODEL_FOR_ZERO_SHOT_OBJECT_DETECTION_MAPPING, is_vision_available, pipeline
from transformers.testing_utils import (
    is_pipeline_test,
    nested_simplify,
    require_tf,
    require_torch,
    require_vision,
    slow,
)

from .test_pipelines_common import ANY


if is_vision_available():
					from PIL import Image
else:


					class 					__a      :

												@staticmethod
												def     UpperCAmelCase__	(							*__magic_name__							:     Optional[Any]       ,     **__magic_name__							:     Tuple   )					->       int:







																		"""simple docstring"""
																		pass


@is_pipeline_test
@require_vision
@require_torch
class 					__a      (unittest.TestCase     ):
							__a					:   Union[str, Any]									=       MODEL_FOR_ZERO_SHOT_OBJECT_DETECTION_MAPPING

							def     UpperCAmelCase__	(							self							:     Optional[Any]       ,     __magic_name__							:     Union[str, Any]       ,     __magic_name__							:     Tuple       ,     __magic_name__							:     str   )					->       Optional[Any]:







													"""simple docstring"""
													UpperCAmelCase_			:      Dict     						=  pipeline(
													    '''zero-shot-object-detection'''       ,     model='''hf-internal-testing/tiny-random-owlvit-object-detection'''   )

													UpperCAmelCase_			:      int     						=  [
													    {
													        '''image''': '''./tests/fixtures/tests_samples/COCO/000000039769.png''',
													        '''candidate_labels''': ['''cat''', '''remote''', '''couch'''],
													    }
													]
													return object_detector, examples

							def     UpperCAmelCase__	(							self							:     Optional[int]       ,     __magic_name__							:     Optional[Any]       ,     __magic_name__							:     Optional[int]   )					->       List[Any]:







													"""simple docstring"""
													UpperCAmelCase_			:      str     						=  object_detector(examples[0]       ,     threshold=0.0   )

													UpperCAmelCase_			:      int     						=  len(__magic_name__   )
													self.assertGreater(__magic_name__       ,     0   )
													self.assertEqual(
													    __magic_name__       ,     [
													        {
													            '''score''': ANY(__magic_name__   ),
													            '''label''': ANY(__magic_name__   ),
													            '''box''': {'''xmin''': ANY(__magic_name__   ), '''ymin''': ANY(__magic_name__   ), '''xmax''': ANY(__magic_name__   ), '''ymax''': ANY(__magic_name__   )},
													        }
													        for i in range(__magic_name__   )
													    ]       ,     )

							@require_tf
							@unittest.skip('''Zero Shot Object Detection not implemented in TF'''   )
							def     UpperCAmelCase__	(							self							:     str   )					->       Optional[int]:







													"""simple docstring"""
													pass

							@require_torch
							def     UpperCAmelCase__	(							self							:     str   )					->       Tuple:







													"""simple docstring"""
													UpperCAmelCase_			:      Tuple     						=  pipeline(
													    '''zero-shot-object-detection'''       ,     model='''hf-internal-testing/tiny-random-owlvit-object-detection'''   )

													UpperCAmelCase_			:      List[Any]     						=  object_detector(
													    '''./tests/fixtures/tests_samples/COCO/000000039769.png'''       ,     candidate_labels=['''cat''', '''remote''', '''couch''']       ,     threshold=0.6_4       ,     )

													self.assertEqual(
													    nested_simplify(__magic_name__       ,     decimals=4   )       ,     [
													        {'''score''': 0.7_2_3_5, '''label''': '''cat''', '''box''': {'''xmin''': 2_04, '''ymin''': 1_67, '''xmax''': 2_32, '''ymax''': 1_90}},
													        {'''score''': 0.7_2_1_8, '''label''': '''remote''', '''box''': {'''xmin''': 2_04, '''ymin''': 1_67, '''xmax''': 2_32, '''ymax''': 1_90}},
													        {'''score''': 0.7_1_8_4, '''label''': '''couch''', '''box''': {'''xmin''': 2_04, '''ymin''': 1_67, '''xmax''': 2_32, '''ymax''': 1_90}},
													        {'''score''': 0.6_7_4_8, '''label''': '''remote''', '''box''': {'''xmin''': 5_71, '''ymin''': 83, '''xmax''': 5_98, '''ymax''': 1_03}},
													        {'''score''': 0.6_6_5_6, '''label''': '''cat''', '''box''': {'''xmin''': 5_71, '''ymin''': 83, '''xmax''': 5_98, '''ymax''': 1_03}},
													        {'''score''': 0.6_6_1_4, '''label''': '''couch''', '''box''': {'''xmin''': 5_71, '''ymin''': 83, '''xmax''': 5_98, '''ymax''': 1_03}},
													        {'''score''': 0.6_4_5_6, '''label''': '''remote''', '''box''': {'''xmin''': 4_94, '''ymin''': 1_05, '''xmax''': 5_21, '''ymax''': 1_27}},
													        {'''score''': 0.6_4_2, '''label''': '''remote''', '''box''': {'''xmin''': 67, '''ymin''': 2_74, '''xmax''': 93, '''ymax''': 2_97}},
													        {'''score''': 0.6_4_1_9, '''label''': '''cat''', '''box''': {'''xmin''': 4_94, '''ymin''': 1_05, '''xmax''': 5_21, '''ymax''': 1_27}},
													    ]       ,     )

													UpperCAmelCase_			:      int     						=  object_detector(
													    [
													        {
													            '''image''': '''./tests/fixtures/tests_samples/COCO/000000039769.png''',
													            '''candidate_labels''': ['''cat''', '''remote''', '''couch'''],
													        }
													    ]       ,     threshold=0.6_4       ,     )

													self.assertEqual(
													    nested_simplify(__magic_name__       ,     decimals=4   )       ,     [
													        [
													            {'''score''': 0.7_2_3_5, '''label''': '''cat''', '''box''': {'''xmin''': 2_04, '''ymin''': 1_67, '''xmax''': 2_32, '''ymax''': 1_90}},
													            {'''score''': 0.7_2_1_8, '''label''': '''remote''', '''box''': {'''xmin''': 2_04, '''ymin''': 1_67, '''xmax''': 2_32, '''ymax''': 1_90}},
													            {'''score''': 0.7_1_8_4, '''label''': '''couch''', '''box''': {'''xmin''': 2_04, '''ymin''': 1_67, '''xmax''': 2_32, '''ymax''': 1_90}},
													            {'''score''': 0.6_7_4_8, '''label''': '''remote''', '''box''': {'''xmin''': 5_71, '''ymin''': 83, '''xmax''': 5_98, '''ymax''': 1_03}},
													            {'''score''': 0.6_6_5_6, '''label''': '''cat''', '''box''': {'''xmin''': 5_71, '''ymin''': 83, '''xmax''': 5_98, '''ymax''': 1_03}},
													            {'''score''': 0.6_6_1_4, '''label''': '''couch''', '''box''': {'''xmin''': 5_71, '''ymin''': 83, '''xmax''': 5_98, '''ymax''': 1_03}},
													            {'''score''': 0.6_4_5_6, '''label''': '''remote''', '''box''': {'''xmin''': 4_94, '''ymin''': 1_05, '''xmax''': 5_21, '''ymax''': 1_27}},
													            {'''score''': 0.6_4_2, '''label''': '''remote''', '''box''': {'''xmin''': 67, '''ymin''': 2_74, '''xmax''': 93, '''ymax''': 2_97}},
													            {'''score''': 0.6_4_1_9, '''label''': '''cat''', '''box''': {'''xmin''': 4_94, '''ymin''': 1_05, '''xmax''': 5_21, '''ymax''': 1_27}},
													        ]
													    ]       ,     )

							@require_torch
							@slow
							def     UpperCAmelCase__	(							self							:     List[Any]   )					->       List[Any]:







													"""simple docstring"""
													UpperCAmelCase_			:      Tuple     						=  pipeline('''zero-shot-object-detection'''   )

													UpperCAmelCase_			:      Any     						=  object_detector(
													    '''http://images.cocodataset.org/val2017/000000039769.jpg'''       ,     candidate_labels=['''cat''', '''remote''', '''couch''']       ,     )
													self.assertEqual(
													    nested_simplify(__magic_name__       ,     decimals=4   )       ,     [
													        {'''score''': 0.2_8_6_8, '''label''': '''cat''', '''box''': {'''xmin''': 3_24, '''ymin''': 20, '''xmax''': 6_40, '''ymax''': 3_73}},
													        {'''score''': 0.2_7_7, '''label''': '''remote''', '''box''': {'''xmin''': 40, '''ymin''': 72, '''xmax''': 1_77, '''ymax''': 1_15}},
													        {'''score''': 0.2_5_3_7, '''label''': '''cat''', '''box''': {'''xmin''': 1, '''ymin''': 55, '''xmax''': 3_15, '''ymax''': 4_72}},
													        {'''score''': 0.1_4_7_4, '''label''': '''remote''', '''box''': {'''xmin''': 3_35, '''ymin''': 74, '''xmax''': 3_71, '''ymax''': 1_87}},
													        {'''score''': 0.1_2_0_8, '''label''': '''couch''', '''box''': {'''xmin''': 4, '''ymin''': 0, '''xmax''': 6_42, '''ymax''': 4_76}},
													    ]       ,     )

													UpperCAmelCase_			:      Any     						=  object_detector(
													    [
													        {
													            '''image''': '''http://images.cocodataset.org/val2017/000000039769.jpg''',
													            '''candidate_labels''': ['''cat''', '''remote''', '''couch'''],
													        },
													        {
													            '''image''': '''http://images.cocodataset.org/val2017/000000039769.jpg''',
													            '''candidate_labels''': ['''cat''', '''remote''', '''couch'''],
													        },
													    ]       ,     )
													self.assertEqual(
													    nested_simplify(__magic_name__       ,     decimals=4   )       ,     [
													        [
													            {'''score''': 0.2_8_6_8, '''label''': '''cat''', '''box''': {'''xmin''': 3_24, '''ymin''': 20, '''xmax''': 6_40, '''ymax''': 3_73}},
													            {'''score''': 0.2_7_7, '''label''': '''remote''', '''box''': {'''xmin''': 40, '''ymin''': 72, '''xmax''': 1_77, '''ymax''': 1_15}},
													            {'''score''': 0.2_5_3_7, '''label''': '''cat''', '''box''': {'''xmin''': 1, '''ymin''': 55, '''xmax''': 3_15, '''ymax''': 4_72}},
													            {'''score''': 0.1_4_7_4, '''label''': '''remote''', '''box''': {'''xmin''': 3_35, '''ymin''': 74, '''xmax''': 3_71, '''ymax''': 1_87}},
													            {'''score''': 0.1_2_0_8, '''label''': '''couch''', '''box''': {'''xmin''': 4, '''ymin''': 0, '''xmax''': 6_42, '''ymax''': 4_76}},
													        ],
													        [
													            {'''score''': 0.2_8_6_8, '''label''': '''cat''', '''box''': {'''xmin''': 3_24, '''ymin''': 20, '''xmax''': 6_40, '''ymax''': 3_73}},
													            {'''score''': 0.2_7_7, '''label''': '''remote''', '''box''': {'''xmin''': 40, '''ymin''': 72, '''xmax''': 1_77, '''ymax''': 1_15}},
													            {'''score''': 0.2_5_3_7, '''label''': '''cat''', '''box''': {'''xmin''': 1, '''ymin''': 55, '''xmax''': 3_15, '''ymax''': 4_72}},
													            {'''score''': 0.1_4_7_4, '''label''': '''remote''', '''box''': {'''xmin''': 3_35, '''ymin''': 74, '''xmax''': 3_71, '''ymax''': 1_87}},
													            {'''score''': 0.1_2_0_8, '''label''': '''couch''', '''box''': {'''xmin''': 4, '''ymin''': 0, '''xmax''': 6_42, '''ymax''': 4_76}},
													        ],
													    ]       ,     )

							@require_tf
							@unittest.skip('''Zero Shot Object Detection not implemented in TF'''   )
							def     UpperCAmelCase__	(							self							:     Any   )					->       Dict:







													"""simple docstring"""
													pass

							@require_torch
							@slow
							def     UpperCAmelCase__	(							self							:     Any   )					->       Optional[int]:







													"""simple docstring"""
													UpperCAmelCase_			:      str     						=  0.2
													UpperCAmelCase_			:      Union[str, Any]     						=  pipeline('''zero-shot-object-detection'''   )

													UpperCAmelCase_			:      Optional[int]     						=  object_detector(
													    '''http://images.cocodataset.org/val2017/000000039769.jpg'''       ,     candidate_labels=['''cat''', '''remote''', '''couch''']       ,     threshold=__magic_name__       ,     )
													self.assertEqual(
													    nested_simplify(__magic_name__       ,     decimals=4   )       ,     [
													        {'''score''': 0.2_8_6_8, '''label''': '''cat''', '''box''': {'''xmin''': 3_24, '''ymin''': 20, '''xmax''': 6_40, '''ymax''': 3_73}},
													        {'''score''': 0.2_7_7, '''label''': '''remote''', '''box''': {'''xmin''': 40, '''ymin''': 72, '''xmax''': 1_77, '''ymax''': 1_15}},
													        {'''score''': 0.2_5_3_7, '''label''': '''cat''', '''box''': {'''xmin''': 1, '''ymin''': 55, '''xmax''': 3_15, '''ymax''': 4_72}},
													    ]       ,     )



							@require_torch
							@slow
							def     UpperCAmelCase__	(							self							:     Any   )					->       Optional[int]:







													"""simple docstring"""
													UpperCAmelCase_			:      Tuple     						=  2
													UpperCAmelCase_			:      Any     						=  pipeline('''zero-shot-object-detection'''   )

													UpperCAmelCase_			:      List[Any]     						=  object_detector(
													    '''http://images.cocodataset.org/val2017/000000039769.jpg'''       ,     candidate_labels=['''cat''', '''remote''', '''couch''']       ,     top_k=__magic_name__       ,     )
													self.assertEqual(
													    nested_simplify(__magic_name__       ,     decimals=4   )       ,     [
													        {'''score''': 0.2_8_6_8, '''label''': '''cat''', '''box''': {'''xmin''': 3_24, '''ymin''': 20, '''xmax''': 6_40, '''ymax''': 3_73}},
													        {'''score''': 0.2_7_7, '''label''': '''remote''', '''box''': {'''xmin''': 40, '''ymin''': 72, '''xmax''': 1_77, '''ymax''': 1_15}},
													    ]       ,     )












'''simple docstring'''







def        lowerCamelCase_      (  SCREAMING_SNAKE_CASE__      :			int,			SCREAMING_SNAKE_CASE__      :			int   ) ->	int:
						return abs(SCREAMING_SNAKE_CASE__   ) if a == 0 else greatest_common_divisor(b % a,			SCREAMING_SNAKE_CASE__   )





def        lowerCamelCase_      (  SCREAMING_SNAKE_CASE__      :			int,			SCREAMING_SNAKE_CASE__      :			int   ) ->	int:
						while y:  # --> when y=0 then loop will terminate and return x as final GCD.
												UpperCAmelCase_						,       UpperCAmelCase_			:      Optional[Any]     						=  y, x % y
						return abs(SCREAMING_SNAKE_CASE__   )





def        lowerCamelCase_      (  ) ->	Optional[int]:
						try:
												UpperCAmelCase_			:      Optional[Any]     						=  input('''Enter two integers separated by comma (,): '''   ).split(''','''   )
												UpperCAmelCase_			:      Optional[int]     						=  int(nums[0]   )
												UpperCAmelCase_			:      List[Any]     						=  int(nums[1]   )
												print(
												    F"""greatest_common_divisor({num_a}, {num_a}) = """
												    F"""{greatest_common_divisor(SCREAMING_SNAKE_CASE__,			SCREAMING_SNAKE_CASE__   )}"""   )
												print(F"""By iterative gcd({num_a}, {num_a}) = {gcd_by_iterative(SCREAMING_SNAKE_CASE__,			SCREAMING_SNAKE_CASE__   )}"""   )
						except (IndexError, UnboundLocalError, ValueError):
												print('''Wrong input'''   )


if __name__ == "__main__":
					main()





