Files
usls/examples/yolov8-trash/main.rs
Jamjamjon a5141a53be Accelerate model pre-processing and post-processing (#23)
* Add X struct to handle input and preprocessing

*Add Ops struct to manage common operations

* Use SIMD (fast_image_resize) to accelerate model pre-processing and post-processing
2024-06-30 15:19:34 +08:00

22 lines
561 B
Rust

use usls::{models::YOLO, Annotator, DataLoader, Options, Vision};
fn main() -> Result<(), Box<dyn std::error::Error>> {
// 1.build model
let options = Options::default()
.with_model("yolov8-plastic-bag-f16.onnx")?
.with_names(&["trash"]);
let mut model = YOLO::new(options)?;
// load image
let x = vec![DataLoader::try_read("./assets/trash.jpg")?];
// run
let y = model.run(&x)?;
// annotate
let annotator = Annotator::default().with_saveout("YOLOv8-Trash");
annotator.annotate(&x, &y);
Ok(())
}