Skip to content

Commit

Permalink
Bump the version to v0.0.11
Browse files Browse the repository at this point in the history
- ONNXRuntime -> 1.19.x
- CUDA -> 12.x
- TensorRT -> 10.x
  • Loading branch information
jamjamjon authored Aug 27, 2024
1 parent b81b5e3 commit f25f5cf
Show file tree
Hide file tree
Showing 9 changed files with 117 additions and 88 deletions.
10 changes: 6 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "usls"
version = "0.0.10"
version = "0.0.11"
edition = "2021"
description = "A Rust library integrated with ONNXRuntime, providing a collection of ML models."
repository = "https://github.com/jamjamjon/usls"
Expand All @@ -11,11 +11,13 @@ exclude = ["assets/*", "examples/*", "scripts/*", "runs/*"]

[dependencies]
clap = { version = "4.2.4", features = ["derive"] }
ndarray = { version = "0.15.6", features = ["rayon"] }
ort = { version = "2.0.0-rc.2", git = "https://github.com/pykeio/ort.git", default-features = false, features = [
ndarray = { version = "0.16.1", features = ["rayon"] }
ort = { version = "2.0.0-rc.5", default-features = false, features = [
"load-dynamic",
"copy-dylibs",
"half",
"cann",
"rknpu",
"ndarray",
"cuda",
"tensorrt",
Expand All @@ -24,7 +26,7 @@ ort = { version = "2.0.0-rc.2", git = "https://github.com/pykeio/ort.git", defau
"rocm",
"openvino",
"operator-libraries"
], rev = "467d127c5877b099e1d0f605d38b74d221b6121c"}
]}
anyhow = { version = "1.0.75" }
regex = { version = "1.5.4" }
rand = { version = "0.8.5" }
Expand Down
163 changes: 90 additions & 73 deletions README.md

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion src/core/ort_engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,6 @@ impl OrtEngine {
}
let xs = Xs::from(xs);
for _ in 0..self.num_dry_run {
// self.run(xs.as_ref())?;
self.run(xs.clone())?;
}
self.ts.clear();
Expand Down
3 changes: 2 additions & 1 deletion src/models/db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@ impl DB {
let (ratio, _, _) = Ops::scale_wh(image_width, image_height, w as f32, h as f32);
let v = luma
.into_owned()
.into_raw_vec()
.into_raw_vec_and_offset()
.0
.iter()
.map(|x| {
if x <= &self.binary_thresh {
Expand Down
2 changes: 1 addition & 1 deletion src/models/depth_anything.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ impl DepthAnything {
let mut ys: Vec<Y> = Vec::new();
for (idx, luma) in xs[0].axis_iter(Axis(0)).enumerate() {
let (w1, h1) = (xs0[idx].width(), xs0[idx].height());
let v = luma.into_owned().into_raw_vec();
let v = luma.into_owned().into_raw_vec_and_offset().0;
let max_ = v.iter().max_by(|x, y| x.total_cmp(y)).unwrap();
let min_ = v.iter().min_by(|x, y| x.total_cmp(y)).unwrap();
let v = v
Expand Down
2 changes: 1 addition & 1 deletion src/models/modnet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ impl MODNet {
let (w1, h1) = (xs0[idx].width(), xs0[idx].height());
let luma = luma.mapv(|x| (x * 255.0) as u8);
let luma = Ops::resize_luma8_vec(
&luma.into_raw_vec(),
&luma.into_raw_vec_and_offset().0,
self.width() as _,
self.height() as _,
w1 as _,
Expand Down
8 changes: 5 additions & 3 deletions src/models/sam.rs
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,8 @@ impl SAM {
for (mask, iou) in masks.axis_iter(Axis(0)).zip(confs.axis_iter(Axis(0))) {
let (i, conf) = match iou
.to_owned()
.into_raw_vec()
.into_raw_vec_and_offset()
.0
.into_iter()
.enumerate()
.max_by(|a, b| a.1.total_cmp(&b.1))
Expand All @@ -264,7 +265,7 @@ impl SAM {
let (h, w) = mask.dim();
let luma = if self.use_low_res_mask {
Ops::resize_lumaf32_vec(
&mask.to_owned().into_raw_vec(),
&mask.into_owned().into_raw_vec_and_offset().0,
w as _,
h as _,
image_width as _,
Expand All @@ -274,7 +275,8 @@ impl SAM {
)?
} else {
mask.mapv(|x| if x > 0. { 255u8 } else { 0u8 })
.into_raw_vec()
.into_raw_vec_and_offset()
.0
};

let luma: image::ImageBuffer<image::Luma<_>, Vec<_>> =
Expand Down
6 changes: 3 additions & 3 deletions src/models/yolo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ impl Vision for YOLO {
} else {
slice_clss.into_owned()
};
let mut probs = Prob::default().with_probs(&x.into_raw_vec());
let mut probs = Prob::default().with_probs(&x.into_raw_vec_and_offset().0);
if let Some(names) = &self.names {
probs =
probs.with_names(&names.iter().map(|x| x.as_str()).collect::<Vec<_>>());
Expand Down Expand Up @@ -417,12 +417,12 @@ impl Vision for YOLO {

// coefs * proto => mask
let coefs = Array::from_shape_vec((1, nm), coefs).ok()?; // (n, nm)
let proto = proto.into_shape((nm, mh * mw)).ok()?; // (nm, mh * mw)
let proto = proto.to_shape((nm, mh * mw)).ok()?; // (nm, mh * mw)
let mask = coefs.dot(&proto); // (mh, mw, n)

// Mask rescale
let mask = Ops::resize_lumaf32_vec(
&mask.into_raw_vec(),
&mask.into_raw_vec_and_offset().0,
mw as _,
mh as _,
image_width as _,
Expand Down
10 changes: 9 additions & 1 deletion src/models/yolop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,15 @@ impl YOLOPv2 {
h1: f32,
) -> Result<Vec<imageproc::contours::Contour<i32>>> {
let mask = mask.mapv(|x| if x < thresh { 0u8 } else { 255u8 });
let mask = Ops::resize_luma8_vec(&mask.into_raw_vec(), w0, h0, w1, h1, false, "Bilinear")?;
let mask = Ops::resize_luma8_vec(
&mask.into_raw_vec_and_offset().0,
w0,
h0,
w1,
h1,
false,
"Bilinear",
)?;
let mask: image::ImageBuffer<image::Luma<_>, Vec<_>> =
image::ImageBuffer::from_raw(w1 as _, h1 as _, mask)
.ok_or(anyhow::anyhow!("Failed to build image"))?;
Expand Down

0 comments on commit f25f5cf

Please sign in to comment.