logo
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Readme
Files and versions

1.7 KiB

Object Detection with Yolov5

author: shiyu22


Description

Object Detection is a computer vision technique that locates and identifies people, items, or other objects in an image. Object detection has applications in many areas of computer vision, including image retrieval, image annotation, vehicle counting, object tracking, etc.

This operator uses PyTorch.yolov5 to detect the object.


Code Example

Writing the pipeline in the simplified way

import towhee

towhee.glob('./test.jpg') \
			.image_decode() \
			.object_detection.yolov5() \
			.show()
results1

Writing the same pipeline with explicitly specified inputs and outputs

import towhee

towhee.glob['path']('./test.png') \
			.image_decode['path','img']() \
			.object_detection.yolov5['img', ('box', 'class', 'score')]() \
			.select('box', 'class', 'score') \
			.show()
results1


Factory Constructor

Create the operator via the following factory method

object_detection.yolov5()


Interface

The operator takes an image as input. It first detects the objects appeared in the image, and gives the bounding box of each object.

Parameters:

img: numpy.ndarray

​ Image data in ndarray format.

Return: List[(int, int, int, int)], List[str], List[float]

The return value is a tuple of (boxes, classes, scores). The boxes is a list of bounding boxes. Each bounding box is represented by the top-left and the bottom right points, i.e. (x1, y1, x2, y2). The classes is a list of prediction labels. The scores is a list of the confidence scores.

1.7 KiB

Object Detection with Yolov5

author: shiyu22


Description

Object Detection is a computer vision technique that locates and identifies people, items, or other objects in an image. Object detection has applications in many areas of computer vision, including image retrieval, image annotation, vehicle counting, object tracking, etc.

This operator uses PyTorch.yolov5 to detect the object.


Code Example

Writing the pipeline in the simplified way

import towhee

towhee.glob('./test.jpg') \
			.image_decode() \
			.object_detection.yolov5() \
			.show()
results1

Writing the same pipeline with explicitly specified inputs and outputs

import towhee

towhee.glob['path']('./test.png') \
			.image_decode['path','img']() \
			.object_detection.yolov5['img', ('box', 'class', 'score')]() \
			.select('box', 'class', 'score') \
			.show()
results1


Factory Constructor

Create the operator via the following factory method

object_detection.yolov5()


Interface

The operator takes an image as input. It first detects the objects appeared in the image, and gives the bounding box of each object.

Parameters:

img: numpy.ndarray

​ Image data in ndarray format.

Return: List[(int, int, int, int)], List[str], List[float]

The return value is a tuple of (boxes, classes, scores). The boxes is a list of bounding boxes. Each bounding box is represented by the top-left and the bottom right points, i.e. (x1, y1, x2, y2). The classes is a list of prediction labels. The scores is a list of the confidence scores.