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.
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 System | Architecture | Device | Compiler | Status | Notes |
---|---|---|---|---|---|
Linux | x86_64 | CPU | GCC 13.3.0 | Supported | |
Linux | aarch64 | CPU | GCC 12.2.0 | Supported | ONNX Runtime versions 1.22.0 and 1.21.0 didn’t work, 1.20.1 worked. |
Windows | x86_64 | CPU | GCC 13.2.0 | Supported | MinGW x64 |
Windows | x86_64 | GPU | GCC 13.2.0 | Supported | MinGW 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:
Short | Long | Argument | Description | Default |
---|---|---|---|---|
-m | --model | Required. Path to the ONNX model file. | ||
-c | --classes | Required. Path to the text file with class names. | ||
-k | --top-k | Number of top results to show. | 5 | |
-t | --threads | Number of threads for classification. | Number of hardware cores | |
-F | --max-filesize | Maximum allowed file size for images (e.g., 100mb). | 100mb | |
-T | --timing | Enable printing processing time for each image. | Disabled | |
-S | --softmax | Apply softmax to output scores. | Disabled | |
-h | --help | Print help message and exit. | ||
-v | --version | Print version information and exit. | ||
-a | --about | Print about information and exit. |
Usage Examples
-
Classify all images in a directory:
find . | ./yolo-cls -m model.onnx -c classes.txt
-
Classify all
.jpg
images:find . -name "*.jpg" | ./yolo-cls -m model.onnx -c classes.txt
-
Classify a single image:
./yolo-cls -m yolov8n-cls.onnx -c imagenet.names -k 3 ./images/fox.png
-
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
.
No comments yet.
Sign in to be the first to comment.