


'''simple docstring'''






import cva
import numpy as np




class 	a       :
 def __init__(	self ,			__magic_name__ ,			__magic_name__  )   ->							int:

      if k in (0.0_4, 0.0_6):
           _a      =							k
           _a      =							window_size
      else:
           raise ValueError('invalid k value'  )
 def __str__(	self  )   ->							str:
      return str(self.k  )




 def 							__UpperCAmelCase						(	self ,			__magic_name__  )   ->							tuple[cva.Mat, list[list[int]]]:
      _a      =							cva.imread(__magic_name__ ,			0  )
      _a ,				_a      =							img.shape
      _a      =							[]
      _a      =							img.copy()
      _a      =							cva.cvtColor(__magic_name__ ,			cva.COLOR_GRAY2RGB  )
      _a ,				_a      =							np.gradient(__magic_name__  )
      _a      =							dx**2
      _a      =							dy**2
      _a      =							dx * dy
      _a      =							0.0_4
      _a      =							self.window_size // 2
      for y in range(__magic_name__ ,			h - offset  ):
           for x in range(__magic_name__ ,			w - offset  ):
                _a      =							ixx[
                    y - offset : y + offset + 1, x - offset : x + offset + 1
                ].sum()
                _a      =							iyy[
                    y - offset : y + offset + 1, x - offset : x + offset + 1
                ].sum()
                _a      =							ixy[
                    y - offset : y + offset + 1, x - offset : x + offset + 1
                ].sum()

                _a      =							(wxx * wyy) - (wxy**2)
                _a      =							wxx + wyy
                _a      =							det - k * (trace**2)
                # Can change the value
                if r > 0.5:
                     corner_list.append([x, y, r]  )
                     color_img.itemset((y, x, 0) ,			0  )
                     color_img.itemset((y, x, 1) ,			0  )
                     color_img.itemset((y, x, 2) ,			2_55  )
      return color_img, corner_list


if __name__ == "__main__":
 a_   :      Any				    =      HarrisCorner(0.04, 3)
 a_   :      Optional[int]				    =      edge_detect.detect("path_to_image")
 cva.imwrite("detect.png", color_img)





'''simple docstring'''






import unittest

from diffusers.pipelines.pipeline_utils import is_safetensors_compatible




class 	a       (       unittest.TestCase    ):
 def 							__UpperCAmelCase						(	self  )   ->							int:
      _a      =							[
          'safety_checker/pytorch_model.bin',
          'safety_checker/model.safetensors',
          'vae/diffusion_pytorch_model.bin',
          'vae/diffusion_pytorch_model.safetensors',
          'text_encoder/pytorch_model.bin',
          'text_encoder/model.safetensors',
          'unet/diffusion_pytorch_model.bin',
          'unet/diffusion_pytorch_model.safetensors',
      ]
      self.assertTrue(is_safetensors_compatible(__magic_name__  )  )
 def 							__UpperCAmelCase						(	self  )   ->							Dict:
      _a      =							[
          'unet/diffusion_pytorch_model.bin',
          'unet/diffusion_pytorch_model.safetensors',
      ]
      self.assertTrue(is_safetensors_compatible(__magic_name__  )  )
 def 							__UpperCAmelCase						(	self  )   ->							Optional[int]:
      _a      =							[
          'safety_checker/pytorch_model.bin',
          'safety_checker/model.safetensors',
          'vae/diffusion_pytorch_model.bin',
          'vae/diffusion_pytorch_model.safetensors',
          'text_encoder/pytorch_model.bin',
          'text_encoder/model.safetensors',
          'unet/diffusion_pytorch_model.bin',
          # Removed: 'unet/diffusion_pytorch_model.safetensors',
      ]
      self.assertFalse(is_safetensors_compatible(__magic_name__  )  )
 def 							__UpperCAmelCase						(	self  )   ->							Optional[Any]:
      _a      =							[
          'text_encoder/pytorch_model.bin',
          'text_encoder/model.safetensors',
      ]
      self.assertTrue(is_safetensors_compatible(__magic_name__  )  )
 def 							__UpperCAmelCase						(	self  )   ->							str:
      _a      =							[
          'safety_checker/pytorch_model.bin',
          'safety_checker/model.safetensors',
          'vae/diffusion_pytorch_model.bin',
          'vae/diffusion_pytorch_model.safetensors',
          'text_encoder/pytorch_model.bin',
          # Removed: 'text_encoder/model.safetensors',
          'unet/diffusion_pytorch_model.bin',
          'unet/diffusion_pytorch_model.safetensors',
      ]
      self.assertFalse(is_safetensors_compatible(__magic_name__  )  )
 def 							__UpperCAmelCase						(	self  )   ->							List[Any]:
      _a      =							[
          'safety_checker/pytorch_model.fp16.bin',
          'safety_checker/model.fp16.safetensors',
          'vae/diffusion_pytorch_model.fp16.bin',
          'vae/diffusion_pytorch_model.fp16.safetensors',
          'text_encoder/pytorch_model.fp16.bin',
          'text_encoder/model.fp16.safetensors',
          'unet/diffusion_pytorch_model.fp16.bin',
          'unet/diffusion_pytorch_model.fp16.safetensors',
      ]
      _a      =							'fp16'
      self.assertTrue(is_safetensors_compatible(__magic_name__ ,			variant=__magic_name__  )  )
 def 							__UpperCAmelCase						(	self  )   ->							Any:
      _a      =							[
          'unet/diffusion_pytorch_model.fp16.bin',
          'unet/diffusion_pytorch_model.fp16.safetensors',
      ]
      _a      =							'fp16'
      self.assertTrue(is_safetensors_compatible(__magic_name__ ,			variant=__magic_name__  )  )
 def 							__UpperCAmelCase						(	self  )   ->							int:
      # pass variant but use the non-variant filenames
      _a      =							[
          'unet/diffusion_pytorch_model.bin',
          'unet/diffusion_pytorch_model.safetensors',
      ]
      _a      =							'fp16'
      self.assertTrue(is_safetensors_compatible(__magic_name__ ,			variant=__magic_name__  )  )
 def 							__UpperCAmelCase						(	self  )   ->							List[str]:
      _a      =							[
          'safety_checker/pytorch_model.fp16.bin',
          'safety_checker/model.fp16.safetensors',
          'vae/diffusion_pytorch_model.fp16.bin',
          'vae/diffusion_pytorch_model.fp16.safetensors',
          'text_encoder/pytorch_model.fp16.bin',
          'text_encoder/model.fp16.safetensors',
          'unet/diffusion_pytorch_model.fp16.bin',
          # Removed: 'unet/diffusion_pytorch_model.fp16.safetensors',
      ]
      _a      =							'fp16'
      self.assertFalse(is_safetensors_compatible(__magic_name__ ,			variant=__magic_name__  )  )
 def 							__UpperCAmelCase						(	self  )   ->							Union[str, Any]:
      _a      =							[
          'text_encoder/pytorch_model.fp16.bin',
          'text_encoder/model.fp16.safetensors',
      ]
      _a      =							'fp16'
      self.assertTrue(is_safetensors_compatible(__magic_name__ ,			variant=__magic_name__  )  )
 def 							__UpperCAmelCase						(	self  )   ->							List[Any]:
      # pass variant but use the non-variant filenames
      _a      =							[
          'text_encoder/pytorch_model.bin',
          'text_encoder/model.safetensors',
      ]
      _a      =							'fp16'
      self.assertTrue(is_safetensors_compatible(__magic_name__ ,			variant=__magic_name__  )  )




 def 							__UpperCAmelCase						(	self  )   ->							List[Any]:
      _a      =							[
          'safety_checker/pytorch_model.fp16.bin',
          'safety_checker/model.fp16.safetensors',
          'vae/diffusion_pytorch_model.fp16.bin',
          'vae/diffusion_pytorch_model.fp16.safetensors',
          'text_encoder/pytorch_model.fp16.bin',
          # 'text_encoder/model.fp16.safetensors',
          'unet/diffusion_pytorch_model.fp16.bin',
          'unet/diffusion_pytorch_model.fp16.safetensors',
      ]
      _a      =							'fp16'
      self.assertFalse(is_safetensors_compatible(__magic_name__ ,			variant=__magic_name__  )  )

