Skip to content

Commit 9358afe

Browse files
author
youngday
committed
rtmo test ok
1 parent 60ee100 commit 9358afe

1 file changed

Lines changed: 38 additions & 4 deletions

File tree

examples/rtmo/main.rs

Lines changed: 38 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,51 @@
11
use anyhow::Result;
2-
use usls::{models::RTMO, Annotator, DataLoader, Options, Style, SKELETON_COCO_19};
2+
use usls::{models::RTMO, Annotator, DataLoader, Config, Style, SKELETON_COCO_19};
3+
#[derive(argh::FromArgs)]
4+
/// Example
5+
struct Args {
6+
/// model file
7+
#[argh(option)]
8+
model: Option<String>,
39

10+
/// source
11+
#[argh(option, default = "String::from(\"./assets/bus.jpg\")")]
12+
source: String,
13+
/// dtype
14+
#[argh(option, default = "String::from(\"fp16\")")]
15+
dtype: String,
16+
17+
/// device
18+
#[argh(option, default = "String::from(\"cpu:0\")")]
19+
device: String,
20+
21+
/// scale: t, s, m, l
22+
#[argh(option, default = "String::from(\"t\")")]
23+
scale: String,
24+
}
425
fn main() -> Result<()> {
526
tracing_subscriber::fmt()
627
.with_env_filter(tracing_subscriber::EnvFilter::from_default_env())
728
.with_timer(tracing_subscriber::fmt::time::ChronoLocal::rfc_3339())
829
.init();
9-
30+
let args: Args = argh::from_env();
31+
// build model
32+
let config = match args.scale.as_str() {
33+
"t" => Config::rtmo_t(),
34+
"s" => Config::rtmo_s(),
35+
"m" => Config::rtmo_m(),
36+
"l" => Config::rtmo_l(),
37+
_ => unreachable!(),
38+
}
39+
.with_model_file(&args.model.unwrap_or_default())
40+
.with_model_dtype(args.dtype.parse()?)
41+
.with_model_device(args.device.parse()?)
42+
.commit()?;
1043
// build model
11-
let mut model = RTMO::new(Options::rtmo_s().commit()?)?;
44+
let mut model = RTMO::new(config)?;
1245

1346
// load image
14-
let xs = DataLoader::try_read_n(&["./assets/bus.jpg"])?;
47+
48+
let xs = DataLoader::try_read_n(&[&args.source])?;
1549

1650
// run
1751
let ys = model.forward(&xs)?;

0 commit comments

Comments
 (0)