






"""simple docstring"""
import unittest

import numpy as np

from transformers.testing_utils import require_torch, require_vision
from transformers.utils import is_torch_available, is_vision_available

from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs


if is_torch_available():
      import torch

if is_vision_available():
      from PIL import Image

      from transformers import DeiTImageProcessor



class 						a_ (      unittest.TestCase					):







      '''simple docstring'''

      def __init__(self,	lowerCamelCase_,	lowerCamelCase_=7,	lowerCamelCase_=3,	lowerCamelCase_=1_8,	lowerCamelCase_=3_0,	lowerCamelCase_=4_0_0,	lowerCamelCase_=True,	lowerCamelCase_=None,	lowerCamelCase_=True,	lowerCamelCase_=None,	lowerCamelCase_=True,	lowerCamelCase_=[0.5, 0.5, 0.5],	lowerCamelCase_=[0.5, 0.5, 0.5],	):

       '''simple docstring'''



       lowerCamelCase__	:     Optional[Any]								=		size if size is not None else {'height': 2_0, 'width': 2_0}
       lowerCamelCase__	:     List[Any]								=		crop_size if crop_size is not None else {'height': 1_8, 'width': 1_8}

       lowerCamelCase__	:     Tuple								=		parent
       lowerCamelCase__	:     List[str]								=		batch_size
       lowerCamelCase__	:     Optional[Any]								=		num_channels
       lowerCamelCase__	:     List[Any]								=		image_size
       lowerCamelCase__	:     Optional[Any]								=		min_resolution
       lowerCamelCase__	:     Optional[Any]								=		max_resolution
       lowerCamelCase__	:     Tuple								=		do_resize
       lowerCamelCase__	:     Any								=		size
       lowerCamelCase__	:     Dict								=		do_center_crop
       lowerCamelCase__	:     List[Any]								=		crop_size
       lowerCamelCase__	:     Optional[Any]								=		do_normalize
       lowerCamelCase__	:     Optional[Any]								=		image_mean
       lowerCamelCase__	:     List[Any]								=		image_std





      def      a__				(self   ):

       '''simple docstring'''



       return {
           "do_resize": self.do_resize,
           "size": self.size,
           "do_center_crop": self.do_center_crop,
           "crop_size": self.crop_size,
           "do_normalize": self.do_normalize,
           "image_mean": self.image_mean,
           "image_std": self.image_std,
       }



@require_torch
@require_vision
class 						a_ (      __UpperCAmelCase    ,		unittest.TestCase					):







      '''simple docstring'''

      lowerCamelCase__			:							str					=      DeiTImageProcessor if is_vision_available() else None
      lowerCamelCase__			:							Union[str, Any]					=      True




      def      a__				(self   ):

       '''simple docstring'''



       lowerCamelCase__	:     Tuple								=		DeiTImageProcessingTester(self   )




      @property
      def      a__				(self   ):

       '''simple docstring'''



       return self.image_processor_tester.prepare_image_processor_dict()




      def      a__				(self   ):

       '''simple docstring'''



       lowerCamelCase__	:     Tuple								=		self.image_processing_class(**self.image_processor_dict   )
       self.assertTrue(hasattr(lowerCamelCase__,	'do_resize'   )   )
       self.assertTrue(hasattr(lowerCamelCase__,	'size'   )   )
       self.assertTrue(hasattr(lowerCamelCase__,	'do_center_crop'   )   )
       self.assertTrue(hasattr(lowerCamelCase__,	'center_crop'   )   )
       self.assertTrue(hasattr(lowerCamelCase__,	'do_normalize'   )   )
       self.assertTrue(hasattr(lowerCamelCase__,	'image_mean'   )   )
       self.assertTrue(hasattr(lowerCamelCase__,	'image_std'   )   )




      def      a__				(self   ):

       '''simple docstring'''



       lowerCamelCase__	:     Optional[int]								=		self.image_processing_class.from_dict(self.image_processor_dict   )
       self.assertEqual(image_processor.size,	{'height': 2_0, 'width': 2_0}   )
       self.assertEqual(image_processor.crop_size,	{'height': 1_8, 'width': 1_8}   )

       lowerCamelCase__	:     Union[str, Any]								=		self.image_processing_class.from_dict(self.image_processor_dict,	size=4_2,	crop_size=8_4   )
       self.assertEqual(image_processor.size,	{'height': 4_2, 'width': 4_2}   )
       self.assertEqual(image_processor.crop_size,	{'height': 8_4, 'width': 8_4}   )




      def      a__				(self   ):

       '''simple docstring'''



       pass




      def      a__				(self   ):

       '''simple docstring'''



       lowerCamelCase__	:     Union[str, Any]								=		self.image_processing_class(**self.image_processor_dict   )
       # create random PIL images
       lowerCamelCase__	:     List[str]								=		prepare_image_inputs(self.image_processor_tester,	equal_resolution=lowerCamelCase__   )
       for image in image_inputs:
        self.assertIsInstance(lowerCamelCase__,	Image.Image   )

       # Test not batched input
       lowerCamelCase__	:     Optional[Any]								=		image_processing(image_inputs[0],	return_tensors='pt'   ).pixel_values
       self.assertEqual(
           encoded_images.shape,	(
               1,
               self.image_processor_tester.num_channels,
               self.image_processor_tester.crop_size['height'],
               self.image_processor_tester.crop_size['width'],
           ),	)

       # Test batched
       lowerCamelCase__	:     List[str]								=		image_processing(lowerCamelCase__,	return_tensors='pt'   ).pixel_values
       self.assertEqual(
           encoded_images.shape,	(
               self.image_processor_tester.batch_size,
               self.image_processor_tester.num_channels,
               self.image_processor_tester.crop_size['height'],
               self.image_processor_tester.crop_size['width'],
           ),	)




      def      a__				(self   ):

       '''simple docstring'''



       lowerCamelCase__	:     Tuple								=		self.image_processing_class(**self.image_processor_dict   )
       # create random numpy tensors
       lowerCamelCase__	:     Dict								=		prepare_image_inputs(self.image_processor_tester,	equal_resolution=lowerCamelCase__,	numpify=lowerCamelCase__   )
       for image in image_inputs:
        self.assertIsInstance(lowerCamelCase__,	np.ndarray   )

       # Test not batched input
       lowerCamelCase__	:     Tuple								=		image_processing(image_inputs[0],	return_tensors='pt'   ).pixel_values
       self.assertEqual(
           encoded_images.shape,	(
               1,
               self.image_processor_tester.num_channels,
               self.image_processor_tester.crop_size['height'],
               self.image_processor_tester.crop_size['width'],
           ),	)

       # Test batched
       lowerCamelCase__	:     Optional[int]								=		image_processing(lowerCamelCase__,	return_tensors='pt'   ).pixel_values
       self.assertEqual(
           encoded_images.shape,	(
               self.image_processor_tester.batch_size,
               self.image_processor_tester.num_channels,
               self.image_processor_tester.crop_size['height'],
               self.image_processor_tester.crop_size['width'],
           ),	)





      def      a__				(self   ):

       '''simple docstring'''



       lowerCamelCase__	:     str								=		self.image_processing_class(**self.image_processor_dict   )
       # create random PyTorch tensors
       lowerCamelCase__	:     List[Any]								=		prepare_image_inputs(self.image_processor_tester,	equal_resolution=lowerCamelCase__,	torchify=lowerCamelCase__   )
       for image in image_inputs:
        self.assertIsInstance(lowerCamelCase__,	torch.Tensor   )

       # Test not batched input
       lowerCamelCase__	:     Any								=		image_processing(image_inputs[0],	return_tensors='pt'   ).pixel_values
       self.assertEqual(
           encoded_images.shape,	(
               1,
               self.image_processor_tester.num_channels,
               self.image_processor_tester.crop_size['height'],
               self.image_processor_tester.crop_size['width'],
           ),	)

       # Test batched
       lowerCamelCase__	:     Optional[int]								=		image_processing(lowerCamelCase__,	return_tensors='pt'   ).pixel_values
       self.assertEqual(
           encoded_images.shape,	(
               self.image_processor_tester.batch_size,
               self.image_processor_tester.num_channels,
               self.image_processor_tester.crop_size['height'],
               self.image_processor_tester.crop_size['width'],
           ),	)


"""simple docstring"""






import requests

try:
						from django.contrib.auth import authenticate, login
						from django.shortcuts import redirect, render
except ImportError:
						lowerCAmelCase__    :    Union[str, Any]			=      print



def     a_		(   lowerCamelCase			):
				# Enter your recaptcha secret key here
				UpperCAmelCase__			 =				'secretKey'
				UpperCAmelCase__			 =				'https://www.google.com/recaptcha/api/siteverify'

				# when method is not POST, direct user to login page
				if request.method != "POST":
								return render(lowerCamelCase   ,     'login.html'			)

				# from the frontend, get username, password, and client_key
				UpperCAmelCase__			 =				request.POST.get('username'			)
				UpperCAmelCase__			 =				request.POST.get('password'			)
				UpperCAmelCase__			 =				request.POST.get('g-recaptcha-response'			)

				# post recaptcha response to Google's recaptcha api
				UpperCAmelCase__			 =				requests.post(lowerCamelCase   ,     data={'secret': secret_key, 'response': client_key}			)
				# if the recaptcha api verified our keys
				if response.json().get('success'   ,     lowerCamelCase			):
								# authenticate the user
								UpperCAmelCase__			 =				authenticate(lowerCamelCase   ,     username=lowerCamelCase   ,     password=lowerCamelCase			)
								if user_in_database:
												login(lowerCamelCase   ,     lowerCamelCase			)
												return redirect('/your-webpage'			)
				return render(lowerCamelCase   ,     'login.html'			)



