Files
usls/examples/yolov5/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

31 lines
813 B
Rust

use usls::{
models::{YOLOTask, YOLOVersion, YOLO},
Annotator, DataLoader, Options, Vision,
};
fn main() -> Result<(), Box<dyn std::error::Error>> {
// build model
let options = Options::default()
.with_yolo_version(YOLOVersion::V5)
.with_model("../models/yolov5s-seg.onnx")?
.with_yolo_task(YOLOTask::Segment)
// .with_trt(0)
// .with_fp16(true)
.with_i00((1, 1, 4).into())
.with_i02((224, 640, 800).into())
.with_i03((224, 640, 800).into());
let mut model = YOLO::new(options)?;
// load image
let x = vec![DataLoader::try_read("./assets/bus.jpg")?];
// run
let y = model.run(&x)?;
// annotate
let annotator = Annotator::default().with_saveout("YOLOv5");
annotator.annotate(&x, &y);
Ok(())
}