mirror of
https://github.com/mii443/usls.git
synced 2025-08-22 23:55:38 +00:00
* 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
22 lines
561 B
Rust
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(())
|
|
}
|