Skip to content

kornia/kornia-yolo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Kornia YOLO in Rust

A fast, reliable YOLO object detection implementation for Rust powered by Kornia and Candle.

Features

  • 🚀 High-performance object detection with YOLOv8 using Kornia and Candle
  • 🔧 Multiple model sizes (n, s, m, l, x) for different performance/accuracy tradeoffs
  • 📦 Pre-trained models automatically downloaded from Hugging Face
  • 🖼️ Simple API for inference on images
  • 🧮 Non-maximum suppression for refined detection results
  • 🔄 Built on the Kornia Rust computer vision ecosystem

Installation

[dependencies]
kornia-yolo = { git = "https://github.com/kornia/kornia-yolo", tag = "0.1.0" }

Quickstart

use kornia_io::functional as F;
use kornia_yolo::{YoloV8, YoloV8Config, YoloV8Size};

fn main() -> Result<(), Box<dyn std::error::Error>> {
    // Create a YOLOv8 model with default configuration (nano size)
    let model = YoloV8::new(YoloV8Config::default())?;
    
    // Load an image
    let image = F::read_image_any("path/to/your/image.jpg")?;
    
    // Run inference
    let detections = model.inference(&image)?;
    
    // Process and display results
    for detection in detections {
        println!(
            "Detected: class={}, confidence={:.2}, bbox=({:.1}, {:.1}, {:.1}, {:.1})",
            detection.class,
            detection.confidence,
            detection.xmin, detection.ymin, detection.xmax, detection.ymax
        );
    }
    
    Ok(())
}

Example

cargo run --example inference --release -- --image_path ./tests/data/bike.jpg

Screenshot from 2025-03-30 16-54-58

Acknowledgements

This project is built on top of the following amazing projects:

License

This project has an uncleared license as it is a derivative work of the above projects including a modified version of the YOLOv8 model from Ultralytics.

Contributing

This is a child project of Kornia. Join the community to get in touch with us, or just sponsor the project: https://opencollective.com/kornia

About

Kornia Rust Yolo implementation

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages