YOLO

For more details refer to the paper You Only Look Once (YOLO).

YOLOv5 Torch

class dronevis.models.YOLOv5

YOLOv5 implementation with torch hub model (inherits from CVModel).

For more details see YOLOv5.

__init__()

Initialize local path

load_model()

Load model from PyTorchHub

transform_img(image)

Idle transformation.

Implemented just for code integrity

Parameters:

image (np.ndarray) – input image

Returns:

output image

Return type:

np.ndarray

predict(image)

Run model inference on input image and return bouding boxes along with object names

Parameters:

image (np.array) – input image

Returns:

detections object

Return type:

torch.hub.models.self.common.Detections

detect_webcam(video_index=0, window_name='YOLOv5 Detection')

Start webcam detection from video_index (to quit running this function press ‘q’)

The stream is retrieved and decoded using opencv library.

Parameters:
  • video_index (Union[str, int], optional) – index of video stream device.

  • 0 (Defaults to) –

  • window_name (str, optional) – name of cv2 window. Defaults to “Cam Detection”.