Image Classification

Image Classification1. Model Introduction2. Image Classification: ImageEffect preview3. Image classification: videoEffect preview4. Image classification: real-time detection4.1. USB cameraEffect preview4.2, CSI cameraEffect previewReferences

Use Python to demonstrate the effect of Ultralytics: Image classification on images, videos, and real-time detection.

1. Model Introduction

Image classification is the simplest of the three tasks and involves classifying the entire image into one of a set of predefined categories.

The output of an image classifier is a single class label and a confidence score. Image classification is very useful when you only need to know which class an image belongs to, without knowing the location or exact shape of the object in that class.

2. Image Classification: Image

Use yolo11n-cls.pt to predict images under the ultralytics project (not ultralytics built-in images).

Enter the code folder:

Run the code:

Effect preview

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

image-20241230201848908

Sample code:

3. Image classification: video

Use yolo11n-cls.pt to predict videos under the ultralytics project (not the videos that come with ultralytics).

Enter the code folder:

Run the code:

Effect preview

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

image-20241230203858580

Sample code:

4. Image classification: real-time detection

4.1. USB camera

Use yolo11n-cls.pt to predict the USB camera screen.

Enter the code folder:

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

Effect preview

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

image-20241230204347046

Sample code:

4.2, CSI camera

Use yolo11n-cls.pt to predict the CSI camera image.

Enter the code folder:

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

Effect preview

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

image-20241230204915931

Sample code:

References

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