Skip to content

Commit 92bc3c1

Browse files
committed
Refactor code formatting and minor improvements
- Clean up whitespace and formatting in predict.py and cv.py - Remove unnecessary whitespace and improve code readability - Minor formatting adjustments in visualization and point conversion functions
1 parent fcf0cfb commit 92bc3c1

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

sahi/predict.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ def get_sliced_prediction(
242242
overlap_width_ratio=overlap_width_ratio,
243243
auto_slice_resolution=auto_slice_resolution,
244244
)
245-
from sahi.models.ultralytics import UltralyticsDetectionModel
245+
from sahi.models.ultralytics import UltralyticsDetectionModel
246246

247247
num_slices = len(slice_image_result)
248248
time_end = time.time() - time_start

sahi/utils/cv.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -567,9 +567,14 @@ def visualize_object_predictions(
567567
lowest_point = points[points[:, :, 1].argmax()][0]
568568
box_width, box_height = cv2.getTextSize(label, 0, fontScale=text_size, thickness=text_th)[0]
569569
outside = lowest_point[1] - box_height - 3 >= 0
570-
text_bg_point1 = (lowest_point[0], lowest_point[1] - box_height - 3 if outside else lowest_point[1] + 3)
570+
text_bg_point1 = (
571+
lowest_point[0],
572+
lowest_point[1] - box_height - 3 if outside else lowest_point[1] + 3,
573+
)
571574
text_bg_point2 = (lowest_point[0] + box_width, lowest_point[1])
572-
cv2.rectangle(image, text_bg_point1, text_bg_point2, color or (0, 0, 0), thickness=-1, lineType=cv2.LINE_AA)
575+
cv2.rectangle(
576+
image, text_bg_point1, text_bg_point2, color or (0, 0, 0), thickness=-1, lineType=cv2.LINE_AA
577+
)
573578
cv2.putText(
574579
image,
575580
label,
@@ -733,7 +738,7 @@ def get_coco_segmentation_from_obb_points(obb_points: np.ndarray) -> List[List[f
733738
[[x1, y1, x2, y2, x3, y3, x4, y4], [...], ...]
734739
"""
735740
# Convert from (4,2) to [x1,y1,x2,y2,x3,y3,x4,y4] format
736-
points = obb_points.reshape(-1).tolist() #
741+
points = obb_points.reshape(-1).tolist()
737742

738743
# Create polygon from points and close it by repeating first point
739744
polygons = []

0 commit comments

Comments
 (0)