mirror of
https://github.com/mii443/usls.git
synced 2025-08-22 15:45:41 +00:00
40 lines
1002 B
Rust
40 lines
1002 B
Rust
use anyhow::Result;
|
|
use usls::{models::Sapiens, Annotator, DataLoader, Options};
|
|
|
|
#[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::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.forward(&x)?;
|
|
|
|
// annotate
|
|
let annotator = Annotator::default()
|
|
.without_masks(true)
|
|
.with_polygons_name(true)
|
|
.with_saveout(model.spec());
|
|
annotator.annotate(&x, &y);
|
|
|
|
Ok(())
|
|
}
|