mirror of
https://github.com/mii443/usls.git
synced 2025-08-22 15:45:41 +00:00
update
This commit is contained in:
@ -1,4 +1,4 @@
|
|||||||
use usls::{models::RMBG, Annotator, DataLoader, ModelConfig};
|
use usls::{models::RMBG, Annotator, Config, DataLoader};
|
||||||
|
|
||||||
#[derive(argh::FromArgs)]
|
#[derive(argh::FromArgs)]
|
||||||
/// Example
|
/// Example
|
||||||
@ -20,7 +20,7 @@ fn main() -> anyhow::Result<()> {
|
|||||||
let args: Args = argh::from_env();
|
let args: Args = argh::from_env();
|
||||||
|
|
||||||
// build model
|
// build model
|
||||||
let config = ModelConfig::ben2_base()
|
let config = Config::ben2_base()
|
||||||
.with_model_dtype(args.dtype.as_str().try_into()?)
|
.with_model_dtype(args.dtype.as_str().try_into()?)
|
||||||
.with_model_device(args.device.as_str().try_into()?)
|
.with_model_device(args.device.as_str().try_into()?)
|
||||||
.commit()?;
|
.commit()?;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
use usls::{models::Blip, DataLoader, ModelConfig};
|
use usls::{models::Blip, Config, DataLoader};
|
||||||
|
|
||||||
#[derive(argh::FromArgs)]
|
#[derive(argh::FromArgs)]
|
||||||
/// BLIP Example
|
/// BLIP Example
|
||||||
@ -20,7 +20,7 @@ fn main() -> anyhow::Result<()> {
|
|||||||
let args: Args = argh::from_env();
|
let args: Args = argh::from_env();
|
||||||
|
|
||||||
// build model
|
// build model
|
||||||
let config = ModelConfig::blip_v1_base_caption()
|
let config = Config::blip_v1_base_caption()
|
||||||
.with_device_all(args.device.as_str().try_into()?)
|
.with_device_all(args.device.as_str().try_into()?)
|
||||||
.commit()?;
|
.commit()?;
|
||||||
let mut model = Blip::new(config)?;
|
let mut model = Blip::new(config)?;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
use usls::{models::ImageClassifier, Annotator, DataLoader, ModelConfig};
|
use usls::{models::ImageClassifier, Annotator, Config, DataLoader};
|
||||||
|
|
||||||
#[derive(argh::FromArgs)]
|
#[derive(argh::FromArgs)]
|
||||||
/// Example
|
/// Example
|
||||||
@ -37,11 +37,11 @@ fn main() -> anyhow::Result<()> {
|
|||||||
|
|
||||||
// build model
|
// build model
|
||||||
let config = match args.model.to_lowercase().as_str() {
|
let config = match args.model.to_lowercase().as_str() {
|
||||||
"beit" => ModelConfig::beit_base(),
|
"beit" => Config::beit_base(),
|
||||||
"convnext" => ModelConfig::convnext_v2_atto(),
|
"convnext" => Config::convnext_v2_atto(),
|
||||||
"deit" => ModelConfig::deit_tiny_distill(),
|
"deit" => Config::deit_tiny_distill(),
|
||||||
"fastvit" => ModelConfig::fastvit_t8_distill(),
|
"fastvit" => Config::fastvit_t8_distill(),
|
||||||
"mobileone" => ModelConfig::mobileone_s0(),
|
"mobileone" => Config::mobileone_s0(),
|
||||||
_ => anyhow::bail!("Unsupported model: {}", args.model),
|
_ => anyhow::bail!("Unsupported model: {}", args.model),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use usls::{models::Clip, DataLoader, ModelConfig, Ops};
|
use usls::{models::Clip, Config, DataLoader, Ops};
|
||||||
|
|
||||||
#[derive(argh::FromArgs)]
|
#[derive(argh::FromArgs)]
|
||||||
/// CLIP Example
|
/// CLIP Example
|
||||||
@ -17,7 +17,7 @@ fn main() -> Result<()> {
|
|||||||
let args: Args = argh::from_env();
|
let args: Args = argh::from_env();
|
||||||
|
|
||||||
// build model
|
// build model
|
||||||
let config = ModelConfig::jina_clip_v1()
|
let config = Config::jina_clip_v1()
|
||||||
.with_device_all(args.device.as_str().try_into()?)
|
.with_device_all(args.device.as_str().try_into()?)
|
||||||
.commit()?;
|
.commit()?;
|
||||||
let mut model = Clip::new(config)?;
|
let mut model = Clip::new(config)?;
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use usls::{models::RTDETR, Annotator, DataLoader, ModelConfig};
|
use usls::{models::RTDETR, Annotator, Config, DataLoader};
|
||||||
|
|
||||||
fn main() -> Result<()> {
|
fn main() -> Result<()> {
|
||||||
tracing_subscriber::fmt()
|
tracing_subscriber::fmt()
|
||||||
@ -8,7 +8,7 @@ fn main() -> Result<()> {
|
|||||||
.init();
|
.init();
|
||||||
|
|
||||||
// config
|
// config
|
||||||
let mut model = RTDETR::new(ModelConfig::d_fine_n_coco().commit()?)?;
|
let mut model = RTDETR::new(Config::d_fine_n_coco().commit()?)?;
|
||||||
|
|
||||||
// load
|
// load
|
||||||
let xs = DataLoader::try_read_n(&["./assets/bus.jpg"])?;
|
let xs = DataLoader::try_read_n(&["./assets/bus.jpg"])?;
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use usls::{models::DB, Annotator, DataLoader, ModelConfig, Style};
|
use usls::{models::DB, Annotator, Config, DataLoader, Style};
|
||||||
|
|
||||||
#[derive(argh::FromArgs)]
|
#[derive(argh::FromArgs)]
|
||||||
/// Example
|
/// Example
|
||||||
@ -42,8 +42,8 @@ fn main() -> Result<()> {
|
|||||||
|
|
||||||
// build model
|
// build model
|
||||||
let config = match &args.model {
|
let config = match &args.model {
|
||||||
Some(m) => ModelConfig::db().with_model_file(m),
|
Some(m) => Config::db().with_model_file(m),
|
||||||
None => ModelConfig::ppocr_det_v4_ch().with_model_dtype(args.dtype.as_str().try_into()?),
|
None => Config::ppocr_det_v4_ch().with_model_dtype(args.dtype.as_str().try_into()?),
|
||||||
}
|
}
|
||||||
.with_device_all(args.device.as_str().try_into()?)
|
.with_device_all(args.device.as_str().try_into()?)
|
||||||
.commit()?;
|
.commit()?;
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use usls::{models::RTDETR, Annotator, DataLoader, ModelConfig};
|
use usls::{models::RTDETR, Annotator, Config, DataLoader};
|
||||||
|
|
||||||
fn main() -> Result<()> {
|
fn main() -> Result<()> {
|
||||||
tracing_subscriber::fmt()
|
tracing_subscriber::fmt()
|
||||||
@ -8,7 +8,7 @@ fn main() -> Result<()> {
|
|||||||
.init();
|
.init();
|
||||||
|
|
||||||
// config
|
// config
|
||||||
let mut model = RTDETR::new(ModelConfig::deim_dfine_s_coco().commit()?)?;
|
let mut model = RTDETR::new(Config::deim_dfine_s_coco().commit()?)?;
|
||||||
|
|
||||||
// load
|
// load
|
||||||
let xs = DataLoader::try_read_n(&["./assets/bus.jpg"])?;
|
let xs = DataLoader::try_read_n(&["./assets/bus.jpg"])?;
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use usls::{models::DepthAnything, Annotator, DataLoader, ModelConfig, Style};
|
use usls::{models::DepthAnything, Annotator, Config, DataLoader, Style};
|
||||||
|
|
||||||
fn main() -> Result<()> {
|
fn main() -> Result<()> {
|
||||||
tracing_subscriber::fmt()
|
tracing_subscriber::fmt()
|
||||||
@ -8,7 +8,7 @@ fn main() -> Result<()> {
|
|||||||
.init();
|
.init();
|
||||||
|
|
||||||
// build model
|
// build model
|
||||||
let mut model = DepthAnything::new(ModelConfig::depth_anything_v2_small().commit()?)?;
|
let mut model = DepthAnything::new(Config::depth_anything_v2_small().commit()?)?;
|
||||||
|
|
||||||
// load
|
// load
|
||||||
let xs = DataLoader::try_read_n(&["images/street.jpg"])?;
|
let xs = DataLoader::try_read_n(&["images/street.jpg"])?;
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use usls::DataLoader;
|
use usls::DataLoader;
|
||||||
use usls::{models::DepthPro, Annotator, ModelConfig, Style};
|
use usls::{models::DepthPro, Annotator, Config, Style};
|
||||||
|
|
||||||
#[derive(argh::FromArgs)]
|
#[derive(argh::FromArgs)]
|
||||||
/// Example
|
/// Example
|
||||||
@ -23,7 +23,7 @@ fn main() -> Result<()> {
|
|||||||
let args: Args = argh::from_env();
|
let args: Args = argh::from_env();
|
||||||
|
|
||||||
// model
|
// model
|
||||||
let config = ModelConfig::depth_pro()
|
let config = Config::depth_pro()
|
||||||
.with_model_dtype(args.dtype.as_str().try_into()?)
|
.with_model_dtype(args.dtype.as_str().try_into()?)
|
||||||
.with_model_device(args.device.as_str().try_into()?)
|
.with_model_device(args.device.as_str().try_into()?)
|
||||||
.commit()?;
|
.commit()?;
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use usls::{models::DINOv2, DataLoader, ModelConfig};
|
use usls::{models::DINOv2, Config, DataLoader};
|
||||||
|
|
||||||
fn main() -> Result<()> {
|
fn main() -> Result<()> {
|
||||||
tracing_subscriber::fmt()
|
tracing_subscriber::fmt()
|
||||||
@ -11,7 +11,7 @@ fn main() -> Result<()> {
|
|||||||
let xs = DataLoader::try_read_n(&["./assets/bus.jpg", "./assets/bus.jpg"])?;
|
let xs = DataLoader::try_read_n(&["./assets/bus.jpg", "./assets/bus.jpg"])?;
|
||||||
|
|
||||||
// model
|
// model
|
||||||
let config = ModelConfig::dinov2_small()
|
let config = Config::dinov2_small()
|
||||||
.with_batch_size_all(xs.len())
|
.with_batch_size_all(xs.len())
|
||||||
.commit()?;
|
.commit()?;
|
||||||
let mut model = DINOv2::new(config)?;
|
let mut model = DINOv2::new(config)?;
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use usls::{models::YOLO, Annotator, DataLoader, ModelConfig};
|
use usls::{models::YOLO, Annotator, Config, DataLoader};
|
||||||
|
|
||||||
#[derive(argh::FromArgs)]
|
#[derive(argh::FromArgs)]
|
||||||
/// Example
|
/// Example
|
||||||
@ -18,7 +18,7 @@ fn main() -> Result<()> {
|
|||||||
let args: Args = argh::from_env();
|
let args: Args = argh::from_env();
|
||||||
|
|
||||||
// build model
|
// build model
|
||||||
let config = ModelConfig::doclayout_yolo_docstructbench()
|
let config = Config::doclayout_yolo_docstructbench()
|
||||||
.with_model_device(args.device.as_str().try_into()?)
|
.with_model_device(args.device.as_str().try_into()?)
|
||||||
.commit()?;
|
.commit()?;
|
||||||
let mut model = YOLO::new(config)?;
|
let mut model = YOLO::new(config)?;
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use usls::{models::DB, Annotator, DataLoader, ModelConfig, Scale, Style};
|
use usls::{models::DB, Annotator, Config, DataLoader, Scale, Style};
|
||||||
|
|
||||||
#[derive(argh::FromArgs)]
|
#[derive(argh::FromArgs)]
|
||||||
/// Example
|
/// Example
|
||||||
@ -27,9 +27,9 @@ fn main() -> Result<()> {
|
|||||||
|
|
||||||
// build model
|
// build model
|
||||||
let config = match args.scale.as_str().try_into()? {
|
let config = match args.scale.as_str().try_into()? {
|
||||||
Scale::T => ModelConfig::fast_tiny(),
|
Scale::T => Config::fast_tiny(),
|
||||||
Scale::S => ModelConfig::fast_small(),
|
Scale::S => Config::fast_small(),
|
||||||
Scale::B => ModelConfig::fast_base(),
|
Scale::B => Config::fast_base(),
|
||||||
_ => unimplemented!("Unsupported model scale: {:?}. Try b, s, t.", args.scale),
|
_ => unimplemented!("Unsupported model scale: {:?}. Try b, s, t.", args.scale),
|
||||||
};
|
};
|
||||||
let mut model = DB::new(
|
let mut model = DB::new(
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use usls::{models::YOLO, Annotator, DataLoader, ModelConfig};
|
use usls::{models::YOLO, Annotator, Config, DataLoader};
|
||||||
|
|
||||||
#[derive(argh::FromArgs)]
|
#[derive(argh::FromArgs)]
|
||||||
/// Example
|
/// Example
|
||||||
@ -22,7 +22,7 @@ fn main() -> Result<()> {
|
|||||||
let args: Args = argh::from_env();
|
let args: Args = argh::from_env();
|
||||||
|
|
||||||
// build model
|
// build model
|
||||||
let config = ModelConfig::fastsam_s()
|
let config = Config::fastsam_s()
|
||||||
.with_model_dtype(args.dtype.as_str().try_into()?)
|
.with_model_dtype(args.dtype.as_str().try_into()?)
|
||||||
.with_model_device(args.device.as_str().try_into()?)
|
.with_model_device(args.device.as_str().try_into()?)
|
||||||
.commit()?;
|
.commit()?;
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use usls::{models::Florence2, Annotator, DataLoader, ModelConfig, Style, Task};
|
use usls::{models::Florence2, Annotator, Config, DataLoader, Style, Task};
|
||||||
|
|
||||||
#[derive(argh::FromArgs)]
|
#[derive(argh::FromArgs)]
|
||||||
/// Example
|
/// Example
|
||||||
@ -25,7 +25,7 @@ fn main() -> Result<()> {
|
|||||||
let xs = DataLoader::try_read_n(&["images/green-car.jpg", "assets/bus.jpg"])?;
|
let xs = DataLoader::try_read_n(&["images/green-car.jpg", "assets/bus.jpg"])?;
|
||||||
|
|
||||||
// build model
|
// build model
|
||||||
let config = ModelConfig::florence2_base()
|
let config = Config::florence2_base()
|
||||||
.with_dtype_all(args.dtype.as_str().try_into()?)
|
.with_dtype_all(args.dtype.as_str().try_into()?)
|
||||||
.with_device_all(args.device.as_str().try_into()?)
|
.with_device_all(args.device.as_str().try_into()?)
|
||||||
.with_batch_size_all(xs.len())
|
.with_batch_size_all(xs.len())
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use usls::{models::GroundingDINO, Annotator, DataLoader, ModelConfig};
|
use usls::{models::GroundingDINO, Annotator, Config, DataLoader};
|
||||||
|
|
||||||
#[derive(argh::FromArgs)]
|
#[derive(argh::FromArgs)]
|
||||||
/// Example
|
/// Example
|
||||||
@ -45,7 +45,7 @@ fn main() -> Result<()> {
|
|||||||
|
|
||||||
let args: Args = argh::from_env();
|
let args: Args = argh::from_env();
|
||||||
|
|
||||||
let config = ModelConfig::grounding_dino_tiny()
|
let config = Config::grounding_dino_tiny()
|
||||||
.with_model_dtype(args.dtype.as_str().try_into()?)
|
.with_model_dtype(args.dtype.as_str().try_into()?)
|
||||||
.with_model_device(args.device.as_str().try_into()?)
|
.with_model_device(args.device.as_str().try_into()?)
|
||||||
.with_text_names(&args.labels.iter().map(|x| x.as_str()).collect::<Vec<_>>())
|
.with_text_names(&args.labels.iter().map(|x| x.as_str()).collect::<Vec<_>>())
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use usls::DataLoader;
|
use usls::DataLoader;
|
||||||
use usls::{models::DB, Annotator, ModelConfig, Scale, Style};
|
use usls::{models::DB, Annotator, Config, Scale, Style};
|
||||||
|
|
||||||
#[derive(argh::FromArgs)]
|
#[derive(argh::FromArgs)]
|
||||||
/// Example
|
/// Example
|
||||||
@ -28,9 +28,9 @@ fn main() -> Result<()> {
|
|||||||
|
|
||||||
// build model
|
// build model
|
||||||
let config = match args.scale.as_str().try_into()? {
|
let config = match args.scale.as_str().try_into()? {
|
||||||
Scale::T => ModelConfig::linknet_r18(),
|
Scale::T => Config::linknet_r18(),
|
||||||
Scale::S => ModelConfig::linknet_r34(),
|
Scale::S => Config::linknet_r34(),
|
||||||
Scale::B => ModelConfig::linknet_r50(),
|
Scale::B => Config::linknet_r50(),
|
||||||
_ => unimplemented!("Unsupported model scale: {:?}. Try b, s, t.", args.scale),
|
_ => unimplemented!("Unsupported model scale: {:?}. Try b, s, t.", args.scale),
|
||||||
};
|
};
|
||||||
let mut model = DB::new(
|
let mut model = DB::new(
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
use usls::{models::MODNet, Annotator, DataLoader, ModelConfig};
|
use usls::{models::MODNet, Annotator, Config, DataLoader};
|
||||||
|
|
||||||
fn main() -> anyhow::Result<()> {
|
fn main() -> anyhow::Result<()> {
|
||||||
tracing_subscriber::fmt()
|
tracing_subscriber::fmt()
|
||||||
@ -7,7 +7,7 @@ fn main() -> anyhow::Result<()> {
|
|||||||
.init();
|
.init();
|
||||||
|
|
||||||
// build model
|
// build model
|
||||||
let mut model = MODNet::new(ModelConfig::modnet_photographic().commit()?)?;
|
let mut model = MODNet::new(Config::modnet_photographic().commit()?)?;
|
||||||
|
|
||||||
// load image
|
// load image
|
||||||
let xs = DataLoader::try_read_n(&["images/liuyifei.png"])?;
|
let xs = DataLoader::try_read_n(&["images/liuyifei.png"])?;
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use usls::{models::Moondream2, Annotator, DataLoader, ModelConfig, Scale, Task};
|
use usls::{models::Moondream2, Annotator, Config, DataLoader, Scale, Task};
|
||||||
|
|
||||||
#[derive(argh::FromArgs)]
|
#[derive(argh::FromArgs)]
|
||||||
/// Example
|
/// Example
|
||||||
@ -40,8 +40,8 @@ fn main() -> Result<()> {
|
|||||||
|
|
||||||
// build model
|
// build model
|
||||||
let config = match args.scale.as_str().try_into()? {
|
let config = match args.scale.as_str().try_into()? {
|
||||||
Scale::Billion(0.5) => ModelConfig::moondream2_0_5b(),
|
Scale::Billion(0.5) => Config::moondream2_0_5b(),
|
||||||
Scale::Billion(2.) => ModelConfig::moondream2_2b(),
|
Scale::Billion(2.) => Config::moondream2_2b(),
|
||||||
_ => unimplemented!(),
|
_ => unimplemented!(),
|
||||||
}
|
}
|
||||||
.with_dtype_all(args.dtype.as_str().try_into()?)
|
.with_dtype_all(args.dtype.as_str().try_into()?)
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use usls::DataLoader;
|
use usls::DataLoader;
|
||||||
use usls::{models::OWLv2, Annotator, ModelConfig};
|
use usls::{models::OWLv2, Annotator, Config};
|
||||||
|
|
||||||
#[derive(argh::FromArgs)]
|
#[derive(argh::FromArgs)]
|
||||||
/// Example
|
/// Example
|
||||||
@ -47,7 +47,7 @@ fn main() -> Result<()> {
|
|||||||
let args: Args = argh::from_env();
|
let args: Args = argh::from_env();
|
||||||
|
|
||||||
// config
|
// config
|
||||||
let config = ModelConfig::owlv2_base_ensemble()
|
let config = Config::owlv2_base_ensemble()
|
||||||
// owlv2_base()
|
// owlv2_base()
|
||||||
.with_model_dtype(args.dtype.as_str().try_into()?)
|
.with_model_dtype(args.dtype.as_str().try_into()?)
|
||||||
.with_model_device(args.device.as_str().try_into()?)
|
.with_model_device(args.device.as_str().try_into()?)
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use usls::DataLoader;
|
use usls::DataLoader;
|
||||||
use usls::{models::PicoDet, Annotator, ModelConfig};
|
use usls::{models::PicoDet, Annotator, Config};
|
||||||
|
|
||||||
fn main() -> Result<()> {
|
fn main() -> Result<()> {
|
||||||
tracing_subscriber::fmt()
|
tracing_subscriber::fmt()
|
||||||
@ -9,7 +9,7 @@ fn main() -> Result<()> {
|
|||||||
.init();
|
.init();
|
||||||
|
|
||||||
// config
|
// config
|
||||||
let config = ModelConfig::picodet_layout_1x().commit()?;
|
let config = Config::picodet_layout_1x().commit()?;
|
||||||
// picodet_l_layout_3cls()
|
// picodet_l_layout_3cls()
|
||||||
// picodet_l_layout_17cls()
|
// picodet_l_layout_17cls()
|
||||||
let mut model = PicoDet::new(config)?;
|
let mut model = PicoDet::new(config)?;
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use usls::{models::RFDETR, Annotator, DataLoader, ModelConfig};
|
use usls::{models::RFDETR, Annotator, Config, DataLoader};
|
||||||
|
|
||||||
fn main() -> Result<()> {
|
fn main() -> Result<()> {
|
||||||
tracing_subscriber::fmt()
|
tracing_subscriber::fmt()
|
||||||
@ -8,7 +8,7 @@ fn main() -> Result<()> {
|
|||||||
.init();
|
.init();
|
||||||
|
|
||||||
// config
|
// config
|
||||||
let mut model = RFDETR::new(ModelConfig::rfdetr_base().commit()?)?;
|
let mut model = RFDETR::new(Config::rfdetr_base().commit()?)?;
|
||||||
|
|
||||||
// load
|
// load
|
||||||
let xs = DataLoader::try_read_n(&["./assets/bus.jpg"])?;
|
let xs = DataLoader::try_read_n(&["./assets/bus.jpg"])?;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
use usls::{models::RMBG, Annotator, DataLoader, ModelConfig};
|
use usls::{models::RMBG, Annotator, Config, DataLoader};
|
||||||
|
|
||||||
#[derive(argh::FromArgs)]
|
#[derive(argh::FromArgs)]
|
||||||
/// Example
|
/// Example
|
||||||
@ -24,8 +24,8 @@ fn main() -> anyhow::Result<()> {
|
|||||||
let args: Args = argh::from_env();
|
let args: Args = argh::from_env();
|
||||||
|
|
||||||
let config = match args.ver {
|
let config = match args.ver {
|
||||||
1.4 => ModelConfig::rmbg1_4(),
|
1.4 => Config::rmbg1_4(),
|
||||||
2.0 => ModelConfig::rmbg2_0(),
|
2.0 => Config::rmbg2_0(),
|
||||||
_ => unreachable!("Unsupported version"),
|
_ => unreachable!("Unsupported version"),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use usls::{models::RTDETR, Annotator, DataLoader, ModelConfig};
|
use usls::{models::RTDETR, Annotator, Config, DataLoader};
|
||||||
|
|
||||||
fn main() -> Result<()> {
|
fn main() -> Result<()> {
|
||||||
tracing_subscriber::fmt()
|
tracing_subscriber::fmt()
|
||||||
@ -8,7 +8,7 @@ fn main() -> Result<()> {
|
|||||||
.init();
|
.init();
|
||||||
|
|
||||||
// config
|
// config
|
||||||
let config = ModelConfig::rtdetr_v2_s_coco().commit()?;
|
let config = Config::rtdetr_v2_s_coco().commit()?;
|
||||||
// rtdetr_v1_r18vd_coco()
|
// rtdetr_v1_r18vd_coco()
|
||||||
// rtdetr_v2_ms_coco()
|
// rtdetr_v2_ms_coco()
|
||||||
// rtdetr_v2_m_coco()
|
// rtdetr_v2_m_coco()
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use usls::{models::RTMO, Annotator, DataLoader, ModelConfig, Style, SKELETON_COCO_19};
|
use usls::{models::RTMO, Annotator, Config, DataLoader, Style, SKELETON_COCO_19};
|
||||||
|
|
||||||
fn main() -> Result<()> {
|
fn main() -> Result<()> {
|
||||||
tracing_subscriber::fmt()
|
tracing_subscriber::fmt()
|
||||||
@ -8,7 +8,7 @@ fn main() -> Result<()> {
|
|||||||
.init();
|
.init();
|
||||||
|
|
||||||
// build model
|
// build model
|
||||||
let mut model = RTMO::new(ModelConfig::rtmo_s().commit()?)?;
|
let mut model = RTMO::new(Config::rtmo_s().commit()?)?;
|
||||||
|
|
||||||
// load image
|
// load image
|
||||||
let xs = DataLoader::try_read_n(&["./assets/bus.jpg"])?;
|
let xs = DataLoader::try_read_n(&["./assets/bus.jpg"])?;
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use usls::{
|
use usls::{
|
||||||
models::{SamKind, SamPrompt, SAM},
|
models::{SamKind, SamPrompt, SAM},
|
||||||
Annotator, DataLoader, ModelConfig, Scale,
|
Annotator, Config, DataLoader, Scale,
|
||||||
};
|
};
|
||||||
|
|
||||||
#[derive(argh::FromArgs)]
|
#[derive(argh::FromArgs)]
|
||||||
@ -29,16 +29,16 @@ fn main() -> Result<()> {
|
|||||||
let args: Args = argh::from_env();
|
let args: Args = argh::from_env();
|
||||||
// Build model
|
// Build model
|
||||||
let config = match args.kind.as_str().try_into()? {
|
let config = match args.kind.as_str().try_into()? {
|
||||||
SamKind::Sam => ModelConfig::sam_v1_base(),
|
SamKind::Sam => Config::sam_v1_base(),
|
||||||
SamKind::Sam2 => match args.scale.as_str().try_into()? {
|
SamKind::Sam2 => match args.scale.as_str().try_into()? {
|
||||||
Scale::T => ModelConfig::sam2_tiny(),
|
Scale::T => Config::sam2_tiny(),
|
||||||
Scale::S => ModelConfig::sam2_small(),
|
Scale::S => Config::sam2_small(),
|
||||||
Scale::B => ModelConfig::sam2_base_plus(),
|
Scale::B => Config::sam2_base_plus(),
|
||||||
_ => unimplemented!("Unsupported model scale: {:?}. Try b, s, t.", args.scale),
|
_ => unimplemented!("Unsupported model scale: {:?}. Try b, s, t.", args.scale),
|
||||||
},
|
},
|
||||||
SamKind::MobileSam => ModelConfig::mobile_sam_tiny(),
|
SamKind::MobileSam => Config::mobile_sam_tiny(),
|
||||||
SamKind::SamHq => ModelConfig::sam_hq_tiny(),
|
SamKind::SamHq => Config::sam_hq_tiny(),
|
||||||
SamKind::EdgeSam => ModelConfig::edge_sam_3x(),
|
SamKind::EdgeSam => Config::edge_sam_3x(),
|
||||||
}
|
}
|
||||||
.with_device_all(args.device.as_str().try_into()?)
|
.with_device_all(args.device.as_str().try_into()?)
|
||||||
.commit()?;
|
.commit()?;
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use usls::{
|
use usls::{
|
||||||
models::{SamPrompt, SAM2},
|
models::{SamPrompt, SAM2},
|
||||||
Annotator, DataLoader, ModelConfig, Scale,
|
Annotator, Config, DataLoader, Scale,
|
||||||
};
|
};
|
||||||
|
|
||||||
#[derive(argh::FromArgs)]
|
#[derive(argh::FromArgs)]
|
||||||
@ -26,10 +26,10 @@ fn main() -> Result<()> {
|
|||||||
|
|
||||||
// Build model
|
// Build model
|
||||||
let config = match args.scale.as_str().try_into()? {
|
let config = match args.scale.as_str().try_into()? {
|
||||||
Scale::T => ModelConfig::sam2_1_tiny(),
|
Scale::T => Config::sam2_1_tiny(),
|
||||||
Scale::S => ModelConfig::sam2_1_small(),
|
Scale::S => Config::sam2_1_small(),
|
||||||
Scale::B => ModelConfig::sam2_1_base_plus(),
|
Scale::B => Config::sam2_1_base_plus(),
|
||||||
Scale::L => ModelConfig::sam2_1_large(),
|
Scale::L => Config::sam2_1_large(),
|
||||||
_ => unimplemented!("Unsupported model scale: {:?}. Try b, s, t, l.", args.scale),
|
_ => unimplemented!("Unsupported model scale: {:?}. Try b, s, t, l.", args.scale),
|
||||||
}
|
}
|
||||||
.with_device_all(args.device.as_str().try_into()?)
|
.with_device_all(args.device.as_str().try_into()?)
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use usls::{models::Sapiens, Annotator, DataLoader, ModelConfig};
|
use usls::{models::Sapiens, Annotator, Config, DataLoader};
|
||||||
|
|
||||||
#[derive(argh::FromArgs)]
|
#[derive(argh::FromArgs)]
|
||||||
/// Example
|
/// Example
|
||||||
@ -17,7 +17,7 @@ fn main() -> Result<()> {
|
|||||||
|
|
||||||
let args: Args = argh::from_env();
|
let args: Args = argh::from_env();
|
||||||
// build
|
// build
|
||||||
let config = ModelConfig::sapiens_seg_0_3b()
|
let config = Config::sapiens_seg_0_3b()
|
||||||
.with_model_device(args.device.as_str().try_into()?)
|
.with_model_device(args.device.as_str().try_into()?)
|
||||||
.commit()?;
|
.commit()?;
|
||||||
let mut model = Sapiens::new(config)?;
|
let mut model = Sapiens::new(config)?;
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use usls::{models::SLANet, Annotator, Color, DataLoader, ModelConfig};
|
use usls::{models::SLANet, Annotator, Color, Config, DataLoader};
|
||||||
|
|
||||||
#[derive(argh::FromArgs)]
|
#[derive(argh::FromArgs)]
|
||||||
/// Example
|
/// Example
|
||||||
@ -26,7 +26,7 @@ fn main() -> Result<()> {
|
|||||||
let args: Args = argh::from_env();
|
let args: Args = argh::from_env();
|
||||||
|
|
||||||
// build model
|
// build model
|
||||||
let config = ModelConfig::slanet_lcnet_v2_mobile_ch()
|
let config = Config::slanet_lcnet_v2_mobile_ch()
|
||||||
.with_model_device(args.device.as_str().try_into()?)
|
.with_model_device(args.device.as_str().try_into()?)
|
||||||
.with_model_dtype(args.dtype.as_str().try_into()?)
|
.with_model_dtype(args.dtype.as_str().try_into()?)
|
||||||
.commit()?;
|
.commit()?;
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use usls::{models::SmolVLM, DataLoader, ModelConfig, Scale};
|
use usls::{models::SmolVLM, Config, DataLoader, Scale};
|
||||||
|
|
||||||
#[derive(argh::FromArgs)]
|
#[derive(argh::FromArgs)]
|
||||||
/// Example
|
/// Example
|
||||||
@ -30,8 +30,8 @@ fn main() -> Result<()> {
|
|||||||
|
|
||||||
// build model
|
// build model
|
||||||
let config = match args.scale.as_str().try_into()? {
|
let config = match args.scale.as_str().try_into()? {
|
||||||
Scale::Million(256.) => ModelConfig::smolvlm_256m(),
|
Scale::Million(256.) => Config::smolvlm_256m(),
|
||||||
Scale::Million(500.) => ModelConfig::smolvlm_500m(),
|
Scale::Million(500.) => Config::smolvlm_500m(),
|
||||||
_ => unimplemented!(),
|
_ => unimplemented!(),
|
||||||
}
|
}
|
||||||
.with_device_all(args.device.as_str().try_into()?)
|
.with_device_all(args.device.as_str().try_into()?)
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use usls::{models::SVTR, DataLoader, ModelConfig};
|
use usls::{models::SVTR, Config, DataLoader};
|
||||||
|
|
||||||
#[derive(argh::FromArgs)]
|
#[derive(argh::FromArgs)]
|
||||||
/// Example
|
/// Example
|
||||||
@ -22,7 +22,7 @@ fn main() -> Result<()> {
|
|||||||
let args: Args = argh::from_env();
|
let args: Args = argh::from_env();
|
||||||
|
|
||||||
// build model
|
// build model
|
||||||
let config = ModelConfig::ppocr_rec_v4_ch()
|
let config = Config::ppocr_rec_v4_ch()
|
||||||
// ppocr_rec_v4_en()
|
// ppocr_rec_v4_en()
|
||||||
// repsvtr_ch()
|
// repsvtr_ch()
|
||||||
.with_model_device(args.device.as_str().try_into()?)
|
.with_model_device(args.device.as_str().try_into()?)
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
use usls::{
|
use usls::{
|
||||||
models::{TrOCR, TrOCRKind},
|
models::{TrOCR, TrOCRKind},
|
||||||
DataLoader, ModelConfig, Scale,
|
Config, DataLoader, Scale,
|
||||||
};
|
};
|
||||||
|
|
||||||
#[derive(argh::FromArgs)]
|
#[derive(argh::FromArgs)]
|
||||||
@ -40,12 +40,12 @@ fn main() -> anyhow::Result<()> {
|
|||||||
// build model
|
// build model
|
||||||
let config = match args.scale.as_str().try_into()? {
|
let config = match args.scale.as_str().try_into()? {
|
||||||
Scale::S => match args.kind.as_str().try_into()? {
|
Scale::S => match args.kind.as_str().try_into()? {
|
||||||
TrOCRKind::Printed => ModelConfig::trocr_small_printed(),
|
TrOCRKind::Printed => Config::trocr_small_printed(),
|
||||||
TrOCRKind::HandWritten => ModelConfig::trocr_small_handwritten(),
|
TrOCRKind::HandWritten => Config::trocr_small_handwritten(),
|
||||||
},
|
},
|
||||||
Scale::B => match args.kind.as_str().try_into()? {
|
Scale::B => match args.kind.as_str().try_into()? {
|
||||||
TrOCRKind::Printed => ModelConfig::trocr_base_printed(),
|
TrOCRKind::Printed => Config::trocr_base_printed(),
|
||||||
TrOCRKind::HandWritten => ModelConfig::trocr_base_handwritten(),
|
TrOCRKind::HandWritten => Config::trocr_base_handwritten(),
|
||||||
},
|
},
|
||||||
x => anyhow::bail!("Unsupported TrOCR scale: {:?}", x),
|
x => anyhow::bail!("Unsupported TrOCR scale: {:?}", x),
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use usls::{models::YOLO, Annotator, DataLoader, ModelConfig};
|
use usls::{models::YOLO, Annotator, Config, DataLoader};
|
||||||
|
|
||||||
#[derive(argh::FromArgs)]
|
#[derive(argh::FromArgs)]
|
||||||
/// Example
|
/// Example
|
||||||
@ -22,7 +22,7 @@ fn main() -> Result<()> {
|
|||||||
let args: Args = argh::from_env();
|
let args: Args = argh::from_env();
|
||||||
|
|
||||||
// build model
|
// build model
|
||||||
let config = ModelConfig::ultralytics_rtdetr_l()
|
let config = Config::ultralytics_rtdetr_l()
|
||||||
.with_model_dtype(args.dtype.as_str().try_into()?)
|
.with_model_dtype(args.dtype.as_str().try_into()?)
|
||||||
.with_model_device(args.device.as_str().try_into()?)
|
.with_model_device(args.device.as_str().try_into()?)
|
||||||
.commit()?;
|
.commit()?;
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use usls::{
|
use usls::{
|
||||||
models::{SamPrompt, SAM2, YOLO},
|
models::{SamPrompt, SAM2, YOLO},
|
||||||
Annotator, DataLoader, ModelConfig, Scale, Style,
|
Annotator, Config, DataLoader, Scale, Style,
|
||||||
};
|
};
|
||||||
|
|
||||||
#[derive(argh::FromArgs)]
|
#[derive(argh::FromArgs)]
|
||||||
@ -21,10 +21,10 @@ fn main() -> Result<()> {
|
|||||||
let args: Args = argh::from_env();
|
let args: Args = argh::from_env();
|
||||||
|
|
||||||
// build SAM
|
// build SAM
|
||||||
let mut sam = SAM2::new(ModelConfig::sam2_1_tiny().commit()?)?;
|
let mut sam = SAM2::new(Config::sam2_1_tiny().commit()?)?;
|
||||||
|
|
||||||
// build YOLOv8
|
// build YOLOv8
|
||||||
let options_yolo = ModelConfig::yolo_detect()
|
let options_yolo = Config::yolo_detect()
|
||||||
.with_scale(Scale::N)
|
.with_scale(Scale::N)
|
||||||
.with_version(8.into())
|
.with_version(8.into())
|
||||||
.with_model_device(args.device.as_str().try_into()?)
|
.with_model_device(args.device.as_str().try_into()?)
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use usls::{
|
use usls::{
|
||||||
models::YOLO, Annotator, DataLoader, ModelConfig, Style, NAMES_COCO_80,
|
models::YOLO, Annotator, Config, DataLoader, Style, NAMES_COCO_80, NAMES_COCO_KEYPOINTS_17,
|
||||||
NAMES_COCO_KEYPOINTS_17, NAMES_IMAGENET_1K, SKELETON_COCO_19, SKELETON_COLOR_COCO_19,
|
NAMES_IMAGENET_1K, SKELETON_COCO_19, SKELETON_COLOR_COCO_19,
|
||||||
};
|
};
|
||||||
|
|
||||||
#[derive(argh::FromArgs, Debug)]
|
#[derive(argh::FromArgs, Debug)]
|
||||||
@ -130,7 +130,7 @@ fn main() -> Result<()> {
|
|||||||
.with_timer(tracing_subscriber::fmt::time::ChronoLocal::rfc_3339())
|
.with_timer(tracing_subscriber::fmt::time::ChronoLocal::rfc_3339())
|
||||||
.init();
|
.init();
|
||||||
let args: Args = argh::from_env();
|
let args: Args = argh::from_env();
|
||||||
let mut config = ModelConfig::yolo()
|
let mut config = Config::yolo()
|
||||||
.with_model_file(&args.model.unwrap_or_default())
|
.with_model_file(&args.model.unwrap_or_default())
|
||||||
.with_task(args.task.as_str().try_into()?)
|
.with_task(args.task.as_str().try_into()?)
|
||||||
.with_version(args.ver.try_into()?)
|
.with_version(args.ver.try_into()?)
|
||||||
@ -170,7 +170,8 @@ fn main() -> Result<()> {
|
|||||||
})
|
})
|
||||||
.with_topk(args.topk)
|
.with_topk(args.topk)
|
||||||
.retain_classes(&args.retain_classes)
|
.retain_classes(&args.retain_classes)
|
||||||
.exclude_classes(&args.exclude_classes);
|
.exclude_classes(&args.exclude_classes)
|
||||||
|
.with_model_num_dry_run(2);
|
||||||
if args.use_coco_80_classes {
|
if args.use_coco_80_classes {
|
||||||
config = config.with_class_names(&NAMES_COCO_80);
|
config = config.with_class_names(&NAMES_COCO_80);
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use usls::{models::YOLO, Annotator, DataLoader, ModelConfig, Style};
|
use usls::{models::YOLO, Annotator, Config, DataLoader, Style};
|
||||||
|
|
||||||
#[derive(argh::FromArgs)]
|
#[derive(argh::FromArgs)]
|
||||||
/// Example
|
/// Example
|
||||||
@ -22,7 +22,7 @@ fn main() -> Result<()> {
|
|||||||
let args: Args = argh::from_env();
|
let args: Args = argh::from_env();
|
||||||
|
|
||||||
// config
|
// config
|
||||||
let config = ModelConfig::yoloe_v8s_seg_pf()
|
let config = Config::yoloe_v8s_seg_pf()
|
||||||
// yoloe_v8m_seg_pf()
|
// yoloe_v8m_seg_pf()
|
||||||
// yoloe_v8l_seg_pf()
|
// yoloe_v8l_seg_pf()
|
||||||
// yoloe_11s_seg_pf()
|
// yoloe_11s_seg_pf()
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use usls::{models::YOLOPv2, Annotator, DataLoader, ModelConfig};
|
use usls::{models::YOLOPv2, Annotator, Config, DataLoader};
|
||||||
|
|
||||||
fn main() -> Result<()> {
|
fn main() -> Result<()> {
|
||||||
tracing_subscriber::fmt()
|
tracing_subscriber::fmt()
|
||||||
@ -8,7 +8,7 @@ fn main() -> Result<()> {
|
|||||||
.init();
|
.init();
|
||||||
|
|
||||||
// build model
|
// build model
|
||||||
let mut model = YOLOPv2::new(ModelConfig::yolop_v2_480x800().commit()?)?;
|
let mut model = YOLOPv2::new(Config::yolop_v2_480x800().commit()?)?;
|
||||||
|
|
||||||
// load image
|
// load image
|
||||||
let xs = DataLoader::try_read_n(&["images/car-view.jpg"])?;
|
let xs = DataLoader::try_read_n(&["images/car-view.jpg"])?;
|
||||||
|
@ -13,8 +13,8 @@ use prost::Message;
|
|||||||
use std::collections::HashSet;
|
use std::collections::HashSet;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
build_progress_bar, elapsed, human_bytes_binary, onnx, DType, Device, EngineConfig, Iiix,
|
build_progress_bar, elapsed, human_bytes_binary, onnx, DType, Device, Iiix, MinOptMax,
|
||||||
MinOptMax, Ops, Ts, Xs, PROGRESS_BAR_STYLE_CYAN_2, PROGRESS_BAR_STYLE_FINISH, X,
|
ORTConfig, Ops, Ts, Xs, PROGRESS_BAR_STYLE_CYAN_2, PROGRESS_BAR_STYLE_FINISH, X,
|
||||||
};
|
};
|
||||||
|
|
||||||
impl From<TensorElementType> for DType {
|
impl From<TensorElementType> for DType {
|
||||||
@ -93,7 +93,7 @@ impl Default for Engine {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Engine {
|
impl Engine {
|
||||||
pub fn try_from_config(config: &EngineConfig) -> Result<Self> {
|
pub fn try_from_config(config: &ORTConfig) -> Result<Self> {
|
||||||
Self {
|
Self {
|
||||||
file: config.file.clone(),
|
file: config.file.clone(),
|
||||||
spec: config.spec.clone(),
|
spec: config.spec.clone(),
|
||||||
@ -101,7 +101,7 @@ impl Engine {
|
|||||||
device: config.device,
|
device: config.device,
|
||||||
trt_fp16: config.trt_fp16,
|
trt_fp16: config.trt_fp16,
|
||||||
num_dry_run: config.num_dry_run,
|
num_dry_run: config.num_dry_run,
|
||||||
graph_opt_level: config.ort_graph_opt_level,
|
graph_opt_level: config.graph_opt_level,
|
||||||
..Default::default()
|
..Default::default()
|
||||||
}
|
}
|
||||||
.build()
|
.build()
|
||||||
|
@ -17,7 +17,9 @@ impl std::fmt::Debug for Hbb {
|
|||||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||||
f.debug_struct("Hbb")
|
f.debug_struct("Hbb")
|
||||||
.field("xyxy", &[self.x, self.y, self.xmax(), self.ymax()])
|
.field("xyxy", &[self.x, self.y, self.xmax(), self.ymax()])
|
||||||
.field("meta", &self.meta)
|
.field("id", &self.meta.id())
|
||||||
|
.field("name", &self.meta.name())
|
||||||
|
.field("confidence", &self.meta.confidence())
|
||||||
.finish()
|
.finish()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,6 @@ impl std::fmt::Debug for Keypoint {
|
|||||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||||
f.debug_struct("Keypoint")
|
f.debug_struct("Keypoint")
|
||||||
.field("xy", &[self.x, self.y])
|
.field("xy", &[self.x, self.y])
|
||||||
.field("uid", &self.meta.uid())
|
|
||||||
.field("id", &self.meta.id())
|
.field("id", &self.meta.id())
|
||||||
.field("name", &self.meta.name())
|
.field("name", &self.meta.name())
|
||||||
.field("confidence", &self.meta.confidence())
|
.field("confidence", &self.meta.confidence())
|
||||||
|
@ -20,7 +20,6 @@ impl std::fmt::Debug for Mask {
|
|||||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||||
f.debug_struct("Mask")
|
f.debug_struct("Mask")
|
||||||
.field("dimensions", &self.dimensions())
|
.field("dimensions", &self.dimensions())
|
||||||
.field("uid", &self.meta.uid())
|
|
||||||
.field("id", &self.meta.id())
|
.field("id", &self.meta.id())
|
||||||
.field("name", &self.meta.name())
|
.field("name", &self.meta.name())
|
||||||
.field("confidence", &self.meta.confidence())
|
.field("confidence", &self.meta.confidence())
|
||||||
|
@ -1,12 +1,10 @@
|
|||||||
#[cfg(any(feature = "ort-download-binaries", feature = "ort-load-dynamic"))]
|
#[cfg(any(feature = "ort-download-binaries", feature = "ort-load-dynamic"))]
|
||||||
mod engine;
|
mod engine;
|
||||||
mod engine_config;
|
|
||||||
mod hbb;
|
mod hbb;
|
||||||
mod image;
|
mod image;
|
||||||
mod instance_meta;
|
mod instance_meta;
|
||||||
mod keypoint;
|
mod keypoint;
|
||||||
mod mask;
|
mod mask;
|
||||||
mod model_config;
|
|
||||||
mod obb;
|
mod obb;
|
||||||
mod polygon;
|
mod polygon;
|
||||||
mod prob;
|
mod prob;
|
||||||
@ -22,13 +20,11 @@ pub(crate) mod onnx {
|
|||||||
|
|
||||||
#[cfg(any(feature = "ort-download-binaries", feature = "ort-load-dynamic"))]
|
#[cfg(any(feature = "ort-download-binaries", feature = "ort-load-dynamic"))]
|
||||||
pub use engine::*;
|
pub use engine::*;
|
||||||
pub use engine_config::EngineConfig;
|
|
||||||
pub use hbb::*;
|
pub use hbb::*;
|
||||||
pub use image::*;
|
pub use image::*;
|
||||||
pub use instance_meta::*;
|
pub use instance_meta::*;
|
||||||
pub use keypoint::*;
|
pub use keypoint::*;
|
||||||
pub use mask::*;
|
pub use mask::*;
|
||||||
pub use model_config::*;
|
|
||||||
pub use obb::*;
|
pub use obb::*;
|
||||||
pub use polygon::*;
|
pub use polygon::*;
|
||||||
pub use prob::*;
|
pub use prob::*;
|
||||||
|
@ -13,7 +13,7 @@ pub struct Obb {
|
|||||||
impl std::fmt::Debug for Obb {
|
impl std::fmt::Debug for Obb {
|
||||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||||
f.debug_struct("Obb")
|
f.debug_struct("Obb")
|
||||||
.field("uid", &self.meta.uid())
|
.field("vertices", &self.vertices)
|
||||||
.field("id", &self.meta.id())
|
.field("id", &self.meta.id())
|
||||||
.field("name", &self.meta.name())
|
.field("name", &self.meta.name())
|
||||||
.field("confidence", &self.meta.confidence())
|
.field("confidence", &self.meta.confidence())
|
||||||
|
@ -27,8 +27,7 @@ impl Default for Polygon {
|
|||||||
impl std::fmt::Debug for Polygon {
|
impl std::fmt::Debug for Polygon {
|
||||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||||
f.debug_struct("Polygon")
|
f.debug_struct("Polygon")
|
||||||
.field("count", &self.count())
|
.field("n_points", &self.count())
|
||||||
.field("uid", &self.meta.uid())
|
|
||||||
.field("id", &self.meta.id())
|
.field("id", &self.meta.id())
|
||||||
.field("name", &self.meta.name())
|
.field("name", &self.meta.name())
|
||||||
.field("confidence", &self.meta.confidence())
|
.field("confidence", &self.meta.confidence())
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/// Model configuration for `BEiT`
|
/// Model configuration for `BEiT`
|
||||||
impl crate::ModelConfig {
|
impl crate::Config {
|
||||||
pub fn beit() -> Self {
|
pub fn beit() -> Self {
|
||||||
Self::default()
|
Self::default()
|
||||||
.with_name("beit")
|
.with_name("beit")
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/// Model configuration for `BEN2`
|
/// Model configuration for `BEN2`
|
||||||
impl crate::ModelConfig {
|
impl crate::Config {
|
||||||
pub fn ben2_base() -> Self {
|
pub fn ben2_base() -> Self {
|
||||||
Self::rmbg().with_model_file("ben2-base.onnx")
|
Self::rmbg().with_model_file("ben2-base.onnx")
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/// Model configuration for `BLIP`
|
/// Model configuration for `BLIP`
|
||||||
impl crate::ModelConfig {
|
impl crate::Config {
|
||||||
#[allow(clippy::excessive_precision)]
|
#[allow(clippy::excessive_precision)]
|
||||||
pub fn blip() -> Self {
|
pub fn blip() -> Self {
|
||||||
Self::default()
|
Self::default()
|
||||||
|
@ -2,7 +2,7 @@ use aksr::Builder;
|
|||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use ndarray::{s, Axis};
|
use ndarray::{s, Axis};
|
||||||
|
|
||||||
use crate::{elapsed, Engine, Image, LogitsSampler, ModelConfig, Processor, Ts, Xs, X, Y};
|
use crate::{elapsed, Config, Engine, Image, LogitsSampler, Processor, Ts, Xs, X, Y};
|
||||||
|
|
||||||
#[derive(Debug, Builder)]
|
#[derive(Debug, Builder)]
|
||||||
pub struct Blip {
|
pub struct Blip {
|
||||||
@ -18,7 +18,7 @@ pub struct Blip {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Blip {
|
impl Blip {
|
||||||
pub fn new(config: ModelConfig) -> Result<Self> {
|
pub fn new(config: Config) -> Result<Self> {
|
||||||
let visual = Engine::try_from_config(&config.visual)?;
|
let visual = Engine::try_from_config(&config.visual)?;
|
||||||
let textual = Engine::try_from_config(&config.textual)?;
|
let textual = Engine::try_from_config(&config.textual)?;
|
||||||
let (batch, height, width) = (
|
let (batch, height, width) = (
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/// Model configuration for `CLIP`
|
/// Model configuration for `CLIP`
|
||||||
impl crate::ModelConfig {
|
impl crate::Config {
|
||||||
pub fn clip() -> Self {
|
pub fn clip() -> Self {
|
||||||
Self::default()
|
Self::default()
|
||||||
.with_name("clip")
|
.with_name("clip")
|
||||||
|
@ -2,7 +2,7 @@ use aksr::Builder;
|
|||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use ndarray::Array2;
|
use ndarray::Array2;
|
||||||
|
|
||||||
use crate::{elapsed, Engine, Image, ModelConfig, Processor, Ts, X};
|
use crate::{elapsed, Config, Engine, Image, Processor, Ts, X};
|
||||||
|
|
||||||
#[derive(Debug, Builder)]
|
#[derive(Debug, Builder)]
|
||||||
pub struct Clip {
|
pub struct Clip {
|
||||||
@ -16,7 +16,7 @@ pub struct Clip {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Clip {
|
impl Clip {
|
||||||
pub fn new(config: ModelConfig) -> Result<Self> {
|
pub fn new(config: Config) -> Result<Self> {
|
||||||
let visual = Engine::try_from_config(&config.visual)?;
|
let visual = Engine::try_from_config(&config.visual)?;
|
||||||
let textual = Engine::try_from_config(&config.textual)?;
|
let textual = Engine::try_from_config(&config.textual)?;
|
||||||
let (batch, height, width) = (
|
let (batch, height, width) = (
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
use crate::NAMES_IMAGENET_1K;
|
use crate::NAMES_IMAGENET_1K;
|
||||||
|
|
||||||
/// Model configuration for `ConvNeXt`
|
/// Model configuration for `ConvNeXt`
|
||||||
impl crate::ModelConfig {
|
impl crate::Config {
|
||||||
pub fn convnext() -> Self {
|
pub fn convnext() -> Self {
|
||||||
Self::default()
|
Self::default()
|
||||||
.with_name("convnext")
|
.with_name("convnext")
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/// Model configuration for `d_fine`
|
/// Model configuration for `d_fine`
|
||||||
impl crate::ModelConfig {
|
impl crate::Config {
|
||||||
pub fn d_fine() -> Self {
|
pub fn d_fine() -> Self {
|
||||||
Self::rtdetr().with_name("d-fine")
|
Self::rtdetr().with_name("d-fine")
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/// Model configuration for [DB](https://github.com/MhLiao/DB) and [PaddleOCR-Det](https://github.com/PaddlePaddle/PaddleOCR)
|
/// Model configuration for [DB](https://github.com/MhLiao/DB) and [PaddleOCR-Det](https://github.com/PaddlePaddle/PaddleOCR)
|
||||||
impl crate::ModelConfig {
|
impl crate::Config {
|
||||||
pub fn db() -> Self {
|
pub fn db() -> Self {
|
||||||
Self::default()
|
Self::default()
|
||||||
.with_name("db")
|
.with_name("db")
|
||||||
|
@ -4,8 +4,7 @@ use ndarray::Axis;
|
|||||||
use rayon::prelude::*;
|
use rayon::prelude::*;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
elapsed, DynConf, Engine, Hbb, Image, Mask, ModelConfig, Obb, Ops, Polygon, Processor, Ts, Xs,
|
elapsed, Config, DynConf, Engine, Hbb, Image, Mask, Obb, Ops, Polygon, Processor, Ts, Xs, Y,
|
||||||
Y,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#[derive(Debug, Builder)]
|
#[derive(Debug, Builder)]
|
||||||
@ -25,7 +24,7 @@ pub struct DB {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl DB {
|
impl DB {
|
||||||
pub fn new(config: ModelConfig) -> Result<Self> {
|
pub fn new(config: Config) -> Result<Self> {
|
||||||
let engine = Engine::try_from_config(&config.model)?;
|
let engine = Engine::try_from_config(&config.model)?;
|
||||||
let (batch, height, width, ts, spec) = (
|
let (batch, height, width, ts, spec) = (
|
||||||
engine.batch().opt(),
|
engine.batch().opt(),
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/// Model configuration for `DEIM`
|
/// Model configuration for `DEIM`
|
||||||
impl crate::ModelConfig {
|
impl crate::Config {
|
||||||
pub fn deim() -> Self {
|
pub fn deim() -> Self {
|
||||||
Self::d_fine().with_name("deim")
|
Self::d_fine().with_name("deim")
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
use crate::NAMES_IMAGENET_1K;
|
use crate::NAMES_IMAGENET_1K;
|
||||||
|
|
||||||
/// Model configuration for `DeiT`
|
/// Model configuration for `DeiT`
|
||||||
impl crate::ModelConfig {
|
impl crate::Config {
|
||||||
pub fn deit() -> Self {
|
pub fn deit() -> Self {
|
||||||
Self::default()
|
Self::default()
|
||||||
.with_name("deit")
|
.with_name("deit")
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/// Model configuration for `DepthAnything`
|
/// Model configuration for `DepthAnything`
|
||||||
impl crate::ModelConfig {
|
impl crate::Config {
|
||||||
pub fn depth_anything() -> Self {
|
pub fn depth_anything() -> Self {
|
||||||
Self::default()
|
Self::default()
|
||||||
.with_name("depth-anything")
|
.with_name("depth-anything")
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
use aksr::Builder;
|
use aksr::Builder;
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
|
|
||||||
use crate::{elapsed, Engine, Image, Mask, ModelConfig, Ops, Processor, Ts, Xs, Y};
|
use crate::{elapsed, Config, Engine, Image, Mask, Ops, Processor, Ts, Xs, Y};
|
||||||
|
|
||||||
#[derive(Debug, Builder)]
|
#[derive(Debug, Builder)]
|
||||||
pub struct DepthAnything {
|
pub struct DepthAnything {
|
||||||
@ -15,7 +15,7 @@ pub struct DepthAnything {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl DepthAnything {
|
impl DepthAnything {
|
||||||
pub fn new(config: ModelConfig) -> Result<Self> {
|
pub fn new(config: Config) -> Result<Self> {
|
||||||
let engine = Engine::try_from_config(&config.model)?;
|
let engine = Engine::try_from_config(&config.model)?;
|
||||||
let spec = engine.spec().to_string();
|
let spec = engine.spec().to_string();
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/// Model configuration for `DepthPro`
|
/// Model configuration for `DepthPro`
|
||||||
impl crate::ModelConfig {
|
impl crate::Config {
|
||||||
pub fn depth_pro() -> Self {
|
pub fn depth_pro() -> Self {
|
||||||
Self::default()
|
Self::default()
|
||||||
.with_name("depth-pro")
|
.with_name("depth-pro")
|
||||||
|
@ -2,7 +2,7 @@ use aksr::Builder;
|
|||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use ndarray::Axis;
|
use ndarray::Axis;
|
||||||
|
|
||||||
use crate::{elapsed, Engine, Image, Mask, ModelConfig, Ops, Processor, Ts, Xs, Y};
|
use crate::{elapsed, Config, Engine, Image, Mask, Ops, Processor, Ts, Xs, Y};
|
||||||
|
|
||||||
#[derive(Builder, Debug)]
|
#[derive(Builder, Debug)]
|
||||||
pub struct DepthPro {
|
pub struct DepthPro {
|
||||||
@ -16,7 +16,7 @@ pub struct DepthPro {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl DepthPro {
|
impl DepthPro {
|
||||||
pub fn new(config: ModelConfig) -> Result<Self> {
|
pub fn new(config: Config) -> Result<Self> {
|
||||||
let engine = Engine::try_from_config(&config.model)?;
|
let engine = Engine::try_from_config(&config.model)?;
|
||||||
let spec = engine.spec().to_string();
|
let spec = engine.spec().to_string();
|
||||||
let (batch, height, width, ts) = (
|
let (batch, height, width, ts) = (
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/// Model configuration for `DINOv2`
|
/// Model configuration for `DINOv2`
|
||||||
impl crate::ModelConfig {
|
impl crate::Config {
|
||||||
pub fn dinov2() -> Self {
|
pub fn dinov2() -> Self {
|
||||||
Self::default()
|
Self::default()
|
||||||
.with_name("dinov2")
|
.with_name("dinov2")
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
use aksr::Builder;
|
use aksr::Builder;
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
|
|
||||||
use crate::{elapsed, Engine, Image, ModelConfig, Processor, Scale, Ts, Xs, X};
|
use crate::{elapsed, Config, Engine, Image, Processor, Scale, Ts, Xs, X};
|
||||||
|
|
||||||
#[derive(Builder, Debug)]
|
#[derive(Builder, Debug)]
|
||||||
pub struct DINOv2 {
|
pub struct DINOv2 {
|
||||||
@ -15,7 +15,7 @@ pub struct DINOv2 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl DINOv2 {
|
impl DINOv2 {
|
||||||
pub fn new(config: ModelConfig) -> Result<Self> {
|
pub fn new(config: Config) -> Result<Self> {
|
||||||
let engine = Engine::try_from_config(&config.model)?;
|
let engine = Engine::try_from_config(&config.model)?;
|
||||||
let (batch, height, width, ts) = (
|
let (batch, height, width, ts) = (
|
||||||
engine.batch().opt(),
|
engine.batch().opt(),
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/// Model configuration for [FAST: Faster Arbitrarily-Shaped Text Detector with Minimalist Kernel Representation](https://github.com/czczup/FAST)
|
/// Model configuration for [FAST: Faster Arbitrarily-Shaped Text Detector with Minimalist Kernel Representation](https://github.com/czczup/FAST)
|
||||||
impl crate::ModelConfig {
|
impl crate::Config {
|
||||||
pub fn fast() -> Self {
|
pub fn fast() -> Self {
|
||||||
Self::db()
|
Self::db()
|
||||||
.with_name("fast")
|
.with_name("fast")
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
use crate::NAMES_IMAGENET_1K;
|
use crate::NAMES_IMAGENET_1K;
|
||||||
|
|
||||||
/// Model configuration for `FastViT`
|
/// Model configuration for `FastViT`
|
||||||
impl crate::ModelConfig {
|
impl crate::Config {
|
||||||
pub fn fastvit() -> Self {
|
pub fn fastvit() -> Self {
|
||||||
Self::default()
|
Self::default()
|
||||||
.with_name("fastvit")
|
.with_name("fastvit")
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/// Model configuration for `Florence2`
|
/// Model configuration for `Florence2`
|
||||||
impl crate::ModelConfig {
|
impl crate::Config {
|
||||||
pub fn florence2() -> Self {
|
pub fn florence2() -> Self {
|
||||||
Self::default()
|
Self::default()
|
||||||
.with_name("florence2")
|
.with_name("florence2")
|
||||||
|
@ -4,7 +4,7 @@ use ndarray::{s, Axis};
|
|||||||
use rayon::prelude::*;
|
use rayon::prelude::*;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
elapsed, models::Quantizer, Engine, Hbb, Image, LogitsSampler, ModelConfig, Polygon, Processor,
|
elapsed, models::Quantizer, Config, Engine, Hbb, Image, LogitsSampler, Polygon, Processor,
|
||||||
Scale, Task, Ts, Xs, X, Y,
|
Scale, Task, Ts, Xs, X, Y,
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -28,7 +28,7 @@ pub struct Florence2 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Florence2 {
|
impl Florence2 {
|
||||||
pub fn new(config: ModelConfig) -> Result<Self> {
|
pub fn new(config: Config) -> Result<Self> {
|
||||||
let vision_encoder = Engine::try_from_config(&config.visual)?;
|
let vision_encoder = Engine::try_from_config(&config.visual)?;
|
||||||
let text_embed = Engine::try_from_config(&config.textual)?;
|
let text_embed = Engine::try_from_config(&config.textual)?;
|
||||||
let encoder = Engine::try_from_config(&config.textual_encoder)?;
|
let encoder = Engine::try_from_config(&config.textual_encoder)?;
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/// Model configuration for `GroundingDino`
|
/// Model configuration for `GroundingDino`
|
||||||
impl crate::ModelConfig {
|
impl crate::Config {
|
||||||
pub fn grounding_dino() -> Self {
|
pub fn grounding_dino() -> Self {
|
||||||
Self::default()
|
Self::default()
|
||||||
.with_name("grounding-dino")
|
.with_name("grounding-dino")
|
||||||
|
@ -4,7 +4,7 @@ use ndarray::{s, Array2, Axis};
|
|||||||
use rayon::prelude::*;
|
use rayon::prelude::*;
|
||||||
use std::fmt::Write;
|
use std::fmt::Write;
|
||||||
|
|
||||||
use crate::{elapsed, DynConf, Engine, Hbb, Image, ModelConfig, Processor, Ts, Xs, X, Y};
|
use crate::{elapsed, Config, DynConf, Engine, Hbb, Image, Processor, Ts, Xs, X, Y};
|
||||||
|
|
||||||
#[derive(Builder, Debug)]
|
#[derive(Builder, Debug)]
|
||||||
pub struct GroundingDINO {
|
pub struct GroundingDINO {
|
||||||
@ -24,7 +24,7 @@ pub struct GroundingDINO {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl GroundingDINO {
|
impl GroundingDINO {
|
||||||
pub fn new(config: ModelConfig) -> Result<Self> {
|
pub fn new(config: Config) -> Result<Self> {
|
||||||
let engine = Engine::try_from_config(&config.model)?;
|
let engine = Engine::try_from_config(&config.model)?;
|
||||||
let spec = engine.spec().to_string();
|
let spec = engine.spec().to_string();
|
||||||
let (batch, height, width, ts) = (
|
let (batch, height, width, ts) = (
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/// Model configuration for [LinkNet: Exploiting Encoder Representations for Efficient Semantic Segmentation](https://arxiv.org/abs/1707.03718)
|
/// Model configuration for [LinkNet: Exploiting Encoder Representations for Efficient Semantic Segmentation](https://arxiv.org/abs/1707.03718)
|
||||||
impl crate::ModelConfig {
|
impl crate::Config {
|
||||||
pub fn linknet() -> Self {
|
pub fn linknet() -> Self {
|
||||||
Self::fast()
|
Self::fast()
|
||||||
.with_name("linknet")
|
.with_name("linknet")
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
use crate::NAMES_IMAGENET_1K;
|
use crate::NAMES_IMAGENET_1K;
|
||||||
|
|
||||||
/// Model configuration for `MobileOne`
|
/// Model configuration for `MobileOne`
|
||||||
impl crate::ModelConfig {
|
impl crate::Config {
|
||||||
pub fn mobileone() -> Self {
|
pub fn mobileone() -> Self {
|
||||||
Self::default()
|
Self::default()
|
||||||
.with_name("mobileone")
|
.with_name("mobileone")
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/// Model configuration for `MODNet`
|
/// Model configuration for `MODNet`
|
||||||
impl crate::ModelConfig {
|
impl crate::Config {
|
||||||
pub fn modnet() -> Self {
|
pub fn modnet() -> Self {
|
||||||
Self::default()
|
Self::default()
|
||||||
.with_name("modnet")
|
.with_name("modnet")
|
||||||
|
@ -2,7 +2,7 @@ use aksr::Builder;
|
|||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use ndarray::Axis;
|
use ndarray::Axis;
|
||||||
|
|
||||||
use crate::{elapsed, Engine, Image, Mask, ModelConfig, Ops, Processor, Ts, Xs, Y};
|
use crate::{elapsed, Config, Engine, Image, Mask, Ops, Processor, Ts, Xs, Y};
|
||||||
|
|
||||||
#[derive(Builder, Debug)]
|
#[derive(Builder, Debug)]
|
||||||
pub struct MODNet {
|
pub struct MODNet {
|
||||||
@ -16,7 +16,7 @@ pub struct MODNet {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl MODNet {
|
impl MODNet {
|
||||||
pub fn new(config: ModelConfig) -> Result<Self> {
|
pub fn new(config: Config) -> Result<Self> {
|
||||||
let engine = Engine::try_from_config(&config.model)?;
|
let engine = Engine::try_from_config(&config.model)?;
|
||||||
let spec = engine.spec().to_string();
|
let spec = engine.spec().to_string();
|
||||||
let (batch, height, width, ts) = (
|
let (batch, height, width, ts) = (
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/// Model configuration for `moondream2`
|
/// Model configuration for `moondream2`
|
||||||
impl crate::ModelConfig {
|
impl crate::Config {
|
||||||
pub fn moondream2() -> Self {
|
pub fn moondream2() -> Self {
|
||||||
Self::default()
|
Self::default()
|
||||||
.with_name("moondream2")
|
.with_name("moondream2")
|
||||||
|
@ -5,8 +5,8 @@ use ndarray::{s, Array, Array2, Array3, Axis, IxDyn};
|
|||||||
use ndarray_npy::ReadNpyExt;
|
use ndarray_npy::ReadNpyExt;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
DType, Engine, Hbb, Hub, Image, Keypoint, LogitsSampler, ModelConfig, Processor, Scale, Task,
|
Config, DType, Engine, Hbb, Hub, Image, Keypoint, LogitsSampler, Processor, Scale, Task, Xs, X,
|
||||||
Xs, X, Y,
|
Y,
|
||||||
};
|
};
|
||||||
|
|
||||||
#[derive(Builder, Debug)]
|
#[derive(Builder, Debug)]
|
||||||
@ -32,7 +32,7 @@ pub struct Moondream2 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Moondream2 {
|
impl Moondream2 {
|
||||||
pub fn new(config: ModelConfig) -> Result<Self> {
|
pub fn new(config: Config) -> Result<Self> {
|
||||||
let max_length = 2048;
|
let max_length = 2048;
|
||||||
let max_objects = 50;
|
let max_objects = 50;
|
||||||
let eos_token_id = 50256;
|
let eos_token_id = 50256;
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/// Model configuration for `OWLv2`
|
/// Model configuration for `OWLv2`
|
||||||
impl crate::ModelConfig {
|
impl crate::Config {
|
||||||
pub fn owlv2() -> Self {
|
pub fn owlv2() -> Self {
|
||||||
Self::default()
|
Self::default()
|
||||||
.with_name("owlv2")
|
.with_name("owlv2")
|
||||||
|
@ -3,7 +3,7 @@ use anyhow::Result;
|
|||||||
use ndarray::{s, Axis};
|
use ndarray::{s, Axis};
|
||||||
use rayon::prelude::*;
|
use rayon::prelude::*;
|
||||||
|
|
||||||
use crate::{elapsed, DynConf, Engine, Hbb, Image, ModelConfig, Processor, Ts, Xs, X, Y};
|
use crate::{elapsed, Config, DynConf, Engine, Hbb, Image, Processor, Ts, Xs, X, Y};
|
||||||
|
|
||||||
#[derive(Debug, Builder)]
|
#[derive(Debug, Builder)]
|
||||||
pub struct OWLv2 {
|
pub struct OWLv2 {
|
||||||
@ -22,7 +22,7 @@ pub struct OWLv2 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl OWLv2 {
|
impl OWLv2 {
|
||||||
pub fn new(config: ModelConfig) -> Result<Self> {
|
pub fn new(config: Config) -> Result<Self> {
|
||||||
let engine = Engine::try_from_config(&config.model)?;
|
let engine = Engine::try_from_config(&config.model)?;
|
||||||
let (batch, height, width, ts) = (
|
let (batch, height, width, ts) = (
|
||||||
engine.batch().opt(),
|
engine.batch().opt(),
|
||||||
|
@ -4,7 +4,7 @@ use crate::{
|
|||||||
};
|
};
|
||||||
|
|
||||||
/// Model configuration for `PicoDet`
|
/// Model configuration for `PicoDet`
|
||||||
impl crate::ModelConfig {
|
impl crate::Config {
|
||||||
pub fn picodet() -> Self {
|
pub fn picodet() -> Self {
|
||||||
Self::default()
|
Self::default()
|
||||||
.with_name("picodet")
|
.with_name("picodet")
|
||||||
|
@ -3,7 +3,7 @@ use anyhow::Result;
|
|||||||
use ndarray::Axis;
|
use ndarray::Axis;
|
||||||
use rayon::prelude::*;
|
use rayon::prelude::*;
|
||||||
|
|
||||||
use crate::{elapsed, DynConf, Engine, Hbb, Image, ModelConfig, Processor, Ts, Xs, X, Y};
|
use crate::{elapsed, Config, DynConf, Engine, Hbb, Image, Processor, Ts, Xs, X, Y};
|
||||||
|
|
||||||
#[derive(Debug, Builder)]
|
#[derive(Debug, Builder)]
|
||||||
pub struct PicoDet {
|
pub struct PicoDet {
|
||||||
@ -19,7 +19,7 @@ pub struct PicoDet {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl PicoDet {
|
impl PicoDet {
|
||||||
pub fn new(config: ModelConfig) -> Result<Self> {
|
pub fn new(config: Config) -> Result<Self> {
|
||||||
let engine = Engine::try_from_config(&config.model)?;
|
let engine = Engine::try_from_config(&config.model)?;
|
||||||
let (batch, height, width, ts) = (
|
let (batch, height, width, ts) = (
|
||||||
engine.batch().opt(),
|
engine.batch().opt(),
|
||||||
|
@ -2,7 +2,7 @@ use aksr::Builder;
|
|||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
elapsed, DType, Device, Engine, Image, ModelConfig, Processor, Scale, Task, Ts, Version, Xs, X,
|
elapsed, Config, DType, Device, Engine, Image, Processor, Scale, Task, Ts, Version, Xs, X,
|
||||||
};
|
};
|
||||||
|
|
||||||
#[derive(Debug, Builder)]
|
#[derive(Debug, Builder)]
|
||||||
@ -27,7 +27,7 @@ impl BaseModelVisual {
|
|||||||
self.ts.summary();
|
self.ts.summary();
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new(config: ModelConfig) -> Result<Self> {
|
pub fn new(config: Config) -> Result<Self> {
|
||||||
let engine = Engine::try_from_config(&config.model)?;
|
let engine = Engine::try_from_config(&config.model)?;
|
||||||
let err_msg = "You need to specify the image height and image width for visual model.";
|
let err_msg = "You need to specify the image height and image width for visual model.";
|
||||||
let (batch, height, width, ts, spec) = (
|
let (batch, height, width, ts, spec) = (
|
||||||
@ -103,7 +103,7 @@ impl BaseModelTextual {
|
|||||||
self.ts.summary();
|
self.ts.summary();
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new(config: ModelConfig) -> Result<Self> {
|
pub fn new(config: Config) -> Result<Self> {
|
||||||
let engine = Engine::try_from_config(&config.model)?;
|
let engine = Engine::try_from_config(&config.model)?;
|
||||||
let (batch, ts, spec) = (
|
let (batch, ts, spec) = (
|
||||||
engine.batch().opt(),
|
engine.batch().opt(),
|
||||||
|
@ -3,7 +3,7 @@ use anyhow::Result;
|
|||||||
use ndarray::Axis;
|
use ndarray::Axis;
|
||||||
use rayon::prelude::*;
|
use rayon::prelude::*;
|
||||||
|
|
||||||
use crate::{elapsed, Engine, Image, ModelConfig, Prob, Processor, Ts, Xs, Y};
|
use crate::{elapsed, Config, Engine, Image, Prob, Processor, Ts, Xs, Y};
|
||||||
|
|
||||||
#[derive(Debug, Builder)]
|
#[derive(Debug, Builder)]
|
||||||
pub struct ImageClassifier {
|
pub struct ImageClassifier {
|
||||||
@ -19,16 +19,16 @@ pub struct ImageClassifier {
|
|||||||
ts: Ts,
|
ts: Ts,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl TryFrom<ModelConfig> for ImageClassifier {
|
impl TryFrom<Config> for ImageClassifier {
|
||||||
type Error = anyhow::Error;
|
type Error = anyhow::Error;
|
||||||
|
|
||||||
fn try_from(config: ModelConfig) -> Result<Self, Self::Error> {
|
fn try_from(config: Config) -> Result<Self, Self::Error> {
|
||||||
Self::new(config)
|
Self::new(config)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ImageClassifier {
|
impl ImageClassifier {
|
||||||
pub fn new(config: ModelConfig) -> Result<Self> {
|
pub fn new(config: Config) -> Result<Self> {
|
||||||
let engine = Engine::try_from_config(&config.model)?;
|
let engine = Engine::try_from_config(&config.model)?;
|
||||||
let spec = engine.spec().to_string();
|
let spec = engine.spec().to_string();
|
||||||
let (batch, height, width, ts) = (
|
let (batch, height, width, ts) = (
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
use crate::NAMES_COCO_91;
|
use crate::NAMES_COCO_91;
|
||||||
|
|
||||||
/// Model configuration for `RT-DETR`
|
/// Model configuration for `RT-DETR`
|
||||||
impl crate::ModelConfig {
|
impl crate::Config {
|
||||||
pub fn rfdetr() -> Self {
|
pub fn rfdetr() -> Self {
|
||||||
Self::default()
|
Self::default()
|
||||||
.with_name("rfdetr")
|
.with_name("rfdetr")
|
||||||
|
@ -3,7 +3,7 @@ use anyhow::Result;
|
|||||||
use ndarray::{s, Axis};
|
use ndarray::{s, Axis};
|
||||||
use rayon::prelude::*;
|
use rayon::prelude::*;
|
||||||
|
|
||||||
use crate::{elapsed, DynConf, Engine, Hbb, Image, ModelConfig, Processor, Ts, Xs, Y};
|
use crate::{elapsed, Config, DynConf, Engine, Hbb, Image, Processor, Ts, Xs, Y};
|
||||||
|
|
||||||
#[derive(Debug, Builder)]
|
#[derive(Debug, Builder)]
|
||||||
pub struct RFDETR {
|
pub struct RFDETR {
|
||||||
@ -19,7 +19,7 @@ pub struct RFDETR {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl RFDETR {
|
impl RFDETR {
|
||||||
pub fn new(config: ModelConfig) -> Result<Self> {
|
pub fn new(config: Config) -> Result<Self> {
|
||||||
let engine = Engine::try_from_config(&config.model)?;
|
let engine = Engine::try_from_config(&config.model)?;
|
||||||
let (batch, height, width, ts) = (
|
let (batch, height, width, ts) = (
|
||||||
engine.batch().opt(),
|
engine.batch().opt(),
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/// Model configuration for `RMBG`
|
/// Model configuration for `RMBG`
|
||||||
impl crate::ModelConfig {
|
impl crate::Config {
|
||||||
pub fn rmbg() -> Self {
|
pub fn rmbg() -> Self {
|
||||||
Self::default()
|
Self::default()
|
||||||
.with_name("rmbg")
|
.with_name("rmbg")
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
use aksr::Builder;
|
use aksr::Builder;
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
|
|
||||||
use crate::{elapsed, Engine, Image, Mask, ModelConfig, Ops, Processor, Ts, Xs, Y};
|
use crate::{elapsed, Config, Engine, Image, Mask, Ops, Processor, Ts, Xs, Y};
|
||||||
|
|
||||||
#[derive(Builder, Debug)]
|
#[derive(Builder, Debug)]
|
||||||
pub struct RMBG {
|
pub struct RMBG {
|
||||||
@ -15,7 +15,7 @@ pub struct RMBG {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl RMBG {
|
impl RMBG {
|
||||||
pub fn new(config: ModelConfig) -> Result<Self> {
|
pub fn new(config: Config) -> Result<Self> {
|
||||||
let engine = Engine::try_from_config(&config.model)?;
|
let engine = Engine::try_from_config(&config.model)?;
|
||||||
let spec = engine.spec().to_string();
|
let spec = engine.spec().to_string();
|
||||||
let (batch, height, width, ts) = (
|
let (batch, height, width, ts) = (
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
use crate::NAMES_COCO_80;
|
use crate::NAMES_COCO_80;
|
||||||
|
|
||||||
/// Model configuration for `RT-DETR`
|
/// Model configuration for `RT-DETR`
|
||||||
impl crate::ModelConfig {
|
impl crate::Config {
|
||||||
pub fn rtdetr() -> Self {
|
pub fn rtdetr() -> Self {
|
||||||
Self::default()
|
Self::default()
|
||||||
.with_name("rtdetr")
|
.with_name("rtdetr")
|
||||||
|
@ -3,7 +3,7 @@ use anyhow::Result;
|
|||||||
use ndarray::{s, Axis};
|
use ndarray::{s, Axis};
|
||||||
use rayon::prelude::*;
|
use rayon::prelude::*;
|
||||||
|
|
||||||
use crate::{elapsed, DynConf, Engine, Hbb, Image, ModelConfig, Processor, Ts, Xs, X, Y};
|
use crate::{elapsed, Config, DynConf, Engine, Hbb, Image, Processor, Ts, Xs, X, Y};
|
||||||
|
|
||||||
#[derive(Debug, Builder)]
|
#[derive(Debug, Builder)]
|
||||||
pub struct RTDETR {
|
pub struct RTDETR {
|
||||||
@ -19,7 +19,7 @@ pub struct RTDETR {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl RTDETR {
|
impl RTDETR {
|
||||||
pub fn new(config: ModelConfig) -> Result<Self> {
|
pub fn new(config: Config) -> Result<Self> {
|
||||||
let engine = Engine::try_from_config(&config.model)?;
|
let engine = Engine::try_from_config(&config.model)?;
|
||||||
let (batch, height, width, ts) = (
|
let (batch, height, width, ts) = (
|
||||||
engine.batch().opt(),
|
engine.batch().opt(),
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/// Model configuration for `RTMO`
|
/// Model configuration for `RTMO`
|
||||||
impl crate::ModelConfig {
|
impl crate::Config {
|
||||||
pub fn rtmo() -> Self {
|
pub fn rtmo() -> Self {
|
||||||
Self::default()
|
Self::default()
|
||||||
.with_name("rtmo")
|
.with_name("rtmo")
|
||||||
|
@ -2,7 +2,7 @@ use aksr::Builder;
|
|||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use ndarray::Axis;
|
use ndarray::Axis;
|
||||||
|
|
||||||
use crate::{elapsed, DynConf, Engine, Hbb, Image, Keypoint, ModelConfig, Processor, Ts, Xs, Y};
|
use crate::{elapsed, Config, DynConf, Engine, Hbb, Image, Keypoint, Processor, Ts, Xs, Y};
|
||||||
|
|
||||||
#[derive(Builder, Debug)]
|
#[derive(Builder, Debug)]
|
||||||
pub struct RTMO {
|
pub struct RTMO {
|
||||||
@ -18,7 +18,7 @@ pub struct RTMO {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl RTMO {
|
impl RTMO {
|
||||||
pub fn new(config: ModelConfig) -> Result<Self> {
|
pub fn new(config: Config) -> Result<Self> {
|
||||||
let engine = Engine::try_from_config(&config.model)?;
|
let engine = Engine::try_from_config(&config.model)?;
|
||||||
let spec = engine.spec().to_string();
|
let spec = engine.spec().to_string();
|
||||||
let (batch, height, width, ts) = (
|
let (batch, height, width, ts) = (
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
use crate::{models::SamKind, ModelConfig};
|
use crate::{models::SamKind, Config};
|
||||||
|
|
||||||
/// Model configuration for `Segment Anything Model`
|
/// Model configuration for `Segment Anything Model`
|
||||||
impl ModelConfig {
|
impl Config {
|
||||||
pub fn sam() -> Self {
|
pub fn sam() -> Self {
|
||||||
Self::default()
|
Self::default()
|
||||||
.with_name("sam")
|
.with_name("sam")
|
||||||
|
@ -4,8 +4,7 @@ use ndarray::{s, Axis};
|
|||||||
use rand::prelude::*;
|
use rand::prelude::*;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
elapsed, DynConf, Engine, Image, Mask, ModelConfig, Ops, Polygon, Processor, SamPrompt, Ts, Xs,
|
elapsed, Config, DynConf, Engine, Image, Mask, Ops, Polygon, Processor, SamPrompt, Ts, Xs, X, Y,
|
||||||
X, Y,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
@ -49,7 +48,7 @@ pub struct SAM {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl SAM {
|
impl SAM {
|
||||||
pub fn new(config: ModelConfig) -> Result<Self> {
|
pub fn new(config: Config) -> Result<Self> {
|
||||||
let encoder = Engine::try_from_config(&config.encoder)?;
|
let encoder = Engine::try_from_config(&config.encoder)?;
|
||||||
let decoder = Engine::try_from_config(&config.decoder)?;
|
let decoder = Engine::try_from_config(&config.decoder)?;
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
use crate::ModelConfig;
|
use crate::Config;
|
||||||
|
|
||||||
/// Model configuration for `SAM2.1`
|
/// Model configuration for `SAM2.1`
|
||||||
impl ModelConfig {
|
impl Config {
|
||||||
pub fn sam2_1_tiny() -> Self {
|
pub fn sam2_1_tiny() -> Self {
|
||||||
Self::sam()
|
Self::sam()
|
||||||
.with_encoder_file("sam2.1-hiera-tiny-encoder.onnx")
|
.with_encoder_file("sam2.1-hiera-tiny-encoder.onnx")
|
||||||
|
@ -3,7 +3,7 @@ use anyhow::Result;
|
|||||||
use ndarray::{s, Axis};
|
use ndarray::{s, Axis};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
elapsed, DynConf, Engine, Image, Mask, ModelConfig, Ops, Processor, SamPrompt, Ts, Xs, X, Y,
|
elapsed, Config, DynConf, Engine, Image, Mask, Ops, Processor, SamPrompt, Ts, Xs, X, Y,
|
||||||
};
|
};
|
||||||
|
|
||||||
#[derive(Builder, Debug)]
|
#[derive(Builder, Debug)]
|
||||||
@ -20,7 +20,7 @@ pub struct SAM2 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl SAM2 {
|
impl SAM2 {
|
||||||
pub fn new(config: ModelConfig) -> Result<Self> {
|
pub fn new(config: Config) -> Result<Self> {
|
||||||
let encoder = Engine::try_from_config(&config.encoder)?;
|
let encoder = Engine::try_from_config(&config.encoder)?;
|
||||||
let decoder = Engine::try_from_config(&config.decoder)?;
|
let decoder = Engine::try_from_config(&config.decoder)?;
|
||||||
let (batch, height, width) = (
|
let (batch, height, width) = (
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
use crate::NAMES_BODY_PARTS_28;
|
use crate::NAMES_BODY_PARTS_28;
|
||||||
|
|
||||||
/// Model configuration for `Sapiens`
|
/// Model configuration for `Sapiens`
|
||||||
impl crate::ModelConfig {
|
impl crate::Config {
|
||||||
pub fn sapiens() -> Self {
|
pub fn sapiens() -> Self {
|
||||||
Self::default()
|
Self::default()
|
||||||
.with_name("sapiens")
|
.with_name("sapiens")
|
||||||
|
@ -2,7 +2,7 @@ use aksr::Builder;
|
|||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use ndarray::{s, Array2, Axis};
|
use ndarray::{s, Array2, Axis};
|
||||||
|
|
||||||
use crate::{elapsed, Engine, Image, Mask, ModelConfig, Ops, Polygon, Processor, Task, Ts, Xs, Y};
|
use crate::{elapsed, Config, Engine, Image, Mask, Ops, Polygon, Processor, Task, Ts, Xs, Y};
|
||||||
|
|
||||||
#[derive(Builder, Debug)]
|
#[derive(Builder, Debug)]
|
||||||
pub struct Sapiens {
|
pub struct Sapiens {
|
||||||
@ -18,7 +18,7 @@ pub struct Sapiens {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Sapiens {
|
impl Sapiens {
|
||||||
pub fn new(config: ModelConfig) -> Result<Self> {
|
pub fn new(config: Config) -> Result<Self> {
|
||||||
let engine = Engine::try_from_config(&config.model)?;
|
let engine = Engine::try_from_config(&config.model)?;
|
||||||
let spec = engine.spec().to_string();
|
let spec = engine.spec().to_string();
|
||||||
let (batch, height, width, ts) = (
|
let (batch, height, width, ts) = (
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/// Model configuration for `SLANet`
|
/// Model configuration for `SLANet`
|
||||||
impl crate::ModelConfig {
|
impl crate::Config {
|
||||||
pub fn slanet() -> Self {
|
pub fn slanet() -> Self {
|
||||||
Self::default()
|
Self::default()
|
||||||
.with_name("slanet")
|
.with_name("slanet")
|
||||||
|
@ -2,7 +2,7 @@ use aksr::Builder;
|
|||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use ndarray::{s, Axis};
|
use ndarray::{s, Axis};
|
||||||
|
|
||||||
use crate::{elapsed, models::BaseModelVisual, Image, Keypoint, ModelConfig, Ts, Xs, Y};
|
use crate::{elapsed, models::BaseModelVisual, Config, Image, Keypoint, Ts, Xs, Y};
|
||||||
|
|
||||||
#[derive(Builder, Debug)]
|
#[derive(Builder, Debug)]
|
||||||
pub struct SLANet {
|
pub struct SLANet {
|
||||||
@ -19,7 +19,7 @@ impl SLANet {
|
|||||||
self.ts.summary();
|
self.ts.summary();
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new(config: ModelConfig) -> Result<Self> {
|
pub fn new(config: Config) -> Result<Self> {
|
||||||
let base = BaseModelVisual::new(config)?;
|
let base = BaseModelVisual::new(config)?;
|
||||||
let spec = base.engine().spec().to_owned();
|
let spec = base.engine().spec().to_owned();
|
||||||
let sos = 0;
|
let sos = 0;
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/// Model configuration for `SmolVLM`
|
/// Model configuration for `SmolVLM`
|
||||||
impl crate::ModelConfig {
|
impl crate::Config {
|
||||||
pub fn smolvlm() -> Self {
|
pub fn smolvlm() -> Self {
|
||||||
Self::default()
|
Self::default()
|
||||||
.with_name("smolvlm")
|
.with_name("smolvlm")
|
||||||
|
@ -3,7 +3,7 @@ use anyhow::Result;
|
|||||||
use image::GenericImageView;
|
use image::GenericImageView;
|
||||||
use ndarray::s;
|
use ndarray::s;
|
||||||
|
|
||||||
use crate::{Engine, Image, LogitsSampler, ModelConfig, Processor, Scale, Ts, Xs, X, Y};
|
use crate::{Config, Engine, Image, LogitsSampler, Processor, Scale, Ts, Xs, X, Y};
|
||||||
|
|
||||||
#[derive(Debug, Builder)]
|
#[derive(Debug, Builder)]
|
||||||
pub struct SmolVLM {
|
pub struct SmolVLM {
|
||||||
@ -32,7 +32,7 @@ pub struct SmolVLM {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl SmolVLM {
|
impl SmolVLM {
|
||||||
pub fn new(config: ModelConfig) -> Result<Self> {
|
pub fn new(config: Config) -> Result<Self> {
|
||||||
let vision = Engine::try_from_config(&config.visual)?;
|
let vision = Engine::try_from_config(&config.visual)?;
|
||||||
let text_embed = Engine::try_from_config(&config.textual)?;
|
let text_embed = Engine::try_from_config(&config.textual)?;
|
||||||
let decoder = Engine::try_from_config(&config.textual_decoder_merged)?;
|
let decoder = Engine::try_from_config(&config.textual_decoder_merged)?;
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/// Model configuration for `SVTR`
|
/// Model configuration for `SVTR`
|
||||||
impl crate::ModelConfig {
|
impl crate::Config {
|
||||||
pub fn svtr() -> Self {
|
pub fn svtr() -> Self {
|
||||||
Self::default()
|
Self::default()
|
||||||
.with_name("svtr")
|
.with_name("svtr")
|
||||||
|
@ -3,7 +3,7 @@ use anyhow::Result;
|
|||||||
use ndarray::Axis;
|
use ndarray::Axis;
|
||||||
use rayon::prelude::*;
|
use rayon::prelude::*;
|
||||||
|
|
||||||
use crate::{elapsed, DynConf, Engine, Image, ModelConfig, Processor, Ts, Xs, Y};
|
use crate::{elapsed, Config, DynConf, Engine, Image, Processor, Ts, Xs, Y};
|
||||||
|
|
||||||
#[derive(Builder, Debug)]
|
#[derive(Builder, Debug)]
|
||||||
pub struct SVTR {
|
pub struct SVTR {
|
||||||
@ -18,7 +18,7 @@ pub struct SVTR {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl SVTR {
|
impl SVTR {
|
||||||
pub fn new(config: ModelConfig) -> Result<Self> {
|
pub fn new(config: Config) -> Result<Self> {
|
||||||
let engine = Engine::try_from_config(&config.model)?;
|
let engine = Engine::try_from_config(&config.model)?;
|
||||||
let (batch, height, width, ts) = (
|
let (batch, height, width, ts) = (
|
||||||
engine.batch().opt(),
|
engine.batch().opt(),
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
use crate::Scale;
|
use crate::Scale;
|
||||||
|
|
||||||
/// Model configuration for `TrOCR`
|
/// Model configuration for `TrOCR`
|
||||||
impl crate::ModelConfig {
|
impl crate::Config {
|
||||||
pub fn trocr() -> Self {
|
pub fn trocr() -> Self {
|
||||||
Self::default()
|
Self::default()
|
||||||
.with_name("trocr")
|
.with_name("trocr")
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user