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
46 lines
1.4 KiB
Rust
46 lines
1.4 KiB
Rust
use usls::{coco, models::YOLO, Annotator, DataLoader, Options, Vision};
|
|
|
|
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|
// build model
|
|
let options = Options::default()
|
|
// .with_model("yolov8m-dyn.onnx")?
|
|
// .with_model("yolov8m-dyn-f16.onnx")?
|
|
// .with_model("yolov8m-pose-dyn.onnx")?
|
|
// .with_model("yolov8m-cls-dyn.onnx")?
|
|
.with_model("yolov8m-seg-dyn.onnx")?
|
|
// .with_model("yolov8m-obb-dyn.onnx")?
|
|
// .with_model("yolov8m-oiv7-dyn.onnx")?
|
|
// .with_trt(0)
|
|
// .with_fp16(true)
|
|
// .with_coreml(0)
|
|
// .with_cuda(3)
|
|
.with_i00((1, 1, 4).into())
|
|
.with_i02((224, 640, 800).into())
|
|
.with_i03((224, 640, 800).into())
|
|
.with_confs(&[0.4, 0.15]) // class 0: 0.4, others: 0.15
|
|
.with_names2(&coco::KEYPOINTS_NAMES_17)
|
|
.with_profile(false);
|
|
let mut model = YOLO::new(options)?;
|
|
|
|
// build dataloader
|
|
let dl = DataLoader::default()
|
|
.with_batch(1)
|
|
.load("./assets/bus.jpg")?;
|
|
// .load("./assets/dota.png")?;
|
|
|
|
// build annotate
|
|
let annotator = Annotator::default()
|
|
.with_skeletons(&coco::SKELETONS_16)
|
|
.with_bboxes_thickness(7)
|
|
.with_saveout("YOLOv8");
|
|
|
|
// run & annotate
|
|
for (xs, _paths) in dl {
|
|
let ys = model.run(&xs)?;
|
|
// let ys = model.forward(&xs, true)?;
|
|
annotator.annotate(&xs, &ys);
|
|
}
|
|
|
|
Ok(())
|
|
}
|