0.0.14: DataLoader now support video and streaming

- Added `Hub` for resource management
- Updated `DataLoader` to support video and streaming
- Updated `CI`
- Replaced `println!` with `tracing` for logging
This commit is contained in:
Jamjamjon
2024-09-16 10:41:16 +08:00
committed by GitHub
parent 826da4037e
commit 0adddd3bbd
82 changed files with 1739 additions and 583 deletions

View File

@@ -6,17 +6,11 @@ This demo shows how to use [BLIP](https://arxiv.org/abs/2201.12086) to do condit
cargo run -r --example blip
```
## BLIP ONNX Model
- [blip-visual-base](https://github.com/jamjamjon/assets/releases/download/v0.0.1/blip-visual-base.onnx)
- [blip-textual-base](https://github.com/jamjamjon/assets/releases/download/v0.0.1/blip-textual-base.onnx)
## Results
```shell
[Unconditional image captioning]: a group of people walking around a bus
[Conditional image captioning]: three man walking in front of a bus
[Unconditional]: a group of people walking around a bus
[Conditional]: three man walking in front of a bus
Some(["three man walking in front of a bus"])
```

View File

@@ -3,14 +3,14 @@ use usls::{models::Blip, DataLoader, Options};
fn main() -> Result<(), Box<dyn std::error::Error>> {
// visual
let options_visual = Options::default()
.with_model("blip-visual-base.onnx")?
.with_model("blip/visual-base.onnx")?
.with_i00((1, 1, 4).into())
.with_profile(false);
// textual
let options_textual = Options::default()
.with_model("blip-textual-base.onnx")?
// .with_tokenizer("tokenizer-blip.json")?
.with_model("blip/textual-base.onnx")?
// .with_tokenizer("blip/tokenizer.json")?
.with_i00((1, 1, 4).into()) // input_id: batch
.with_i01((1, 1, 4).into()) // input_id: seq_len
.with_i10((1, 1, 4).into()) // attention_mask: batch
@@ -23,7 +23,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
let mut model = Blip::new(options_visual, options_textual)?;
// image caption (this demo use batch_size=1)
let xs = vec![DataLoader::try_read("./assets/bus.jpg")?];
let xs = [DataLoader::try_read("images/bus.jpg")?];
let image_embeddings = model.encode_images(&xs)?;
let _y = model.caption(&image_embeddings, None, true)?; // unconditional
let y = model.caption(&image_embeddings, Some("three man"), true)?; // conditional

View File

@@ -6,12 +6,6 @@ This demo showcases how to use [CLIP](https://github.com/openai/CLIP) to compute
cargo run -r --example clip
```
## CLIP ONNX Model
- [clip-b32-visual](https://github.com/jamjamjon/assets/releases/download/v0.0.1/clip-b32-visual.onnx)
- [clip-b32-textual](https://github.com/jamjamjon/assets/releases/download/v0.0.1/clip-b32-textual.onnx)
## Results
```shell

View File

@@ -3,14 +3,14 @@ use usls::{models::Clip, DataLoader, Options};
fn main() -> Result<(), Box<dyn std::error::Error>> {
// visual
let options_visual = Options::default()
.with_model("clip-b32-visual-dyn.onnx")?
.with_model("clip/visual-base-dyn.onnx")?
.with_i00((1, 1, 4).into())
.with_profile(false);
// textual
let options_textual = Options::default()
.with_model("clip-b32-textual-dyn.onnx")?
// .with_tokenizer("tokenizer-clip.json")?
.with_model("clip/textual-base-dyn.onnx")?
.with_tokenizer("clip/tokenizer.json")?
.with_i00((1, 1, 4).into())
.with_profile(false);
@@ -30,9 +30,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
let feats_text = model.encode_texts(&texts)?; // [n, ndim]
// load image
let dl = DataLoader::default()
.with_batch(model.batch_visual())
.load("./examples/clip/images")?;
let dl = DataLoader::new("./examples/clip/images")?.build()?;
// loop
for (images, paths) in dl {

View File

@@ -0,0 +1,49 @@
use usls::{models::YOLO, Annotator, DataLoader, Options, Vision, YOLOTask, YOLOVersion};
fn main() -> anyhow::Result<()> {
tracing_subscriber::fmt()
.with_max_level(tracing::Level::ERROR)
.init();
let options = Options::new()
.with_cuda(0)
.with_model("yolo/v8-m-dyn.onnx")?
.with_yolo_version(YOLOVersion::V8)
.with_yolo_task(YOLOTask::Detect)
.with_i00((1, 1, 4).into())
.with_i02((0, 640, 640).into())
.with_i03((0, 640, 640).into())
.with_confs(&[0.2]);
let mut model = YOLO::new(options)?;
// build dataloader
let dl = DataLoader::new(
"./assets/bus.jpg", // local image
// "images/bus.jpg", // remote image
// "../images", // image folder
// "../demo.mp4", // local video
// "http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4", // remote video
// "rtsp://admin:xyz@192.168.2.217:554/h265/ch1/", // rtsp h264 stream
)?
.with_batch(1)
.with_progress_bar(true)
.with_bound(100)
.build()?;
// // build annotator
let annotator = Annotator::new()
.with_bboxes_thickness(4)
.with_saveout("YOLO-DataLoader");
// run
for (xs, _) in dl {
// std::thread::sleep(std::time::Duration::from_millis(1000));
let ys = model.forward(&xs, false)?;
annotator.annotate(&xs, &ys);
}
// images -> video
// DataLoader::is2v("runs/YOLO-DataLoader", &["runs", "is2v"], 24)?;
Ok(())
}

View File

@@ -4,11 +4,6 @@
cargo run -r --example db
```
## ONNX Model
- [ppocr-v3-db-dyn](https://github.com/jamjamjon/assets/releases/download/v0.0.1/ppocr-v3-db-dyn.onnx)
- [ppocr-v4-db-dyn](https://github.com/jamjamjon/assets/releases/download/v0.0.1/ppocr-v4-db-dyn.onnx)
### Speed test
| Model | Image size | TensorRT<br />f16<br />batch=1<br />(ms) | TensorRT<br />f32<br />batch=1<br />(ms) | CUDA<br />f32<br />batch=1<br />(ms) |
@@ -20,4 +15,5 @@ cargo run -r --example db
## Results
![](./demo.png)
![](https://github.com/jamjamjon/assets/releases/download/db/demo-paper.png)
![](https://github.com/jamjamjon/assets/releases/download/db/demo-sign.png)

Binary file not shown.

Before

Width:  |  Height:  |  Size: 35 KiB

View File

@@ -10,14 +10,14 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
.with_confs(&[0.4])
.with_min_width(5.0)
.with_min_height(12.0)
.with_model("ppocr-v4-db-dyn.onnx")?;
.with_model("db/ppocr-v4-db-dyn.onnx")?;
let mut model = DB::new(options)?;
// load image
let x = vec![
DataLoader::try_read("./assets/db.png")?,
DataLoader::try_read("./assets/2.jpg")?,
let x = [
DataLoader::try_read("images/db.png")?,
DataLoader::try_read("images/street.jpg")?,
];
// run

View File

@@ -4,14 +4,7 @@
cargo run -r --example depth-anything
```
## ONNX Model
- [depth-anything-s-dyn](https://github.com/jamjamjon/assets/releases/download/v0.0.1/depth-anything-s-dyn.onnx)
- [depth-anything-b-dyn](https://github.com/jamjamjon/assets/releases/download/v0.0.1/depth-anything-b-dyn.onnx)
- [depth-anything-l-dyn](https://github.com/jamjamjon/assets/releases/download/v0.0.1/depth-anything-l-dyn.onnx)
- [depth-anything-v2-s](https://github.com/jamjamjon/assets/releases/download/v0.0.1/depth-anything-v2-s.onnx)
## Results
![](./demo.png)
![](https://github.com/jamjamjon/assets/releases/download/depth-anything/demo.png)

Binary file not shown.

Before

Width:  |  Height:  |  Size: 175 KiB

View File

@@ -3,15 +3,15 @@ use usls::{models::DepthAnything, Annotator, DataLoader, Options};
fn main() -> Result<(), Box<dyn std::error::Error>> {
// options
let options = Options::default()
// .with_model("depth-anything-s-dyn.onnx")?
.with_model("depth-anything-v2-s.onnx")?
// .with_model("depth-anything/v1-s-dyn.onnx")?
.with_model("depth-anything/v2-s.onnx")?
.with_i00((1, 1, 8).into())
.with_i02((384, 512, 1024).into())
.with_i03((384, 512, 1024).into());
let mut model = DepthAnything::new(options)?;
// load
let x = [DataLoader::try_read("./assets/2.jpg")?];
let x = [DataLoader::try_read("images/2.jpg")?];
// run
let y = model.run(&x)?;

View File

@@ -5,22 +5,3 @@ This demo showcases how to use `DINOv2` to compute image similarity, applicable
```shell
cargo run -r --example dinov2
```
## Donwload DINOv2 ONNX Model
- [dinov2-s14](https://github.com/jamjamjon/assets/releases/download/v0.0.1/dinov2-s14.onnx)
- [dinov2-s14-dyn](https://github.com/jamjamjon/assets/releases/download/v0.0.1/dinov2-s14-dyn.onnx)
- [dinov2-s14-dyn-f16](https://github.com/jamjamjon/assets/releases/download/v0.0.1/dinov2-s14-dyn-f16.onnx)
- [dinov2-b14](https://github.com/jamjamjon/assets/releases/download/v0.0.1/dinov2-b14.onnx)
- [dinov2-b14-dyn](https://github.com/jamjamjon/assets/releases/download/v0.0.1/dinov2-b14-dyn.onnx)
## Results
```shell
Top-1 0.0000000 /home/qweasd/Desktop/usls/examples/dinov2/images/bus.jpg
Top-2 1.9059424 /home/qweasd/Desktop/usls/examples/dinov2/images/1.jpg
Top-3 1.9736203 /home/qweasd/Desktop/usls/examples/dinov2/images/2.jpg
```

Binary file not shown.

Before

Width:  |  Height:  |  Size: 66 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 44 KiB

View File

@@ -3,15 +3,16 @@ use usls::{models::Dinov2, DataLoader, Options};
fn main() -> Result<(), Box<dyn std::error::Error>> {
// build model
let options = Options::default()
.with_model("dinov2-s14-dyn-f16.onnx")?
.with_model("dinov2/s-dyn.onnx")?
.with_i00((1, 1, 1).into())
.with_i02((224, 224, 224).into())
.with_i03((224, 224, 224).into());
let mut model = Dinov2::new(options)?;
let x = vec![DataLoader::try_read("./examples/dinov2/images/1.jpg")?];
let x = [DataLoader::try_read("images/bus.jpg")?];
let y = model.run(&x)?;
println!("{y:?}");
// TODO:
// query from vector
// let ys = model.query_from_vec(
// "./assets/bus.jpg",

View File

@@ -0,0 +1,10 @@
## Quick Start
```shell
cargo run -r --example grounding-dino
```
## Results
![](https://github.com/jamjamjon/assets/releases/download/grounding-dino/demo.png)

View File

@@ -16,14 +16,15 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
.with_i50((1, 1, 4).into())
.with_i51((256, 256, 512).into())
.with_i52((256, 256, 512).into())
.with_model("groundingdino-swint-ogc-dyn-u8.onnx")? // TODO: current onnx model does not support bs > 1
// .with_model("groundingdino-swint-ogc-dyn-f32.onnx")?
.with_model("grounding-dino/swint-ogc-dyn-u8.onnx")? // TODO: current onnx model does not support bs > 1
// .with_model("grounding-dino/swint-ogc-dyn-f32.onnx")?
.with_tokenizer("grounding-dino/tokenizer.json")?
.with_confs(&[0.2])
.with_profile(false);
let mut model = GroundingDINO::new(opts)?;
// Load images and set class names
let x = [DataLoader::try_read("./assets/bus.jpg")?];
let x = [DataLoader::try_read("images/bus.jpg")?];
let texts = [
"person", "hand", "shoes", "bus", "dog", "cat", "sign", "tie", "monitor", "window",
"glasses", "tree", "head",

View File

@@ -4,12 +4,7 @@
cargo run -r --example modnet
```
## ONNX Model
- [modnet-dyn](https://github.com/jamjamjon/assets/releases/download/v0.0.1/modnet-dyn.onnx)
## Results
![](./demo.png)
![](https://github.com/jamjamjon/assets/releases/download/modnet/demo.png)

Binary file not shown.

Before

Width:  |  Height:  |  Size: 128 KiB

View File

@@ -3,14 +3,14 @@ use usls::{models::MODNet, Annotator, DataLoader, Options};
fn main() -> Result<(), Box<dyn std::error::Error>> {
// build model
let options = Options::default()
.with_model("modnet-dyn.onnx")?
.with_model("modnet/dyn-f32.onnx")?
.with_i00((1, 1, 4).into())
.with_i02((416, 512, 800).into())
.with_i03((416, 512, 800).into());
let mut model = MODNet::new(options)?;
// load image
let x = vec![DataLoader::try_read("./assets/liuyifei.png")?];
let x = [DataLoader::try_read("images/liuyifei.png")?];
// run
let y = model.run(&x)?;

View File

@@ -3,16 +3,8 @@
```shell
cargo run -r --example rtmo
```
## ONNX Model
- [rtmo-s-dyn model](https://github.com/jamjamjon/assets/releases/download/v0.0.1/rtmo-s-dyn.onnx)
- [rtmo-m-dyn model](https://github.com/jamjamjon/assets/releases/download/v0.0.1/rtmo-m-dyn.onnx)
- [rtmo-l-dyn model](https://github.com/jamjamjon/assets/releases/download/v0.0.1/rtmo-l-dyn.onnx)
- [rtmo-s-dyn-f16 model](https://github.com/jamjamjon/assets/releases/download/v0.0.1/rtmo-s-dyn-f16.onnx)
- [rtmo-m-dyn-f16 model](https://github.com/jamjamjon/assets/releases/download/v0.0.1/rtmo-m-dyn-f16.onnx)
- [rtmo-l-dyn-f16 model](https://github.com/jamjamjon/assets/releases/download/v0.0.1/rtmo-l-dyn-f16.onnx)
## Results
![](./demo.png)
![](https://github.com/jamjamjon/assets/releases/download/rtmo/demo.png)

Binary file not shown.

Before

Width:  |  Height:  |  Size: 455 KiB

View File

@@ -3,7 +3,7 @@ use usls::{models::RTMO, Annotator, DataLoader, Options, COCO_SKELETONS_16};
fn main() -> Result<(), Box<dyn std::error::Error>> {
// build model
let options = Options::default()
.with_model("rtmo-s-dyn.onnx")?
.with_model("rtmo/s-dyn.onnx")?
.with_i00((1, 1, 8).into())
.with_nk(17)
.with_confs(&[0.3])
@@ -11,7 +11,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
let mut model = RTMO::new(options)?;
// load image
let x = vec![DataLoader::try_read("./assets/bus.jpg")?];
let x = [DataLoader::try_read("images/bus.jpg")?];
// run
let y = model.run(&x)?;

View File

@@ -18,4 +18,5 @@ cargo run -r --example sam -- --kind sam-hq
## Results
![](./demo.png)
![](https://github.com/jamjamjon/assets/releases/download/sam/demo-car.png)
![](https://github.com/jamjamjon/assets/releases/download/sam/demo-dog.png)

Binary file not shown.

Before

Width:  |  Height:  |  Size: 326 KiB

View File

@@ -25,63 +25,64 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
let (options_encoder, options_decoder, saveout) = match args.kind {
SamKind::Sam => {
let options_encoder = Options::default()
// .with_model("sam-vit-b-encoder.onnx")?;
.with_model("sam-vit-b-encoder-u8.onnx")?;
// .with_model("sam/sam-vit-b-encoder.onnx")?;
.with_model("sam/sam-vit-b-encoder-u8.onnx")?;
let options_decoder = Options::default()
.with_i00((1, 1, 1).into())
.with_i11((1, 1, 1).into())
.with_i21((1, 1, 1).into())
.with_sam_kind(SamKind::Sam)
// .with_model("sam-vit-b-decoder.onnx")?;
// .with_model("sam-vit-b-decoder-singlemask.onnx")?;
.with_model("sam-vit-b-decoder-u8.onnx")?;
// .with_model("sam/sam-vit-b-decoder.onnx")?;
// .with_model("sam/sam-vit-b-decoder-singlemask.onnx")?;
.with_model("sam/sam-vit-b-decoder-u8.onnx")?;
(options_encoder, options_decoder, "SAM")
}
SamKind::Sam2 => {
let options_encoder = Options::default()
// .with_model("sam2-hiera-tiny-encoder.onnx")?;
// .with_model("sam2-hiera-small-encoder.onnx")?;
.with_model("sam2-hiera-base-plus-encoder.onnx")?;
// .with_model("sam/sam2-hiera-tiny-encoder.onnx")?;
// .with_model("sam/sam2-hiera-small-encoder.onnx")?;
.with_model("sam/sam2-hiera-base-plus-encoder.onnx")?;
let options_decoder = Options::default()
.with_i31((1, 1, 1).into())
.with_i41((1, 1, 1).into())
.with_sam_kind(SamKind::Sam2)
// .with_model("sam2-hiera-tiny-decoder.onnx")?;
// .with_model("sam2-hiera-small-decoder.onnx")?;
.with_model("sam2-hiera-base-plus-decoder.onnx")?;
// .with_model("sam/sam2-hiera-tiny-decoder.onnx")?;
// .with_model("sam/sam2-hiera-small-decoder.onnx")?;
.with_model("sam/sam2-hiera-base-plus-decoder.onnx")?;
(options_encoder, options_decoder, "SAM2")
}
SamKind::MobileSam => {
let options_encoder = Options::default().with_model("mobile-sam-vit-t-encoder.onnx")?;
let options_encoder =
Options::default().with_model("sam/mobile-sam-vit-t-encoder.onnx")?;
let options_decoder = Options::default()
.with_i00((1, 1, 1).into())
.with_i11((1, 1, 1).into())
.with_i21((1, 1, 1).into())
.with_sam_kind(SamKind::MobileSam)
.with_model("mobile-sam-vit-t-decoder.onnx")?;
.with_model("sam/mobile-sam-vit-t-decoder.onnx")?;
(options_encoder, options_decoder, "Mobile-SAM")
}
SamKind::SamHq => {
let options_encoder = Options::default().with_model("sam-hq-vit-t-encoder.onnx")?;
let options_encoder = Options::default().with_model("sam/sam-hq-vit-t-encoder.onnx")?;
let options_decoder = Options::default()
.with_i00((1, 1, 1).into())
.with_i21((1, 1, 1).into())
.with_i31((1, 1, 1).into())
.with_sam_kind(SamKind::SamHq)
.with_model("sam-hq-vit-t-decoder.onnx")?;
.with_model("sam/sam-hq-vit-t-decoder.onnx")?;
(options_encoder, options_decoder, "SAM-HQ")
}
SamKind::EdgeSam => {
let options_encoder = Options::default().with_model("edge-sam-3x-encoder.onnx")?;
let options_encoder = Options::default().with_model("sam/edge-sam-3x-encoder.onnx")?;
let options_decoder = Options::default()
.with_i00((1, 1, 1).into())
.with_i11((1, 1, 1).into())
.with_i21((1, 1, 1).into())
.with_sam_kind(SamKind::EdgeSam)
.with_model("edge-sam-3x-decoder.onnx")?;
.with_model("sam/edge-sam-3x-decoder.onnx")?;
(options_encoder, options_decoder, "Edge-SAM")
}
};
@@ -100,8 +101,8 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
// Load image
let xs = [
DataLoader::try_read("./assets/truck.jpg")?,
// DataLoader::try_read("./assets/dog.jpg")?,
DataLoader::try_read("images/truck.jpg")?,
// DataLoader::try_read("images/dog.jpg")?,
];
// Build annotator

View File

@@ -0,0 +1,10 @@
## Quick Start
```shell
cargo run -r --example sapiens
```
## Results
![](https://github.com/jamjamjon/assets/releases/download/sapiens/demo.png)

View File

@@ -6,7 +6,7 @@ use usls::{
fn main() -> Result<(), Box<dyn std::error::Error>> {
// build
let options = Options::default()
.with_model("sapiens-seg-0.3b-dyn.onnx")?
.with_model("sapiens/seg-0.3b-dyn.onnx")?
.with_sapiens_task(SapiensTask::Seg)
.with_names(&BODY_PARTS_28)
.with_profile(false)
@@ -14,7 +14,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
let mut model = Sapiens::new(options)?;
// load
let x = [DataLoader::try_read("./assets/paul-george.jpg")?];
let x = [DataLoader::try_read("images/paul-george.jpg")?];
// run
let y = model.run(&x)?;

View File

@@ -4,13 +4,6 @@
cargo run -r --example svtr
```
## ONNX Model
- [ppocr-v4-server-svtr-ch-dyn](https://github.com/jamjamjon/assets/releases/download/v0.0.1/ppocr-v4-server-svtr-ch-dyn.onnx)
- [ppocr-v4-svtr-ch-dyn](https://github.com/jamjamjon/assets/releases/download/v0.0.1/ppocr-v4-svtr-ch-dyn.onnx)
- [ppocr-v3-svtr-ch-dyn](https://github.com/jamjamjon/assets/releases/download/v0.0.1/ppocr-v3-svtr-ch-dyn.onnx)
### Speed test
| Model | Width | TensorRT<br />f16<br />batch=1<br />(ms) | TensorRT<br />f32<br />batch=1<br />(ms) | CUDA<br />f32<br />batch=1<br />(ms) |

View File

@@ -6,14 +6,12 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
.with_i00((1, 2, 8).into())
.with_i03((320, 960, 1600).into())
.with_confs(&[0.2])
.with_vocab("ppocr_rec_vocab.txt")?
.with_model("ppocr-v4-svtr-ch-dyn.onnx")?;
.with_vocab("svtr/ppocr_rec_vocab.txt")?
.with_model("svtr/ppocr-v4-svtr-ch-dyn.onnx")?;
let mut model = SVTR::new(options)?;
// load images
let dl = DataLoader::default()
.with_batch(1)
.load("./examples/svtr/images")?;
let dl = DataLoader::new("./examples/svtr/images")?.build()?;
// run
for (xs, paths) in dl {

View File

@@ -0,0 +1,9 @@
## Quick Start
```shell
cargo run -r --example yolo-sam
```
## Results
![](https://github.com/jamjamjon/assets/releases/download/sam/demo-yolo-sam.png)

Binary file not shown.

Before

Width:  |  Height:  |  Size: 133 KiB

View File

@@ -7,20 +7,20 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
// build SAM
let options_encoder = Options::default()
.with_i00((1, 1, 1).into())
.with_model("mobile-sam-vit-t-encoder.onnx")?;
.with_model("sam/mobile-sam-vit-t-encoder.onnx")?;
let options_decoder = Options::default()
.with_i11((1, 1, 1).into())
.with_i21((1, 1, 1).into())
.with_find_contours(true)
.with_sam_kind(SamKind::Sam)
.with_model("mobile-sam-vit-t-decoder.onnx")?;
.with_model("sam/mobile-sam-vit-t-decoder.onnx")?;
let mut sam = SAM::new(options_encoder, options_decoder)?;
// build YOLOv8-Det
let options_yolo = Options::default()
.with_yolo_version(YOLOVersion::V8)
.with_yolo_task(YOLOTask::Detect)
.with_model("yolov8m-dyn.onnx")?
.with_model("yolo/v8-m-dyn.onnx")?
.with_cuda(0)
.with_i00((1, 1, 4).into())
.with_i02((416, 640, 800).into())
@@ -30,7 +30,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
let mut yolo = YOLO::new(options_yolo)?;
// load one image
let xs = vec![DataLoader::try_read("./assets/dog.jpg")?];
let xs = [DataLoader::try_read("images/dog.jpg")?];
// build annotator
let annotator = Annotator::default()
@@ -38,7 +38,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
.without_bboxes_name(true)
.without_bboxes_conf(true)
.without_mbrs(true)
.with_saveout("YOLO+SAM");
.with_saveout("YOLO-SAM");
// run & annotate
let ys_det = yolo.run(&xs)?;

View File

@@ -3,19 +3,19 @@
| Detection | Instance Segmentation | Pose |
| :---------------: | :------------------------: |:---------------: |
| <img src='./demos/det.png' width="300px"> | <img src='./demos/seg.png' width="300px"> |<img src='./demos/pose.png' width="300px"> |
| <img src='https://github.com/jamjamjon/assets/releases/download/yolo/demo-det.png' width="300px"> | <img src='https://github.com/jamjamjon/assets/releases/download/yolo/demo-seg.png' width="300px"> |<img src='https://github.com/jamjamjon/assets/releases/download/yolo/demo-pose.png' width="300px"> |
| Classification | Obb |
| :------------------------: |:------------------------: |
|<img src='./demos/cls.png' width="300px"> |<img src='./demos/obb-2.png' width="628px">
|<img src='https://github.com/jamjamjon/assets/releases/download/yolo/demo-cls.png' width="300px"> |<img src='https://github.com/jamjamjon/assets/releases/download/yolo/demo-obb-2.png' width="628px">
| Head Detection | Fall Detection | Trash Detection |
| :------------------------: |:------------------------: |:------------------------: |
|<img src='./demos/head.png' width="300px"> |<img src='./demos/falldown.png' width="300px">|<img src='./demos/trash.png' width="300px">
|<img src='https://github.com/jamjamjon/assets/releases/download/yolo/demo-head.png' width="300px"> |<img src='https://github.com/jamjamjon/assets/releases/download/yolo/demo-falldown.png' width="300px">|<img src='https://github.com/jamjamjon/assets/releases/download/yolo/demo-trash.png' width="300px">
| YOLO-World | Face Parsing | FastSAM |
| :------------------------: |:------------------------: |:------------------------: |
|<img src='./demos/yolov8-world.png' width="300px"> |<img src='./demos/face-parsing.png' width="300px">|<img src='./demos/fastsam.png' width="300px">
|<img src='https://github.com/jamjamjon/assets/releases/download/yolo/demo-yolov8-world.png' width="300px"> |<img src='https://github.com/jamjamjon/assets/releases/download/yolo/demo-face-parsing.png' width="300px">|<img src='https://github.com/jamjamjon/assets/releases/download/yolo/demo-fastsam.png' width="300px">
@@ -104,11 +104,11 @@ let options = Options::default()
| Model | Weights | Datasets|
|:---------------------: | :--------------------------: | :-------------------------------: |
| Face-Landmark Detection | [yolov8-face-dyn-f16](https://github.com/jamjamjon/assets/releases/download/v0.0.1/yolov8-face-dyn-f16.onnx) | |
| Head Detection | [yolov8-head-f16](https://github.com/jamjamjon/assets/releases/download/v0.0.1/yolov8-head-f16.onnx) | |
| Fall Detection | [yolov8-falldown-f16](https://github.com/jamjamjon/assets/releases/download/v0.0.1/yolov8-falldown-f16.onnx) | |
| Trash Detection | [yolov8-plastic-bag-f16](https://github.com/jamjamjon/assets/releases/download/v0.0.1/yolov8-plastic-bag-f16.onnx) | |
| FaceParsing | [face-parsing-dyn](https://github.com/jamjamjon/assets/releases/download/v0.0.1/face-parsing-dyn.onnx) | [CelebAMask-HQ](https://github.com/switchablenorms/CelebAMask-HQ/tree/master/face_parsing)<br />[[Processed YOLO labels]](https://github.com/jamjamjon/assets/releases/download/v0.0.1/CelebAMask-HQ-YOLO-Labels.zip)[[Python Script]](https://github.com/jamjamjon/assets/releases/download/v0.0.1/CelebAMask-HQ-YOLO-Labels.zip) |
| Face-Landmark Detection | [yolov8-face-dyn-f16](https://github.com/jamjamjon/assets/releases/download/yolo/v8-n-face-dyn-f16.onnx) | |
| Head Detection | [yolov8-head-f16](https://github.com/jamjamjon/assets/releases/download/yolo/v8-head-f16.onnx) | |
| Fall Detection | [yolov8-falldown-f16](https://github.com/jamjamjon/assets/releases/download/yolo/v8-falldown-f16.onnx) | |
| Trash Detection | [yolov8-plastic-bag-f16](https://github.com/jamjamjon/assets/releases/download/yolo/v8-plastic-bag-f16.onnx) | |
| FaceParsing | [yolov8-face-parsing-dyn](https://github.com/jamjamjon/assets/releases/download/yolo/v8-face-parsing-dyn.onnx) | [CelebAMask-HQ](https://github.com/switchablenorms/CelebAMask-HQ/tree/master/face_parsing)<br />[[Processed YOLO labels]](https://github.com/jamjamjon/assets/releases/download/yolo/CelebAMask-HQ-YOLO-Labels.zip)[[Python Script]](../../scripts/CelebAMask-HQ-To-YOLO-Labels.py) |

Binary file not shown.

Before

Width:  |  Height:  |  Size: 453 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 451 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 105 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 286 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 57 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 321 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 291 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 546 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 552 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 457 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 391 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 367 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 453 KiB

View File

@@ -77,15 +77,15 @@ fn main() -> Result<()> {
let (options, saveout) = match args.ver {
YOLOVersion::V5 => match args.task {
YOLOTask::Classify => (
options.with_model(&args.model.unwrap_or("yolov5n-cls-dyn.onnx".to_string()))?,
options.with_model(&args.model.unwrap_or("yolo/v5-n-cls-dyn.onnx".to_string()))?,
"YOLOv5-Classify",
),
YOLOTask::Detect => (
options.with_model(&args.model.unwrap_or("yolov5n-dyn.onnx".to_string()))?,
options.with_model(&args.model.unwrap_or("yolo/v5-n-dyn.onnx".to_string()))?,
"YOLOv5-Detect",
),
YOLOTask::Segment => (
options.with_model(&args.model.unwrap_or("yolov5n-seg-dyn.onnx".to_string()))?,
options.with_model(&args.model.unwrap_or("yolo/v5-n-seg-dyn.onnx".to_string()))?,
"YOLOv5-Segment",
),
t => anyhow::bail!("Task: {t:?} is unsupported for {:?}", args.ver),
@@ -93,7 +93,7 @@ fn main() -> Result<()> {
YOLOVersion::V6 => match args.task {
YOLOTask::Detect => (
options
.with_model(&args.model.unwrap_or("yolov6n-dyn.onnx".to_string()))?
.with_model(&args.model.unwrap_or("yolo/v6-n-dyn.onnx".to_string()))?
.with_nc(args.nc),
"YOLOv6-Detect",
),
@@ -102,7 +102,7 @@ fn main() -> Result<()> {
YOLOVersion::V7 => match args.task {
YOLOTask::Detect => (
options
.with_model(&args.model.unwrap_or("yolov7-tiny-dyn.onnx".to_string()))?
.with_model(&args.model.unwrap_or("yolo/v7-tiny-dyn.onnx".to_string()))?
.with_nc(args.nc),
"YOLOv7-Detect",
),
@@ -110,43 +110,43 @@ fn main() -> Result<()> {
},
YOLOVersion::V8 => match args.task {
YOLOTask::Classify => (
options.with_model(&args.model.unwrap_or("yolov8m-cls-dyn.onnx".to_string()))?,
options.with_model(&args.model.unwrap_or("yolo/v8-m-cls-dyn.onnx".to_string()))?,
"YOLOv8-Classify",
),
YOLOTask::Detect => (
options.with_model(&args.model.unwrap_or("yolov8m-dyn.onnx".to_string()))?,
options.with_model(&args.model.unwrap_or("yolo/v8-m-dyn.onnx".to_string()))?,
"YOLOv8-Detect",
),
YOLOTask::Segment => (
options.with_model(&args.model.unwrap_or("yolov8m-seg-dyn.onnx".to_string()))?,
options.with_model(&args.model.unwrap_or("yolo/v8-m-seg-dyn.onnx".to_string()))?,
"YOLOv8-Segment",
),
YOLOTask::Pose => (
options.with_model(&args.model.unwrap_or("yolov8m-pose-dyn.onnx".to_string()))?,
options.with_model(&args.model.unwrap_or("yolo/v8-m-pose-dyn.onnx".to_string()))?,
"YOLOv8-Pose",
),
YOLOTask::Obb => (
options.with_model(&args.model.unwrap_or("yolov8m-obb-dyn.onnx".to_string()))?,
options.with_model(&args.model.unwrap_or("yolo/v8-m-obb-dyn.onnx".to_string()))?,
"YOLOv8-Obb",
),
},
YOLOVersion::V9 => match args.task {
YOLOTask::Detect => (
options.with_model(&args.model.unwrap_or("yolov9-c-dyn-f16.onnx".to_string()))?,
options.with_model(&args.model.unwrap_or("yolo/v9-c-dyn-f16.onnx".to_string()))?,
"YOLOv9-Detect",
),
t => anyhow::bail!("Task: {t:?} is unsupported for {:?}", args.ver),
},
YOLOVersion::V10 => match args.task {
YOLOTask::Detect => (
options.with_model(&args.model.unwrap_or("yolov10n.onnx".to_string()))?,
options.with_model(&args.model.unwrap_or("yolo/v10-n.onnx".to_string()))?,
"YOLOv10-Detect",
),
t => anyhow::bail!("Task: {t:?} is unsupported for {:?}", args.ver),
},
YOLOVersion::RTDETR => match args.task {
YOLOTask::Detect => (
options.with_model(&args.model.unwrap_or("rtdetr-l-f16.onnx".to_string()))?,
options.with_model(&args.model.unwrap_or("yolo/rtdetr-l-f16.onnx".to_string()))?,
"RTDETR",
),
t => anyhow::bail!("Task: {t:?} is unsupported for {:?}", args.ver),
@@ -184,9 +184,9 @@ fn main() -> Result<()> {
let mut model = YOLO::new(options)?;
// build dataloader
let dl = DataLoader::default()
let dl = DataLoader::new(&args.source)?
.with_batch(model.batch() as _)
.load(args.source)?;
.build()?;
// build annotator
let annotator = Annotator::default()

View File

@@ -4,11 +4,6 @@
cargo run -r --example yolop
```
## Pretrained Model
- [yolopv2-dyn-480x800](https://github.com/jamjamjon/assets/releases/download/v0.0.1/yolopv2-dyn-480x800.onnx)
- [yolopv2-dyn-736x1280](https://github.com/jamjamjon/assets/releases/download/v0.0.1/yolopv2-dyn-736x1280.onnx)
## Results
![](./demo.png)
![](https://github.com/jamjamjon/assets/releases/download/yolop/demo.png)

Binary file not shown.

Before

Width:  |  Height:  |  Size: 296 KiB

View File

@@ -3,13 +3,13 @@ use usls::{models::YOLOPv2, Annotator, DataLoader, Options};
fn main() -> Result<(), Box<dyn std::error::Error>> {
// build model
let options = Options::default()
.with_model("yolopv2-dyn-480x800.onnx")?
.with_model("yolop/v2-dyn-480x800.onnx")?
.with_i00((1, 1, 8).into())
.with_confs(&[0.3]);
let mut model = YOLOPv2::new(options)?;
// load image
let x = vec![DataLoader::try_read("./assets/car.jpg")?];
let x = [DataLoader::try_read("images/car.jpg")?];
// run
let y = model.run(&x)?;