Skip to content

Commit

Permalink
+++++++++
Browse files Browse the repository at this point in the history
  • Loading branch information
jamjamjon committed Jan 1, 2025
1 parent 615f3c0 commit a6c2ae4
Show file tree
Hide file tree
Showing 19 changed files with 159 additions and 229 deletions.
10 changes: 2 additions & 8 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[package]
name = "usls"
version = "0.0.21"
rust-version = "1.79"
edition = "2021"
description = "A Rust library integrated with ONNXRuntime, providing a collection of ML models."
repository = "https://github.com/jamjamjon/usls"
Expand All @@ -9,7 +10,6 @@ license = "MIT"
readme = "README.md"
exclude = ["assets/*", "examples/*", "runs/*", "benches/*"]


[dependencies]
aksr = { version = "0.0.2" }
image = { version = "0.25.2" }
Expand All @@ -22,7 +22,6 @@ rand = { version = "0.8.5" }
chrono = { version = "0.4.30" }
tokenizers = { version = "0.15.2" }
log = { version = "0.4.22" }
env_logger = { version = "0.11.5" }
indicatif = "0.17.8"
serde_json = "1.0"
serde = { version = "1.0", features = ["derive"] }
Expand All @@ -42,19 +41,15 @@ video-rs = { version = "0.10.0", features = ["ndarray"], optional = true }
minifb = { version = "0.27.0", optional = true }
argh = "0.1.13"


[dev-dependencies]
env_logger = { version = "0.11.5" }
tracing-subscriber = { version = "0.3.18" }
tracing = { version = "0.1.40", features = ["log"] }



[[example]]
name = "viewer"
required-features = ["ffmpeg"]



[features]
default = [
"ort/ndarray",
Expand All @@ -68,7 +63,6 @@ cuda = [ "ort/cuda" ]
trt = [ "ort/tensorrt" ]
mps = [ "ort/coreml" ]


[profile.release]
# lto = true
strip = true
Expand Down
292 changes: 107 additions & 185 deletions README.md

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions examples/blip/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ This demo shows how to use [BLIP](https://arxiv.org/abs/2201.12086) to do condit
cargo run -r -F cuda --example blip -- --device cuda:0 --source images/dog.jpg --source ./assets/bus.jpg --source images/green-car.jpg
```

## Results

```shell
Unconditional: Ys([Y { Texts: [Text("a dog running through a field of grass")] }, Y { Texts: [Text("a group of people walking around a bus")] }, Y { Texts: [Text("a green volkswagen beetle parked in front of a yellow building")] }])
Conditional: Ys([Y { Texts: [Text("this image depicting a dog running in a field")] }, Y { Texts: [Text("this image depict a bus in barcelona")] }, Y { Texts: [Text("this image depict a blue volkswagen beetle parked in a street in havana, cuba")] }])
Expand Down
3 changes: 1 addition & 2 deletions examples/clip/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,4 @@ cargo run -r -F cuda --example clip -- --device cuda:0
(99.9675%) ./examples/clip/images/carrot.jpg => Some carrots
(99.93718%) ./examples/clip/images/doll.jpg => There is a doll with red hair and a clock on a table
(100.0%) ./examples/clip/images/drink.jpg => Some people holding wine glasses in a restaurant

```
```
5 changes: 5 additions & 0 deletions examples/fastsam/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
## Quick Start

```shell
cargo run -r -F cuda --example fastsam -- --device cuda
```
6 changes: 0 additions & 6 deletions examples/fastsam.rs → examples/fastsam/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,6 @@ struct Args {
}

fn main() -> Result<()> {
tracing_subscriber::fmt()
.with_max_level(tracing::Level::INFO)
.init();

let args: Args = argh::from_env();

// build model
Expand All @@ -40,7 +36,5 @@ fn main() -> Result<()> {
.with_saveout("fastsam");
annotator.annotate(&xs, &ys);

model.summary();

Ok(())
}
3 changes: 1 addition & 2 deletions examples/florence2/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ Task: Caption(2)
Ys([Y { Texts: [Text("The image shows a vintage Volkswagen Beetle car parked on a cobblestone street in front of a yellow building with two wooden doors. The car is a light blue color with silver rims and appears to be in good condition. The building has a sloping roof and is painted in a bright yellow color. The sky is blue and there are trees in the background. The overall mood of the image is peaceful and serene.")] }, Y { Texts: [Text("The image shows a blue and white bus with the logo of the Brazilian football club, Cero Emisiones, on the side. The bus is parked on a street with a building in the background. There are several people walking on the sidewalk in front of the bus, some of them are carrying bags and one person is holding a camera. The sky is blue and there are trees and a traffic light visible in the top right corner of the image. The image appears to be taken during the day.")] }])
```
# Tasks
## Results
| Task | Demo |
| -----| ------|
Expand Down
14 changes: 10 additions & 4 deletions examples/rtdetr/README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
## Quick Start


**Models exported from [RT-DETR](https://github.com/lyuwenyu/RT-DETR)**


```shell
cargo run -r --example rtdetr
```

## Results

```
[Bboxes]: Found 5 objects
0: Bbox { xyxy: [47.969677, 397.81808, 246.22426, 904.8823], class_id: 0, name: Some("person"), confidence: 0.94432133 }
1: Bbox { xyxy: [668.0796, 399.28854, 810.3779, 880.7412], class_id: 0, name: Some("person"), confidence: 0.93386495 }
2: Bbox { xyxy: [20.852705, 229.30482, 807.43494, 729.51196], class_id: 5, name: Some("bus"), confidence: 0.9319465 }
3: Bbox { xyxy: [223.28226, 405.37265, 343.92603, 859.50366], class_id: 0, name: Some("person"), confidence: 0.9130827 }
4: Bbox { xyxy: [0.0, 552.6165, 65.99908, 868.00525], class_id: 0, name: Some("person"), confidence: 0.7910869 }
```
17 changes: 13 additions & 4 deletions examples/rtdetr/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,26 @@ fn main() -> Result<()> {
let mut model = RTDETR::new(options)?;

// load
let x = [DataLoader::try_read("./assets/bus.jpg")?];
let xs = [DataLoader::try_read("./assets/bus.jpg")?];

// run
let y = model.forward(&x)?;
println!("{:?}", y);
let ys = model.forward(&xs)?;

// extract bboxes
for y in ys.iter() {
if let Some(bboxes) = y.bboxes() {
println!("[Bboxes]: Found {} objects", bboxes.len());
for (i, bbox) in bboxes.iter().enumerate() {
println!("{}: {:?}", i, bbox)
}
}
}

// annotate
let annotator = Annotator::default()
.with_bboxes_thickness(3)
.with_saveout(model.spec());
annotator.annotate(&x, &y);
annotator.annotate(&xs, &ys);

Ok(())
}
1 change: 0 additions & 1 deletion examples/sam/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ cargo run -r -F cuda --example sam -- --device cuda --kind edge-sam
cargo run -r -F cuda --example sam -- --device cuda --kind sam-hq
```


## Results

![](https://github.com/jamjamjon/assets/releases/download/sam/demo-car.png)
Expand Down
1 change: 0 additions & 1 deletion examples/sapiens/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
cargo run -r -F cuda --example sapiens -- --device cuda
```


## Results

![](https://github.com/jamjamjon/assets/releases/download/sapiens/demo.png)
1 change: 0 additions & 1 deletion examples/slanet/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
cargo run -r -F cuda --example slanet -- --device cuda
```


## Results

![](https://github.com/jamjamjon/assets/releases/download/slanet/demo.png)
16 changes: 8 additions & 8 deletions examples/yolo/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -223,14 +223,14 @@ fn main() -> Result<()> {
for (xs, _paths) in dl {
let ys = model.forward(&xs)?;
// extract bboxes
for y in ys.iter() {
if let Some(bboxes) = y.bboxes() {
println!("[Bboxes]: Found {} objects", bboxes.len());
for (i, bbox) in bboxes.iter().enumerate() {
println!("{}: {:?}", i, bbox)
}
}
}
// for y in ys.iter() {
// if let Some(bboxes) = y.bboxes() {
// println!("[Bboxes]: Found {} objects", bboxes.len());
// for (i, bbox) in bboxes.iter().enumerate() {
// println!("{}: {:?}", i, bbox)
// }
// }
// }

// plot
annotator.annotate(&xs, &ys);
Expand Down
9 changes: 9 additions & 0 deletions examples/yolov8-rtdetr/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
## Quick Start

```shell
cargo run -r -F cuda --example yolov8-rtdetr -- --device cuda
```

```shell
Ys([Y { BBoxes: [Bbox { xyxy: [668.71356, 395.4159, 809.01587, 879.3043], class_id: 0, name: Some("person"), confidence: 0.950527 }, Bbox { xyxy: [48.866394, 399.50665, 248.22641, 904.7525], class_id: 0, name: Some("person"), confidence: 0.9504415 }, Bbox { xyxy: [20.197449, 230.00304, 805.026, 730.3445], class_id: 5, name: Some("bus"), confidence: 0.94705224 }, Bbox { xyxy: [221.3088, 405.65436, 345.44052, 860.2628], class_id: 0, name: Some("person"), confidence: 0.93062377 }, Bbox { xyxy: [0.34117508, 549.8391, 76.50758, 868.87646], class_id: 0, name: Some("person"), confidence: 0.71064234 }, Bbox { xyxy: [282.12543, 484.14166, 296.43207, 520.96246], class_id: 27, name: Some("tie"), confidence: 0.40305245 }] }])
```
6 changes: 0 additions & 6 deletions examples/yolov8-rtdetr.rs → examples/yolov8-rtdetr/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,6 @@ struct Args {
}

fn main() -> Result<()> {
tracing_subscriber::fmt()
.with_max_level(tracing::Level::INFO)
.init();

let args: Args = argh::from_env();

// build model
Expand All @@ -40,7 +36,5 @@ fn main() -> Result<()> {
.with_saveout(model.spec());
annotator.annotate(&xs, &ys);

model.summary();

Ok(())
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion src/models/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ mod beit;
mod blip;
mod clip;
mod convnext;
mod d_fine;
mod db;
mod deim;
mod deit;
mod depth_anything;
mod depth_pro;
mod dfine;
mod dinov2;
mod fastvit;
mod florence2;
Expand Down

0 comments on commit a6c2ae4

Please sign in to comment.