Remove "mypy type hint" from annotator scene assertions
This commit is contained in:
@@ -88,7 +88,7 @@ class BoxAnnotator(BaseAnnotator):
|
||||

|
||||
"""
|
||||
assert isinstance(scene, np.ndarray), "MyPy type hint"
|
||||
assert isinstance(scene, np.ndarray)
|
||||
for detection_idx in range(len(detections)):
|
||||
x1, y1, x2, y2 = detections.xyxy[detection_idx].astype(int)
|
||||
color = resolve_color(
|
||||
@@ -174,7 +174,7 @@ class BoundingBoxAnnotator(BaseAnnotator):
|
||||

|
||||
"""
|
||||
assert isinstance(scene, np.ndarray), "MyPy type hint"
|
||||
assert isinstance(scene, np.ndarray)
|
||||
for detection_idx in range(len(detections)):
|
||||
x1, y1, x2, y2 = detections.xyxy[detection_idx].astype(int)
|
||||
color = resolve_color(
|
||||
@@ -259,7 +259,7 @@ class OrientedBoxAnnotator(BaseAnnotator):
|
||||
)
|
||||
```
|
||||
""" # noqa E501 // docs
|
||||
assert isinstance(scene, np.ndarray), "MyPy type hint"
|
||||
assert isinstance(scene, np.ndarray)
|
||||
if detections.data is None or ORIENTED_BOX_COORDINATES not in detections.data:
|
||||
return scene
|
||||
|
||||
@@ -345,7 +345,7 @@ class MaskAnnotator(BaseAnnotator):
|
||||

|
||||
"""
|
||||
assert isinstance(scene, np.ndarray), "MyPy type hint"
|
||||
assert isinstance(scene, np.ndarray)
|
||||
if detections.mask is None:
|
||||
return scene
|
||||
|
||||
@@ -435,7 +435,7 @@ class PolygonAnnotator(BaseAnnotator):
|
||||

|
||||
"""
|
||||
assert isinstance(scene, np.ndarray), "MyPy type hint"
|
||||
assert isinstance(scene, np.ndarray)
|
||||
if detections.mask is None:
|
||||
return scene
|
||||
|
||||
@@ -522,7 +522,7 @@ class ColorAnnotator(BaseAnnotator):
|
||||

|
||||
"""
|
||||
assert isinstance(scene, np.ndarray), "MyPy type hint"
|
||||
assert isinstance(scene, np.ndarray)
|
||||
scene_with_boxes = scene.copy()
|
||||
for detection_idx in range(len(detections)):
|
||||
x1, y1, x2, y2 = detections.xyxy[detection_idx].astype(int)
|
||||
@@ -618,7 +618,7 @@ class HaloAnnotator(BaseAnnotator):
|
||||

|
||||
"""
|
||||
assert isinstance(scene, np.ndarray), "MyPy type hint"
|
||||
assert isinstance(scene, np.ndarray)
|
||||
if detections.mask is None:
|
||||
return scene
|
||||
colored_mask = np.zeros_like(scene, dtype=np.uint8)
|
||||
@@ -718,7 +718,7 @@ class EllipseAnnotator(BaseAnnotator):
|
||||

|
||||
"""
|
||||
assert isinstance(scene, np.ndarray), "MyPy type hint"
|
||||
assert isinstance(scene, np.ndarray)
|
||||
for detection_idx in range(len(detections)):
|
||||
x1, y1, x2, y2 = detections.xyxy[detection_idx].astype(int)
|
||||
color = resolve_color(
|
||||
@@ -810,7 +810,7 @@ class BoxCornerAnnotator(BaseAnnotator):
|
||||

|
||||
"""
|
||||
assert isinstance(scene, np.ndarray), "MyPy type hint"
|
||||
assert isinstance(scene, np.ndarray)
|
||||
for detection_idx in range(len(detections)):
|
||||
x1, y1, x2, y2 = detections.xyxy[detection_idx].astype(int)
|
||||
color = resolve_color(
|
||||
@@ -900,7 +900,7 @@ class CircleAnnotator(BaseAnnotator):
|
||||

|
||||
"""
|
||||
assert isinstance(scene, np.ndarray), "MyPy type hint"
|
||||
assert isinstance(scene, np.ndarray)
|
||||
for detection_idx in range(len(detections)):
|
||||
x1, y1, x2, y2 = detections.xyxy[detection_idx].astype(int)
|
||||
center = ((x1 + x2) // 2, (y1 + y2) // 2)
|
||||
@@ -993,7 +993,7 @@ class DotAnnotator(BaseAnnotator):
|
||||

|
||||
"""
|
||||
assert isinstance(scene, np.ndarray), "MyPy type hint"
|
||||
assert isinstance(scene, np.ndarray)
|
||||
xy = detections.get_anchors_coordinates(anchor=self.position)
|
||||
for detection_idx in range(len(detections)):
|
||||
color = resolve_color(
|
||||
@@ -1103,7 +1103,7 @@ class LabelAnnotator(BaseAnnotator):
|
||||

|
||||
"""
|
||||
assert isinstance(scene, np.ndarray), "MyPy type hint"
|
||||
assert isinstance(scene, np.ndarray)
|
||||
font = cv2.FONT_HERSHEY_SIMPLEX
|
||||
anchors_coordinates = detections.get_anchors_coordinates(
|
||||
anchor=self.text_anchor
|
||||
@@ -1320,7 +1320,7 @@ class RichLabelAnnotator(BaseAnnotator):
|
||||
```
|
||||
|
||||
"""
|
||||
assert isinstance(scene, Image.Image), "MyPy type hint"
|
||||
assert isinstance(scene, Image.Image)
|
||||
draw = ImageDraw.Draw(scene)
|
||||
anchors_coordinates = detections.get_anchors_coordinates(
|
||||
anchor=self.text_anchor
|
||||
@@ -1453,7 +1453,7 @@ class BlurAnnotator(BaseAnnotator):
|
||||

|
||||
"""
|
||||
assert isinstance(scene, np.ndarray), "MyPy type hint"
|
||||
assert isinstance(scene, np.ndarray)
|
||||
image_height, image_width = scene.shape[:2]
|
||||
clipped_xyxy = clip_boxes(
|
||||
xyxy=detections.xyxy, resolution_wh=(image_width, image_height)
|
||||
@@ -1552,7 +1552,7 @@ class TraceAnnotator(BaseAnnotator):
|
||||

|
||||
"""
|
||||
assert isinstance(scene, np.ndarray), "MyPy type hint"
|
||||
assert isinstance(scene, np.ndarray)
|
||||
if detections.tracker_id is None:
|
||||
raise ValueError(
|
||||
"The `tracker_id` field is missing in the provided detections."
|
||||
@@ -1656,7 +1656,7 @@ class HeatMapAnnotator(BaseAnnotator):
|
||||

|
||||
"""
|
||||
assert isinstance(scene, np.ndarray), "MyPy type hint"
|
||||
assert isinstance(scene, np.ndarray)
|
||||
if self.heat_mask is None:
|
||||
self.heat_mask = np.zeros(scene.shape[:2], dtype=np.float32)
|
||||
|
||||
@@ -1737,7 +1737,7 @@ class PixelateAnnotator(BaseAnnotator):
|
||||

|
||||
"""
|
||||
assert isinstance(scene, np.ndarray), "MyPy type hint"
|
||||
assert isinstance(scene, np.ndarray)
|
||||
image_height, image_width = scene.shape[:2]
|
||||
clipped_xyxy = clip_boxes(
|
||||
xyxy=detections.xyxy, resolution_wh=(image_width, image_height)
|
||||
@@ -1831,7 +1831,7 @@ class TriangleAnnotator(BaseAnnotator):
|
||||

|
||||
"""
|
||||
assert isinstance(scene, np.ndarray), "MyPy type hint"
|
||||
assert isinstance(scene, np.ndarray)
|
||||
xy = detections.get_anchors_coordinates(anchor=self.position)
|
||||
for detection_idx in range(len(detections)):
|
||||
color = resolve_color(
|
||||
@@ -1932,7 +1932,7 @@ class RoundBoxAnnotator(BaseAnnotator):
|
||||

|
||||
"""
|
||||
assert isinstance(scene, np.ndarray), "MyPy type hint"
|
||||
assert isinstance(scene, np.ndarray)
|
||||
for detection_idx in range(len(detections)):
|
||||
x1, y1, x2, y2 = detections.xyxy[detection_idx].astype(int)
|
||||
color = resolve_color(
|
||||
@@ -2076,7 +2076,7 @@ class PercentageBarAnnotator(BaseAnnotator):
|
||||

|
||||
"""
|
||||
assert isinstance(scene, np.ndarray), "MyPy type hint"
|
||||
assert isinstance(scene, np.ndarray)
|
||||
self.validate_custom_values(custom_values=custom_values, detections=detections)
|
||||
|
||||
anchors = detections.get_anchors_coordinates(anchor=self.position)
|
||||
@@ -2249,7 +2249,7 @@ class CropAnnotator(BaseAnnotator):
|
||||
)
|
||||
```
|
||||
"""
|
||||
assert isinstance(scene, np.ndarray), "MyPy type hint"
|
||||
assert isinstance(scene, np.ndarray)
|
||||
crops = [
|
||||
crop_image(image=scene, xyxy=xyxy) for xyxy in detections.xyxy.astype(int)
|
||||
]
|
||||
@@ -2388,7 +2388,7 @@ class BackgroundOverlayAnnotator(BaseAnnotator):
|
||||

|
||||
"""
|
||||
assert isinstance(scene, np.ndarray), "MyPy type hint"
|
||||
assert isinstance(scene, np.ndarray)
|
||||
colored_mask = np.full_like(scene, self.color.as_bgr(), dtype=np.uint8)
|
||||
|
||||
cv2.addWeighted(
|
||||
|
||||
@@ -78,7 +78,7 @@ class VertexAnnotator(BaseKeyPointAnnotator):
|
||||

|
||||
"""
|
||||
assert isinstance(scene, np.ndarray), "MyPy type hint"
|
||||
assert isinstance(scene, np.ndarray)
|
||||
if len(key_points) == 0:
|
||||
return scene
|
||||
|
||||
@@ -156,7 +156,7 @@ class EdgeAnnotator(BaseKeyPointAnnotator):
|
||||

|
||||
"""
|
||||
assert isinstance(scene, np.ndarray), "MyPy type hint"
|
||||
assert isinstance(scene, np.ndarray)
|
||||
if len(key_points) == 0:
|
||||
return scene
|
||||
|
||||
@@ -310,7 +310,7 @@ class VertexLabelAnnotator:
|
||||

|
||||
"""
|
||||
assert isinstance(scene, np.ndarray), "MyPy type hint"
|
||||
assert isinstance(scene, np.ndarray)
|
||||
font = cv2.FONT_HERSHEY_SIMPLEX
|
||||
|
||||
skeletons_count, points_count, _ = key_points.xy.shape
|
||||
|
||||
Reference in New Issue
Block a user