PitchHut logo
yolo-cls
Efficient YOLO-based image classification made easy.
Pitch

yolo-cls is a high-performance command-line tool for YOLO-based image classification, utilizing the ONNX Runtime to ensure speed and flexibility. With features like multi-threaded processing, customizable output, and support for various input formats, it streamlines the classification of large image collections efficiently.

Description

yolo-cls is a highly efficient, multi-threaded command-line tool used for YOLO-based image classification utilizing the ONNX Runtime. This tool is optimized for speed and adaptability, allowing users to classify images by providing file paths directly as command-line arguments or piping them from standard input. This makes it particularly suitable for batch processing extensive collections of images.

Features

  • High Performance: Built on the ONNX Runtime to ensure optimized, cross-platform inference capabilities.
  • Multi-threaded Processing: Capable of classifying multiple images concurrently, effectively leveraging the full potential of available CPU cores.
  • Flexible Input Options: Supports input of image file paths either directly as command-line arguments or through a pipe from other commands.
  • Customizable Output: Users can specify the number of top results to be displayed using the --top-k option.
  • Softmax Application: Optionally applies a softmax function to convert raw output scores into probabilities, enhancing the interpretability of results.
  • Performance Timing: Users can measure and display the processing time for each image classification task.
  • Input Filtering: Allows for filtering of input by file extension and maximum file size, thereby effectively managing processing resources.

Platform Support

yolo-cls has been officially tested on the following operating systems and architectures:

Operating SystemArchitectureDeviceCompilerStatusNotes
Linuxx86_64CPUGCC 13.3.0Supported
Linuxaarch64CPUGCC 12.2.0SupportedONNX Runtime versions 1.22.0 and 1.21.0 didn’t work, 1.20.1 worked.
Windowsx86_64CPUGCC 13.2.0SupportedMinGW x64
Windowsx86_64GPUGCC 13.2.0SupportedMinGW x64 with Nvidia CUDA (libcublas, libcufft, etc.)

Getting Started

To leverage yolo-cls, a YOLO classification model in ONNX format accompanied by a text file containing the class names is essential. The usage is straightforward:

usage: yolo-cls [options...] [image_file...]
       <command> | yolo-cls [options...]

Options:

ShortLongArgumentDescriptionDefault
-m--modelRequired. Path to the ONNX model file.
-c--classesRequired. Path to the text file with class names.
-k--top-kNumber of top results to show.5
-t--threadsNumber of threads for classification.Number of hardware cores
-F--max-filesizeMaximum allowed file size for images (e.g., 100mb).100mb
-T--timingEnable printing processing time for each image.Disabled
-S--softmaxApply softmax to output scores.Disabled
-h--helpPrint help message and exit.
-v--versionPrint version information and exit.
-a--aboutPrint about information and exit.

Usage Examples

  1. Classify all images in a directory:

    find . | ./yolo-cls -m model.onnx -c classes.txt
    
  2. Classify all .jpg images:

    find . -name "*.jpg" | ./yolo-cls -m model.onnx -c classes.txt
    
  3. Classify a single image:

    ./yolo-cls -m yolov8n-cls.onnx -c imagenet.names -k 3 ./images/fox.png
    
  4. Classify multiple images with processing time:

    ./yolo-cls -m model.onnx -c classes.txt -T ./img1.jpg ./img2.png ./img3.webp
    

Contributing

Contributions to yolo-cls are welcomed. Engagement in a collaborative community is encouraged. Please refer to the Contributing Guidelines for more information.

Documentation

Doxygen is supported for generating code documentation, making it easier to understand and utilize the codebase. To generate documentation, navigate to the ./docs directory and run:

doxygen doxyfile

The documentation will be located in docs/documentation.

0 comments

No comments yet.

Sign in to be the first to comment.