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
31 lines
813 B
Rust
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(())
|
|
}
|