Update ort and improve the speed of preprocessing

* Add onnx proto

* Update ort to 2.0.0-rc.2

* Improve the speed of resizing

* Fix yolo-seg bug

* Update README.md
This commit is contained in:
Jamjamjon
2024-05-12 18:12:34 +08:00
committed by GitHub
parent 246e6091cd
commit fc970fc117
48 changed files with 1926 additions and 349 deletions

View File

@@ -15,7 +15,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
.with_profile(false);
// build model
let model = Clip::new(options_visual, options_textual)?;
let mut model = Clip::new(options_visual, options_textual)?;
// texts
let texts = vec![

View File

@@ -6,18 +6,18 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
.with_i00((1, 4, 8).into())
.with_i02((608, 960, 1280).into())
.with_i03((608, 960, 1280).into())
// .with_trt(0)
.with_confs(&[0.4])
.with_min_width(5.0)
.with_min_height(12.0)
// .with_trt(0)
.with_model("ppocr-v4-db-dyn.onnx")?;
let mut model = DB::new(&options)?;
let mut model = DB::new(options)?;
// load image
let x = vec![
DataLoader::try_read("./assets/db.png")?,
// DataLoader::try_read("./assets/2.jpg")?,
DataLoader::try_read("./assets/2.jpg")?,
];
// run

View File

@@ -7,7 +7,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
.with_i00((1, 1, 8).into())
.with_i02((384, 512, 1024).into())
.with_i03((384, 512, 1024).into());
let model = DepthAnything::new(&options)?;
let mut model = DepthAnything::new(options)?;
// load
let x = vec![DataLoader::try_read("./assets/2.jpg")?];

View File

@@ -7,7 +7,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
.with_i00((1, 1, 1).into())
.with_i02((224, 224, 224).into())
.with_i03((224, 224, 224).into());
let _model = Dinov2::new(&options)?;
let _model = Dinov2::new(options)?;
println!("TODO...");
// query from vector

View File

@@ -10,7 +10,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
// .with_trt(0)
// .with_fp16(true)
.with_confs(&[0.5]);
let mut model = YOLO::new(&options)?;
let mut model = YOLO::new(options)?;
// load image
let x = vec![DataLoader::try_read("./assets/nini.png")?];

View File

@@ -8,7 +8,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
.with_i02((416, 640, 800).into())
.with_i03((416, 640, 800).into())
.with_confs(&[0.4]);
let mut model = YOLO::new(&options)?;
let mut model = YOLO::new(options)?;
// load image
let x = vec![DataLoader::try_read("./assets/bus.jpg")?];

Binary file not shown.

Before

Width:  |  Height:  |  Size: 93 KiB

After

Width:  |  Height:  |  Size: 128 KiB

View File

@@ -7,10 +7,10 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
.with_i00((1, 1, 4).into())
.with_i02((416, 512, 800).into())
.with_i03((416, 512, 800).into());
let model = MODNet::new(&options)?;
let mut model = MODNet::new(options)?;
// load image
let x = vec![DataLoader::try_read("./assets/portrait.jpg")?];
let x = vec![DataLoader::try_read("./assets/liuyifei.png")?];
// run
let y = model.run(&x)?;

View File

@@ -4,9 +4,9 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
// build model
let options = Options::default()
.with_model("rtdetr-l-f16.onnx")?
.with_confs(&[0.4, 0.15]) // person: 0.4, others: 0.15
.with_confs(&[0.4, 0.15])
.with_names(&coco::NAMES_80);
let mut model = RTDETR::new(&options)?;
let mut model = RTDETR::new(options)?;
// load image
let x = vec![DataLoader::try_read("./assets/bus.jpg")?];

View File

@@ -8,7 +8,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
.with_nk(17)
.with_confs(&[0.3])
.with_kconfs(&[0.5]);
let mut model = RTMO::new(&options)?;
let mut model = RTMO::new(options)?;
// load image
let x = vec![DataLoader::try_read("./assets/bus.jpg")?];

View File

@@ -8,7 +8,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
.with_confs(&[0.2])
.with_vocab("ppocr_rec_vocab.txt")?
.with_model("ppocr-v4-svtr-ch-dyn.onnx")?;
let mut model = SVTR::new(&options)?;
let mut model = SVTR::new(options)?;
// load images
let dl = DataLoader::default()

View File

@@ -7,9 +7,9 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
.with_i00((1, 1, 4).into())
.with_i02((416, 640, 800).into())
.with_i03((416, 640, 800).into())
.with_confs(&[0.3]) // shoes: 0.2
.with_confs(&[0.3])
.with_profile(false);
let mut model = YOLO::new(&options)?;
let mut model = YOLO::new(options)?;
// load image
let x = vec![DataLoader::try_read("./assets/bus.jpg")?];

View File

@@ -6,7 +6,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
.with_model("yolopv2-dyn-480x800.onnx")?
.with_i00((1, 1, 8).into())
.with_confs(&[0.3]);
let mut model = YOLOPv2::new(&options)?;
let mut model = YOLOPv2::new(options)?;
// load image
let x = vec![DataLoader::try_read("./assets/car.jpg")?];

View File

@@ -10,13 +10,12 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
.with_anchors_first(true)
.with_yolo_task(YOLOTask::Segment)
.with_model("yolov5s-seg.onnx")?
.with_trt(0)
.with_fp16(true)
// .with_trt(0)
// .with_fp16(true)
.with_i00((1, 1, 4).into())
.with_i02((224, 640, 800).into())
.with_i03((224, 640, 800).into())
.with_dry_run(3);
let mut model = YOLO::new(&options)?;
.with_i03((224, 640, 800).into());
let mut model = YOLO::new(options)?;
// load image
let x = vec![DataLoader::try_read("./assets/bus.jpg")?];

Binary file not shown.

Before

Width:  |  Height:  |  Size: 285 KiB

After

Width:  |  Height:  |  Size: 286 KiB

View File

@@ -8,7 +8,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
.with_i02((416, 640, 800).into())
.with_i03((416, 640, 800).into())
.with_confs(&[0.15]);
let mut model = YOLO::new(&options)?;
let mut model = YOLO::new(options)?;
// load image
let x = vec![DataLoader::try_read("./assets/kids.jpg")?];

View File

@@ -3,7 +3,7 @@ use usls::{models::YOLO, Annotator, DataLoader, Options};
fn main() -> Result<(), Box<dyn std::error::Error>> {
// build model
let options = Options::default().with_model("yolov8-falldown-f16.onnx")?;
let mut model = YOLO::new(&options)?;
let mut model = YOLO::new(options)?;
// load image
let x = vec![DataLoader::try_read("./assets/falldown.jpg")?];

View File

@@ -3,7 +3,7 @@ use usls::{models::YOLO, Annotator, DataLoader, Options};
fn main() -> Result<(), Box<dyn std::error::Error>> {
// build model
let options = Options::default().with_model("yolov8-head-f16.onnx")?;
let mut model = YOLO::new(&options)?;
let mut model = YOLO::new(options)?;
// load image
let x = vec![DataLoader::try_read("./assets/kids.jpg")?];

View File

@@ -5,7 +5,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
let options = Options::default()
.with_model("yolov8-plastic-bag-f16.onnx")?
.with_names(&["trash"]);
let mut model = YOLO::new(&options)?;
let mut model = YOLO::new(options)?;
// load image
let x = vec![DataLoader::try_read("./assets/trash.jpg")?];

Binary file not shown.

Before

Width:  |  Height:  |  Size: 387 KiB

After

Width:  |  Height:  |  Size: 391 KiB

View File

@@ -3,21 +3,25 @@ use usls::{coco, models::YOLO, Annotator, DataLoader, Options};
fn main() -> Result<(), Box<dyn std::error::Error>> {
// build model
let options = Options::default()
.with_model("yolov8m-dyn.onnx")?
// .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-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]) // person: 0.4, others: 0.15
.with_confs(&[0.4, 0.15]) // class 0: 0.4, others: 0.15
.with_names2(&coco::KEYPOINTS_NAMES_17)
// .with_dry_run(10)
.with_profile(false);
let mut model = YOLO::new(&options)?;
let mut model = YOLO::new(options)?;
// build dataloader
let dl = DataLoader::default()

View File

@@ -7,8 +7,8 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
.with_i00((1, 1, 4).into())
.with_i02((416, 640, 800).into())
.with_i03((416, 640, 800).into())
.with_confs(&[0.4, 0.15]); // person: 0.4, others: 0.15
let mut model = YOLO::new(&options)?;
.with_confs(&[0.4, 0.15]);
let mut model = YOLO::new(options)?;
// load image
let x = vec![DataLoader::try_read("./assets/bus.jpg")?];