Convert formatting to use ruff instead of yapf + isort (#26247)
Signed-off-by: Harry Mellor <19981378+hmellor@users.noreply.github.com>
This commit is contained in:
@@ -8,7 +8,7 @@ from PIL import Image
|
||||
|
||||
|
||||
def random_image(rng: np.random.RandomState, min_wh: int, max_wh: int):
|
||||
w, h = rng.randint(min_wh, max_wh, size=(2, ))
|
||||
w, h = rng.randint(min_wh, max_wh, size=(2,))
|
||||
arr = rng.randint(0, 255, size=(w, h, 3), dtype=np.uint8)
|
||||
return Image.fromarray(arr)
|
||||
|
||||
@@ -21,7 +21,7 @@ def random_video(
|
||||
max_wh: int,
|
||||
):
|
||||
num_frames = rng.randint(min_frames, max_frames)
|
||||
w, h = rng.randint(min_wh, max_wh, size=(2, ))
|
||||
w, h = rng.randint(min_wh, max_wh, size=(2,))
|
||||
return rng.randint(0, 255, size=(num_frames, w, h, 3), dtype=np.uint8)
|
||||
|
||||
|
||||
@@ -66,14 +66,13 @@ def create_video_from_image(
|
||||
return video_path
|
||||
|
||||
|
||||
def cosine_similarity(A: npt.NDArray,
|
||||
B: npt.NDArray,
|
||||
axis: int = -1) -> npt.NDArray:
|
||||
def cosine_similarity(A: npt.NDArray, B: npt.NDArray, axis: int = -1) -> npt.NDArray:
|
||||
"""Compute cosine similarity between two vectors."""
|
||||
return (np.sum(A * B, axis=axis) /
|
||||
(np.linalg.norm(A, axis=axis) * np.linalg.norm(B, axis=axis)))
|
||||
return np.sum(A * B, axis=axis) / (
|
||||
np.linalg.norm(A, axis=axis) * np.linalg.norm(B, axis=axis)
|
||||
)
|
||||
|
||||
|
||||
def normalize_image(image: npt.NDArray) -> npt.NDArray:
|
||||
"""Normalize image to [0, 1] range."""
|
||||
return image.astype(np.float32) / 255.0
|
||||
return image.astype(np.float32) / 255.0
|
||||
|
||||
Reference in New Issue
Block a user