Add docstrings and improve comments (#11229)

Signed-off-by: Glenn Jocher <glenn.jocher@ultralytics.com>
This commit is contained in:
Glenn Jocher 2024-05-03 22:51:26 +02:00 committed by GitHub
parent ccfc1cf925
commit d5458f27cd
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
16 changed files with 34 additions and 17 deletions

View file

@ -917,7 +917,6 @@ class Albumentations:
return labels
# TODO: technically this is not an augmentation, maybe we should put this to another files
class Format:
"""
Formats image annotations for object detection, instance segmentation, and pose estimation tasks. The class

View file

@ -14,7 +14,7 @@ import tkinter as tk
class ParkingPtsSelection:
def __init__(self, master):
# Initialize window and widgets.
"""Initializes the UI for selecting parking zone points in a tkinter window."""
self.master = master
master.title("Ultralytics Parking Zones Points Selector")
self.initialize_ui()
@ -109,6 +109,7 @@ class ParkingPtsSelection:
messagebox.showwarning("Warning", "No bounding boxes to remove.")
def save_to_json(self):
"""Saves rescaled bounding boxes to 'bounding_boxes.json' based on image-to-canvas size ratio."""
canvas_width, canvas_height = self.canvas.winfo_width(), self.canvas.winfo_height()
width_scaling_factor = self.img_width / canvas_width
height_scaling_factor = self.img_height / canvas_height

View file

@ -268,6 +268,7 @@ from ultralytics import YOLO
def run_tracker_in_thread(filename, model):
"""Starts multi-thread tracking on video from `filename` using `model` and displays results frame by frame."""
video = cv2.VideoCapture(filename)
frames = int(video.get(cv2.CAP_PROP_FRAME_COUNT))
for _ in range(frames):

View file

@ -343,11 +343,7 @@ class Instances:
self.keypoints[..., 1] = self.keypoints[..., 1].clip(0, h)
def remove_zero_area_boxes(self):
"""
Remove zero-area boxes, i.e. after clipping some boxes may have zero width or height.
This removes them.
"""
"""Remove zero-area boxes, i.e. after clipping some boxes may have zero width or height."""
good = self.bbox_areas > 0
if not all(good):
self._bboxes = self._bboxes[good]