Options -> ModelConfig

This commit is contained in:
jamjamjon
2025-05-16 15:45:27 +08:00
parent 54045543fc
commit 70e6b2f03e
118 changed files with 1735 additions and 2503 deletions

View File

@ -1,5 +1,5 @@
use anyhow::Result;
use usls::{models::DB, Annotator, DataLoader, Options, Style};
use usls::{models::DB, Annotator, DataLoader, ModelConfig, Style};
#[derive(argh::FromArgs)]
/// Example
@ -41,15 +41,13 @@ fn main() -> Result<()> {
let args: Args = argh::from_env();
// build model
let options = match &args.model {
Some(m) => Options::db().with_model_file(m),
None => Options::ppocr_det_v4_ch().with_model_dtype(args.dtype.as_str().try_into()?),
};
let mut model = DB::new(
options
.with_model_device(args.device.as_str().try_into()?)
.commit()?,
)?;
let config = match &args.model {
Some(m) => ModelConfig::db().with_model_file(m),
None => ModelConfig::ppocr_det_v4_ch().with_model_dtype(args.dtype.as_str().try_into()?),
}
.with_device_all(args.device.as_str().try_into()?)
.commit()?;
let mut model = DB::new(config)?;
// load image
let xs = DataLoader::try_read_n(&[