* Add docs

* Add mediapipe-selfie-segmenter model

* Update README.md

* Update RTMO model
This commit is contained in:
Jamjamjon
2025-06-08 18:15:54 +08:00
committed by GitHub
parent 0e8d4f832a
commit 70aeae9e01
77 changed files with 2325 additions and 1414 deletions

View File

@ -0,0 +1,10 @@
## Quick Start
```shell
cargo run -r --example mediapipe-selfie-segmentation -- --dtype f16
```
## Results
![](https://github.com/jamjamjon/assets/releases/download/mediapipe/demo-selfie-segmentaion.jpg)

View File

@ -0,0 +1,49 @@
use usls::{models::MediaPipeSegmenter, Annotator, Config, DataLoader};
#[derive(argh::FromArgs)]
/// Example
struct Args {
/// dtype
#[argh(option, default = "String::from(\"auto\")")]
dtype: String,
/// device
#[argh(option, default = "String::from(\"cpu:0\")")]
device: String,
}
fn main() -> anyhow::Result<()> {
tracing_subscriber::fmt()
.with_env_filter(tracing_subscriber::EnvFilter::from_default_env())
.with_timer(tracing_subscriber::fmt::time::ChronoLocal::rfc_3339())
.init();
let args: Args = argh::from_env();
// build model
let config = Config::mediapipe_selfie_segmentater()
.with_model_dtype(args.dtype.parse()?)
.with_model_device(args.device.parse()?)
.commit()?;
let mut model = MediaPipeSegmenter::new(config)?;
// load image
let xs = DataLoader::try_read_n(&["images/selfie-segmenter.png"])?;
// run
let ys = model.forward(&xs)?;
// annotate
let annotator =
Annotator::default().with_mask_style(usls::Style::mask().with_mask_cutout(true));
for (x, y) in xs.iter().zip(ys.iter()) {
annotator.annotate(x, y)?.save(format!(
"{}.jpg",
usls::Dir::Current
.base_dir_with_subs(&["runs", model.spec()])?
.join(usls::timestamp(None))
.display(),
))?;
}
Ok(())
}