
from manim import *

class        _UpperCamelCase				(					_SCREAMING_SNAKE_CASE  ):






			'''simple docstring'''

			def       lowerCAmelCase__	(       self :       Union[str, Any]      ):
							UpperCamelCase_:							Union[str, Any]	=						Rectangle(height=0.5						,	width=0.5      )
							UpperCamelCase_:							Any	=						Rectangle(height=0.46						,	width=0.46      ).set_stroke(width=0      )

							UpperCamelCase_:							Optional[int]	=						[mem.copy() for i in range(6      )]
							UpperCamelCase_:							Tuple	=						[mem.copy() for i in range(6      )]
							UpperCamelCase_:							int	=						VGroup(*A_      ).arrange(A_						,	buff=0      )
							UpperCamelCase_:							Optional[Any]	=						VGroup(*A_      ).arrange(A_						,	buff=0      )
							UpperCamelCase_:							str	=						VGroup(A_						,	A_      ).arrange(A_						,	buff=0      )
							UpperCamelCase_:							Any	=						Text("""CPU"""						,	font_size=24      )
							UpperCamelCase_:							Any	=						Group(A_						,	A_      ).arrange(A_						,	buff=0.5						,	aligned_edge=A_      )
							cpu.move_to([-2.5, -0.5, 0]      )
							self.add(A_      )

							UpperCamelCase_:							List[str]	=						[mem.copy() for i in range(4      )]
							UpperCamelCase_:							Dict	=						VGroup(*A_      ).arrange(A_						,	buff=0      )
							UpperCamelCase_:							Union[str, Any]	=						Text("""GPU"""						,	font_size=24      )
							UpperCamelCase_:							Optional[Any]	=						Group(A_						,	A_      ).arrange(A_						,	buff=0.5						,	aligned_edge=A_      )
							gpu.move_to([-1, -1, 0]      )
							self.add(A_      )

							UpperCamelCase_:							List[Any]	=						[mem.copy() for i in range(6      )]
							UpperCamelCase_:							str	=						VGroup(*A_      ).arrange(A_						,	buff=0      )

							UpperCamelCase_:							Dict	=						Text("""Model"""						,	font_size=24      )
							UpperCamelCase_:							Union[str, Any]	=						Group(A_						,	A_      ).arrange(A_						,	buff=0.5						,	aligned_edge=A_      )
							model.move_to([3, -1.0, 0]      )
							self.add(A_      )

							UpperCamelCase_:							Any	=						[]
							for i, rect in enumerate(A_      ):
											rect.set_stroke(A_      )
											# target = fill.copy().set_fill(YELLOW, opacity=0.7)
											# target.move_to(rect)
											# self.add(target)

											UpperCamelCase_:							Union[str, Any]	=						Rectangle(height=0.46 / 4						,	width=0.46 / 3      ).set_stroke(width=0.0      ).set_fill(A_						,	opacity=0.7      )

											if i == 0:
															cpu_target.next_to(cpu_left_col_base[0].get_corner(DOWN + LEFT      )						,	buff=0.02						,	direction=A_      )
															cpu_target.set_x(cpu_target.get_x() + 0.1      )
											elif i == 3:
															cpu_target.next_to(cpu_targs[0]						,	direction=A_						,	buff=0.0      )
											else:
															cpu_target.next_to(cpu_targs[i - 1]						,	direction=A_						,	buff=0.0      )
											self.add(A_      )
											cpu_targs.append(A_      )

							UpperCamelCase_:							Tuple	=						[mem.copy() for i in range(6      )]
							UpperCamelCase_:							int	=						VGroup(*A_      ).arrange(A_						,	buff=0      )

							UpperCamelCase_:							List[Any]	=						Text("""Loaded Checkpoint"""						,	font_size=24      )
							UpperCamelCase_:							Union[str, Any]	=						Group(A_						,	A_      ).arrange(A_						,	aligned_edge=A_						,	buff=0.4      )
							checkpoint.move_to([3, 0.5, 0]      )

							UpperCamelCase_:							int	=						Square(side_length=2.2      )
							key.move_to([-5, 2, 0]      )

							UpperCamelCase_:							int	=						MarkupText(
							    f'''<b>Key:</b>\n\n<span fgcolor=\'{YELLOW}\'>●</span> Empty Model'''						,	font_size=18						,	)

							key_text.move_to([-5, 2.4, 0]      )

							self.add(A_						,	A_      )

							UpperCamelCase_:							List[Any]	=						MarkupText(
							    f'''<span fgcolor=\'{BLUE}\'>●</span> Checkpoint'''						,	font_size=18						,	)

							blue_text.next_to(A_						,	DOWN * 2.4						,	aligned_edge=key_text.get_left()      )

							UpperCamelCase_:							List[str]	=						MarkupText(
							    f'''Next, a <i><span fgcolor="{BLUE}">second</span></i> model is loaded into memory,\nwith the weights of a <span fgcolor="{BLUE}">single shard</span>.'''						,	font_size=24						,	)
							step_a.move_to([2, 2, 0]      )
							self.play(Write(A_      )						,	Write(A_      )      )

							self.play(Write(A_						,	run_time=1      )						,	Create(A_						,	run_time=1      )      )

							UpperCamelCase_:							Dict	=						[]
							UpperCamelCase_:							List[Any]	=						[]
							for i, rect in enumerate(A_      ):
											UpperCamelCase_:							Union[str, Any]	=						fill.copy().set_fill(A_						,	opacity=0.7      )
											target.move_to(A_      )
											first_animations.append(GrowFromCenter(A_						,	run_time=1      )      )

											UpperCamelCase_:							List[str]	=						target.copy()
											cpu_target.generate_target()
											if i < 5:
															cpu_target.target.move_to(cpu_left_col_base[i + 1]      )
											else:
															cpu_target.target.move_to(cpu_right_col_base[i - 5]      )
											second_animations.append(MoveToTarget(A_						,	run_time=1.5      )      )

							self.play(*A_      )
							self.play(*A_      )
							self.wait()








import cva
import numpy as np

class        _UpperCamelCase				:






			'''simple docstring'''

			def __init__(       self :       Dict						,	snake_case_ :       float						,	snake_case_ :       int      ):

							if k in (0.04, 0.06):
											UpperCamelCase_:							Union[str, Any]	=						k
											UpperCamelCase_:							Union[str, Any]	=						window_size
							else:
											raise ValueError("""invalid k value"""      )

			def __str__(       self :       int      ):
							return str(self.k      )




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

															UpperCamelCase_:							List[str]	=						(wxx * wyy) - (wxy**2)
															UpperCamelCase_:							Optional[int]	=						wxx + wyy
															UpperCamelCase_:							Dict	=						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__":
							lowerCamelCase_						: Optional[Any]         =  HarrisCorner(0.04, 3)
							lowerCamelCase_   ,       lowerCamelCase_						: Any         =  edge_detect.detect("""path_to_image""")
							cva.imwrite("""detect.png""", color_img)






