Add RTMO model for keypoint detection (#2)

* Add RTMO
This commit is contained in:
Jamjamjon
2024-04-08 20:45:38 +08:00
committed by GitHub
parent a0d410b46d
commit ead175234c
31 changed files with 237 additions and 53 deletions

35
examples/rtmo/README.md Normal file
View File

@ -0,0 +1,35 @@
## Quick Start
```shell
cargo run -r --example rtmo
```
## Or you can manully
### 1. Donwload 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)
### 2. Specify the ONNX model path in `main.rs`
```Rust
let options = Options::default()
.with_model("ONNX_MODEL") // <= modify this
```
### 3. Then, run
```bash
cargo run -r --example rtmo
```
## Results
![](./demo.jpg)

BIN
examples/rtmo/demo.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 242 KiB

26
examples/rtmo/main.rs Normal file
View File

@ -0,0 +1,26 @@
use usls::{models::RTMO, Annotator, DataLoader, Options, COCO_SKELETON_17};
fn main() -> Result<(), Box<dyn std::error::Error>> {
// build model
let options = Options::default()
.with_model("../rtmo-l-dyn-f16.onnx")
.with_i00((1, 2, 8).into())
.with_nk(17)
.with_confs(&[0.3])
.with_kconfs(&[0.5]);
let mut model = RTMO::new(&options)?;
// load image
let x = vec![DataLoader::try_read("./assets/bus.jpg")?];
// run
let y = model.run(&x)?;
// // annotate
let annotator = Annotator::default()
.with_saveout("RTMO")
.with_skeletons(&COCO_SKELETON_17);
annotator.annotate(&x, &y);
Ok(())
}