mirror of
https://github.com/mii443/usls.git
synced 2025-08-22 15:45:41 +00:00
Add MODNet model (#11)
* Add MODNet for portrait matting * Minor fixes * Move assets to home directory * Add colormap * ci * Update README.md
This commit is contained in:
15
examples/modnet/README.md
Normal file
15
examples/modnet/README.md
Normal file
@ -0,0 +1,15 @@
|
||||
## Quick Start
|
||||
|
||||
```shell
|
||||
cargo run -r --example modnet
|
||||
```
|
||||
|
||||
## ONNX Model
|
||||
|
||||
- [modnet-dyn](https://github.com/jamjamjon/assets/releases/download/v0.0.1/modnet-dyn.onnx)
|
||||
|
||||
|
||||
|
||||
## Results
|
||||
|
||||

|
BIN
examples/modnet/demo.png
Normal file
BIN
examples/modnet/demo.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 93 KiB |
23
examples/modnet/main.rs
Normal file
23
examples/modnet/main.rs
Normal file
@ -0,0 +1,23 @@
|
||||
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_i00((1, 1, 4).into())
|
||||
.with_i02((416, 512, 800).into())
|
||||
.with_i03((416, 512, 800).into());
|
||||
let model = MODNet::new(&options)?;
|
||||
|
||||
// load image
|
||||
let x = vec![DataLoader::try_read("./assets/portrait.jpg")?];
|
||||
|
||||
// run
|
||||
let y = model.run(&x)?;
|
||||
|
||||
// annotate
|
||||
let annotator = Annotator::default().with_saveout("MODNet");
|
||||
annotator.annotate(&x, &y);
|
||||
|
||||
Ok(())
|
||||
}
|
Reference in New Issue
Block a user