mirror of
https://github.com/mii443/usls.git
synced 2025-08-22 15:45:41 +00:00
40 lines
1.1 KiB
Rust
40 lines
1.1 KiB
Rust
use anyhow::Result;
|
|
use usls::{models::RTDETR, Annotator, DataLoader, ModelConfig};
|
|
|
|
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();
|
|
|
|
// config
|
|
let config = ModelConfig::rtdetr_v2_s_coco().commit()?;
|
|
// rtdetr_v1_r18vd_coco()
|
|
// rtdetr_v2_ms_coco()
|
|
// rtdetr_v2_m_coco()
|
|
// rtdetr_v2_l_coco()
|
|
// rtdetr_v2_x_coco()
|
|
let mut model = RTDETR::new(config)?;
|
|
|
|
// load
|
|
let xs = DataLoader::try_read_n(&["./assets/bus.jpg"])?;
|
|
|
|
// run
|
|
let ys = model.forward(&xs)?;
|
|
println!("{:?}", ys);
|
|
|
|
// annotate
|
|
let annotator = Annotator::default();
|
|
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(())
|
|
}
|