🐍 v0.1.0 (#53)

This commit is contained in:
Jamjamjon
2025-01-12 16:59:57 +08:00
committed by GitHub
parent 4e932c4910
commit 0f2d84b8c5
256 changed files with 12485 additions and 9088 deletions

View File

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

View File

@@ -1,27 +1,38 @@
use usls::{
models::{Sapiens, SapiensTask},
Annotator, DataLoader, Options, BODY_PARTS_28,
};
use anyhow::Result;
use usls::{models::Sapiens, Annotator, DataLoader, Options};
fn main() -> Result<(), Box<dyn std::error::Error>> {
#[derive(argh::FromArgs)]
/// Example
struct Args {
/// device
#[argh(option, default = "String::from(\"cpu:0\")")]
device: String,
}
fn main() -> 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
let options = Options::default()
.with_model("sapiens/seg-0.3b-dyn.onnx")?
.with_sapiens_task(SapiensTask::Seg)
.with_names(&BODY_PARTS_28);
let options = Options::sapiens_seg_0_3b()
.with_model_device(args.device.as_str().try_into()?)
.commit()?;
let mut model = Sapiens::new(options)?;
// load
let x = [DataLoader::try_read("images/paul-george.jpg")?];
// run
let y = model.run(&x)?;
let y = model.forward(&x)?;
// annotate
let annotator = Annotator::default()
.without_masks(true)
.with_polygons_name(false)
.with_saveout("Sapiens");
.with_polygons_name(true)
.with_saveout(model.spec());
annotator.annotate(&x, &y);
Ok(())