Object Detection

Object Detection1. Model Introduction2. Start2.1. Enter docker2.2. Target prediction: imageEffect preview2.3, Target prediction: VideoEffect preview2.4, Target Prediction: Real-time DetectionEffect PreviewReferences

Use Python to demonstrate the effect of Ultralytics: Object Detection in image, video, and real-time detection.

1. Model Introduction

Object detection is a task that involves identifying the location and category of objects in an image or video stream.

The output of the object detector is a set of bounding boxes surrounding the objects in the image, as well as the class label and confidence score of each bounding box. If you need to identify objects of interest in a scene, but do not need to know the specific location or exact shape of the object, then object detection is a good choice.

2. Start

2.1. Enter docker

Run YOLOv11's docker script

2.2. Target prediction: image

Use yolo11n.pt to predict the pictures that come with the ultralytics project.

Enter the code folder:

Run the code:

Effect preview

Yolo recognition output image location: /ultralytics/ultralytics/output/

1. View using jupyter lab

Open another terminal to enter the docker container and use jupyter lab to view the image

image-20250324155841464

image-20250324155023395

Access directly through http://localhost:8080/ in the system browser:

image-20250324170906785

2. Copy the file to the host machine for viewing

Enter the following command in the host terminal

image-20250324171108493

image-20241228154717085

Sample code:

2.3, Target prediction: Video

Use yolo11n.pt to predict the video under the ultralytics project (not the video that comes with ultralytics).

Enter the code folder:

Run the code:

Effect preview

Video location of yolo recognition output: /ultralytics/ultralytics/output/

The output video will be displayed in real time during the code running process. If you want to view the video later, you can refer to the above [2. Copy the file to the host machine for viewing] tutorial operation.

image-20241228155000451

Sample code:

2.4, Target Prediction: Real-time Detection

Use yolo11n.pt to predict the USB camera screen.

Enter the code folder:

Run the code: Click the preview screen, press the q key to terminate the program!

Effect Preview

Yolo recognizes the output video location: /ultralytics/ultralytics/output/

The camera screen will be displayed in real time during the code running process. If you want to view the output video later, you can refer to the above [2. Copy the file to the host machine for viewing] tutorial operation.

image-20241228160354642

Sample code:

References

https://docs.ultralytics.com/tasks/detect/