Skip to content

Commit 0de4b1b

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent 258e99c commit 0de4b1b

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

computer_vision/grounded_sam2_segmentation.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,9 @@ def segment_with_points(
124124
# Validate point labels
125125
for label in point_labels:
126126
if label not in [0, 1]:
127-
raise ValueError("Point labels must be 0 (background) or 1 (foreground)")
127+
raise ValueError(
128+
"Point labels must be 0 (background) or 1 (foreground)"
129+
)
128130

129131
# Simulate segmentation based on point prompts
130132
# In real implementation, this would use SAM2 model inference
@@ -245,9 +247,9 @@ def segment_with_text(
245247
radius = min(h, w) // 4
246248

247249
y_coords, x_coords = np.ogrid[:h, :w]
248-
circle_mask = (
249-
(x_coords - center_x) ** 2 + (y_coords - center_y) ** 2 <= radius**2
250-
)
250+
circle_mask = (x_coords - center_x) ** 2 + (
251+
y_coords - center_y
252+
) ** 2 <= radius**2
251253
mask = np.zeros((h, w), dtype=np.uint8)
252254
mask[circle_mask] = 1
253255

@@ -269,7 +271,11 @@ def segment_with_text(
269271
return results
270272

271273
def apply_color_mask(
272-
self, image: np.ndarray, mask: np.ndarray, color: tuple[int, int, int] = (0, 255, 0), alpha: float = 0.5
274+
self,
275+
image: np.ndarray,
276+
mask: np.ndarray,
277+
color: tuple[int, int, int] = (0, 255, 0),
278+
alpha: float = 0.5,
273279
) -> np.ndarray:
274280
"""
275281
Apply colored overlay on image based on segmentation mask.

0 commit comments

Comments
 (0)