



"""simple docstring"""







import datasets


lowerCAmelCase_   						=   '\\n@InProceedings{conneau2018xnli,\n  author = "Conneau, Alexis\n                 and Rinott, Ruty\n                 and Lample, Guillaume\n                 and Williams, Adina\n                 and Bowman, Samuel R.\n                 and Schwenk, Holger\n                 and Stoyanov, Veselin",\n  title = "XNLI: Evaluating Cross-lingual Sentence Representations",\n  booktitle = "Proceedings of the 2018 Conference on Empirical Methods\n               in Natural Language Processing",\n  year = "2018",\n  publisher = "Association for Computational Linguistics",\n  location = "Brussels, Belgium",\n}\n'

lowerCAmelCase_   						=   '\\nXNLI is a subset of a few thousand examples from MNLI which has been translated\ninto a 14 different languages (some low-ish resource). As with MNLI, the goal is\nto predict textual entailment (does sentence A imply/contradict/neither sentence\nB) and is a classification task (given two sentences, predict one of three\nlabels).\n'

lowerCAmelCase_   						=   '\nComputes XNLI score which is just simple accuracy.\nArgs:\n    predictions: Predicted labels.\n    references: Ground truth labels.\nReturns:\n    \'accuracy\': accuracy\nExamples:\n\n    >>> predictions = [0, 1]\n    >>> references = [0, 1]\n    >>> xnli_metric = datasets.load_metric("xnli")\n    >>> results = xnli_metric.compute(predictions=predictions, references=references)\n    >>> print(results)\n    {\'accuracy\': 1.0}\n'



def      __UpperCAmelCase      (    __lowerCamelCase						,     __lowerCamelCase	)							->      Tuple:
		return (preds == labels).mean()





@datasets.utils.file_utils.add_start_docstrings(_DESCRIPTION     ,_KWARGS_DESCRIPTION    )
class        __A       (	datasets.Metric    ):







		'''simple docstring'''





		def 					UpperCAmelCase    (	self						:  Optional[int]						)					->		List[Any]:






				"""simple docstring"""



				return datasets.MetricInfo(
				    description=_DESCRIPTION			,citation=_CITATION			,inputs_description=_KWARGS_DESCRIPTION			,features=datasets.Features(
				        {
				            '''predictions''': datasets.Value('''int64''' if self.config_name != '''sts-b''' else '''float32'''						),
				            '''references''': datasets.Value('''int64''' if self.config_name != '''sts-b''' else '''float32'''						),
				        }						)			,codebase_urls=[]			,reference_urls=[]			,format='''numpy'''			,)







		def 					UpperCAmelCase    (	self						:  List[Any]			,_snake_case						:  Union[str, Any]			,_snake_case						:  Optional[int]						)					->		Tuple:






				"""simple docstring"""



				return {"accuracy": simple_accuracy(_snake_case			,_snake_case						)}








import cva
import numpy as np
class     a    :



      """simple docstring"""


      def __init__(      self					:			Optional[Any]		,      __lowercase					:			float		,      __lowercase					:			int					)							->      List[Any]:

        if k in (0.04, 0.06):
          __UpperCAmelCase							:	int           =  k
          __UpperCAmelCase							:	List[str]           =  window_size
        else:
          raise ValueError("""invalid k value"""					)
      def __str__(      self					:			Union[str, Any]					)							->      str:
        return str(self.k					)




      def 	UpperCAmelCase      (      self					:			Optional[int]		,      __lowercase					:			str					)							->      tuple[cva.Mat, list[list[int]]]:
        __UpperCAmelCase							:	Optional[Any]           =  cva.imread(__lowercase		,      0					)
        __UpperCAmelCase      , __UpperCAmelCase							:	List[Any]           =  img.shape
        __UpperCAmelCase							:	list[list[int]]           =  []
        __UpperCAmelCase							:	Any           =  img.copy()
        __UpperCAmelCase							:	Tuple           =  cva.cvtColor(__lowercase		,      cva.COLOR_GRAY2RGB					)
        __UpperCAmelCase      , __UpperCAmelCase							:	List[str]           =  np.gradient(__lowercase					)
        __UpperCAmelCase							:	int           =  dx**2
        __UpperCAmelCase							:	Any           =  dy**2
        __UpperCAmelCase							:	Any           =  dx * dy
        __UpperCAmelCase							:	Optional[int]           =  0.04
        __UpperCAmelCase							:	List[str]           =  self.window_size // 2
        for y in range(__lowercase		,      h - offset					):
          for x in range(__lowercase		,      w - offset					):
            __UpperCAmelCase							:	Tuple           =  ixx[
                y - offset : y + offset + 1, x - offset : x + offset + 1
            ].sum()
            __UpperCAmelCase							:	List[Any]           =  iyy[
                y - offset : y + offset + 1, x - offset : x + offset + 1
            ].sum()
            __UpperCAmelCase							:	Optional[int]           =  ixy[
                y - offset : y + offset + 1, x - offset : x + offset + 1
            ].sum()

            __UpperCAmelCase							:	int           =  (wxx * wyy) - (wxy**2)
            __UpperCAmelCase							:	Any           =  wxx + wyy
            __UpperCAmelCase							:	Optional[Any]           =  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)		,      255					)
        return color_img, corner_list


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


