mirror of
https://github.com/mii443/usls.git
synced 2025-12-03 02:58:22 +00:00
Add some eps (#108)
This commit is contained in:
@@ -21,8 +21,8 @@ fn main() -> anyhow::Result<()> {
|
||||
|
||||
// build model
|
||||
let config = Config::ben2_base()
|
||||
.with_model_dtype(args.dtype.as_str().try_into()?)
|
||||
.with_model_device(args.device.as_str().try_into()?)
|
||||
.with_model_dtype(args.dtype.parse()?)
|
||||
.with_model_device(args.device.parse()?)
|
||||
.commit()?;
|
||||
let mut model = RMBG::new(config)?;
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ fn main() -> anyhow::Result<()> {
|
||||
|
||||
// build model
|
||||
let config = Config::blip_v1_base_caption()
|
||||
.with_device_all(args.device.as_str().try_into()?)
|
||||
.with_device_all(args.device.parse()?)
|
||||
.commit()?;
|
||||
let mut model = Blip::new(config)?;
|
||||
|
||||
|
||||
@@ -46,8 +46,8 @@ fn main() -> anyhow::Result<()> {
|
||||
};
|
||||
|
||||
let config = config
|
||||
.with_model_dtype(args.dtype.as_str().try_into()?)
|
||||
.with_model_device(args.device.as_str().try_into()?)
|
||||
.with_model_dtype(args.dtype.parse()?)
|
||||
.with_model_device(args.device.parse()?)
|
||||
.commit()?;
|
||||
let mut model = ImageClassifier::try_from(config)?;
|
||||
|
||||
|
||||
@@ -29,8 +29,8 @@ fn main() -> Result<()> {
|
||||
// clip_vit_b32()
|
||||
// jina_clip_v1()
|
||||
// jina_clip_v2()
|
||||
.with_dtype_all(args.dtype.as_str().try_into()?)
|
||||
.with_device_all(args.device.as_str().try_into()?)
|
||||
.with_dtype_all(args.dtype.parse()?)
|
||||
.with_device_all(args.device.parse()?)
|
||||
.commit()?;
|
||||
let mut model = Clip::new(config)?;
|
||||
|
||||
|
||||
@@ -47,9 +47,9 @@ fn main() -> Result<()> {
|
||||
// build model
|
||||
let config = match &args.model {
|
||||
Some(m) => Config::db().with_model_file(m),
|
||||
None => Config::ppocr_det_v5_mobile().with_model_dtype(args.dtype.as_str().try_into()?),
|
||||
None => Config::ppocr_det_v5_mobile().with_model_dtype(args.dtype.parse()?),
|
||||
}
|
||||
.with_device_all(args.device.as_str().try_into()?)
|
||||
.with_device_all(args.device.parse()?)
|
||||
.commit()?;
|
||||
let mut model = DB::new(config)?;
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ fn main() -> Result<()> {
|
||||
|
||||
// annotate
|
||||
let annotator =
|
||||
Annotator::default().with_mask_style(Style::mask().with_colormap256("turbo".into()));
|
||||
Annotator::default().with_mask_style(Style::mask().with_colormap256("turbo".parse()?));
|
||||
for (x, y) in xs.iter().zip(ys.iter()) {
|
||||
annotator.annotate(x, y)?.save(format!(
|
||||
"{}.jpg",
|
||||
|
||||
@@ -24,8 +24,8 @@ fn main() -> Result<()> {
|
||||
|
||||
// model
|
||||
let config = Config::depth_pro()
|
||||
.with_model_dtype(args.dtype.as_str().try_into()?)
|
||||
.with_model_device(args.device.as_str().try_into()?)
|
||||
.with_model_dtype(args.dtype.parse()?)
|
||||
.with_model_device(args.device.parse()?)
|
||||
.commit()?;
|
||||
|
||||
let mut model = DepthPro::new(config)?;
|
||||
@@ -38,7 +38,7 @@ fn main() -> Result<()> {
|
||||
|
||||
// annotate
|
||||
let annotator =
|
||||
Annotator::default().with_mask_style(Style::mask().with_colormap256("turbo".into()));
|
||||
Annotator::default().with_mask_style(Style::mask().with_colormap256("turbo".parse()?));
|
||||
for (x, y) in xs.iter().zip(ys.iter()) {
|
||||
annotator.annotate(x, y)?.save(format!(
|
||||
"{}.jpg",
|
||||
|
||||
@@ -19,7 +19,7 @@ fn main() -> Result<()> {
|
||||
|
||||
// build model
|
||||
let config = Config::doclayout_yolo_docstructbench()
|
||||
.with_model_device(args.device.as_str().try_into()?)
|
||||
.with_model_device(args.device.parse()?)
|
||||
.commit()?;
|
||||
let mut model = YOLO::new(config)?;
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ fn main() -> Result<()> {
|
||||
let args: Args = argh::from_env();
|
||||
|
||||
// build model
|
||||
let config = match args.scale.as_str().try_into()? {
|
||||
let config = match args.scale.parse()? {
|
||||
Scale::T => Config::fast_tiny(),
|
||||
Scale::S => Config::fast_small(),
|
||||
Scale::B => Config::fast_base(),
|
||||
@@ -34,8 +34,8 @@ fn main() -> Result<()> {
|
||||
};
|
||||
let mut model = DB::new(
|
||||
config
|
||||
.with_dtype_all(args.dtype.as_str().try_into()?)
|
||||
.with_device_all(args.device.as_str().try_into()?)
|
||||
.with_dtype_all(args.dtype.parse()?)
|
||||
.with_device_all(args.device.parse()?)
|
||||
.commit()?,
|
||||
)?;
|
||||
|
||||
|
||||
@@ -23,8 +23,8 @@ fn main() -> Result<()> {
|
||||
|
||||
// build model
|
||||
let config = Config::fastsam_s()
|
||||
.with_model_dtype(args.dtype.as_str().try_into()?)
|
||||
.with_model_device(args.device.as_str().try_into()?)
|
||||
.with_model_dtype(args.dtype.parse()?)
|
||||
.with_model_device(args.device.parse()?)
|
||||
.commit()?;
|
||||
let mut model = YOLO::new(config)?;
|
||||
|
||||
|
||||
@@ -26,8 +26,8 @@ fn main() -> Result<()> {
|
||||
|
||||
// build model
|
||||
let config = Config::florence2_base()
|
||||
.with_dtype_all(args.dtype.as_str().try_into()?)
|
||||
.with_device_all(args.device.as_str().try_into()?)
|
||||
.with_dtype_all(args.dtype.parse()?)
|
||||
.with_device_all(args.device.parse()?)
|
||||
.with_batch_size_all(xs.len())
|
||||
.commit()?;
|
||||
let mut model = Florence2::new(config)?;
|
||||
|
||||
@@ -46,8 +46,8 @@ fn main() -> Result<()> {
|
||||
let args: Args = argh::from_env();
|
||||
|
||||
let config = Config::grounding_dino_tiny()
|
||||
.with_model_dtype(args.dtype.as_str().try_into()?)
|
||||
.with_model_device(args.device.as_str().try_into()?)
|
||||
.with_model_dtype(args.dtype.parse()?)
|
||||
.with_model_device(args.device.parse()?)
|
||||
.with_text_names(&args.labels.iter().map(|x| x.as_str()).collect::<Vec<_>>())
|
||||
.with_class_confs(&[0.25])
|
||||
.with_text_confs(&[0.25])
|
||||
|
||||
@@ -27,7 +27,7 @@ fn main() -> Result<()> {
|
||||
let args: Args = argh::from_env();
|
||||
|
||||
// build model
|
||||
let config = match args.scale.as_str().try_into()? {
|
||||
let config = match args.scale.parse()? {
|
||||
Scale::T => Config::linknet_r18(),
|
||||
Scale::S => Config::linknet_r34(),
|
||||
Scale::B => Config::linknet_r50(),
|
||||
@@ -35,8 +35,8 @@ fn main() -> Result<()> {
|
||||
};
|
||||
let mut model = DB::new(
|
||||
config
|
||||
.with_model_dtype(args.dtype.as_str().try_into()?)
|
||||
.with_model_device(args.device.as_str().try_into()?)
|
||||
.with_model_dtype(args.dtype.parse()?)
|
||||
.with_model_device(args.device.parse()?)
|
||||
.commit()?,
|
||||
)?;
|
||||
|
||||
|
||||
@@ -39,13 +39,13 @@ fn main() -> Result<()> {
|
||||
let args: Args = argh::from_env();
|
||||
|
||||
// build model
|
||||
let config = match args.scale.as_str().try_into()? {
|
||||
let config = match args.scale.parse()? {
|
||||
Scale::Billion(0.5) => Config::moondream2_0_5b(),
|
||||
Scale::Billion(2.) => Config::moondream2_2b(),
|
||||
_ => unimplemented!(),
|
||||
}
|
||||
.with_dtype_all(args.dtype.as_str().try_into()?)
|
||||
.with_device_all(args.device.as_str().try_into()?)
|
||||
.with_dtype_all(args.dtype.parse()?)
|
||||
.with_device_all(args.device.parse()?)
|
||||
.commit()?;
|
||||
|
||||
let mut model = Moondream2::new(config)?;
|
||||
@@ -54,7 +54,7 @@ fn main() -> Result<()> {
|
||||
let xs = DataLoader::try_read_n(&args.source)?;
|
||||
|
||||
// run with task
|
||||
let task: Task = args.task.as_str().try_into()?;
|
||||
let task: Task = args.task.parse()?;
|
||||
let ys = model.forward(&xs, &task)?;
|
||||
|
||||
// annotate
|
||||
|
||||
@@ -49,8 +49,8 @@ fn main() -> Result<()> {
|
||||
// config
|
||||
let config = Config::owlv2_base_ensemble()
|
||||
// owlv2_base()
|
||||
.with_model_dtype(args.dtype.as_str().try_into()?)
|
||||
.with_model_device(args.device.as_str().try_into()?)
|
||||
.with_model_dtype(args.dtype.parse()?)
|
||||
.with_model_device(args.device.parse()?)
|
||||
.with_text_names(&args.labels.iter().map(|x| x.as_str()).collect::<Vec<_>>())
|
||||
.commit()?;
|
||||
let mut model = OWLv2::new(config)?;
|
||||
|
||||
@@ -31,8 +31,8 @@ fn main() -> anyhow::Result<()> {
|
||||
|
||||
// build model
|
||||
let config = config
|
||||
.with_model_dtype(args.dtype.as_str().try_into()?)
|
||||
.with_model_device(args.device.as_str().try_into()?)
|
||||
.with_model_dtype(args.dtype.parse()?)
|
||||
.with_model_device(args.device.parse()?)
|
||||
.commit()?;
|
||||
let mut model = RMBG::new(config)?;
|
||||
|
||||
|
||||
@@ -28,9 +28,9 @@ fn main() -> Result<()> {
|
||||
|
||||
let args: Args = argh::from_env();
|
||||
// Build model
|
||||
let config = match args.kind.as_str().try_into()? {
|
||||
let config = match args.kind.parse()? {
|
||||
SamKind::Sam => Config::sam_v1_base(),
|
||||
SamKind::Sam2 => match args.scale.as_str().try_into()? {
|
||||
SamKind::Sam2 => match args.scale.parse()? {
|
||||
Scale::T => Config::sam2_tiny(),
|
||||
Scale::S => Config::sam2_small(),
|
||||
Scale::B => Config::sam2_base_plus(),
|
||||
@@ -40,7 +40,7 @@ fn main() -> Result<()> {
|
||||
SamKind::SamHq => Config::sam_hq_tiny(),
|
||||
SamKind::EdgeSam => Config::edge_sam_3x(),
|
||||
}
|
||||
.with_device_all(args.device.as_str().try_into()?)
|
||||
.with_device_all(args.device.parse()?)
|
||||
.commit()?;
|
||||
|
||||
let mut model = SAM::new(config)?;
|
||||
|
||||
@@ -25,14 +25,14 @@ fn main() -> Result<()> {
|
||||
let args: Args = argh::from_env();
|
||||
|
||||
// Build model
|
||||
let config = match args.scale.as_str().try_into()? {
|
||||
let config = match args.scale.parse()? {
|
||||
Scale::T => Config::sam2_1_tiny(),
|
||||
Scale::S => Config::sam2_1_small(),
|
||||
Scale::B => Config::sam2_1_base_plus(),
|
||||
Scale::L => Config::sam2_1_large(),
|
||||
_ => 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.parse()?)
|
||||
.commit()?;
|
||||
let mut model = SAM2::new(config)?;
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ fn main() -> Result<()> {
|
||||
let args: Args = argh::from_env();
|
||||
// build
|
||||
let config = Config::sapiens_seg_0_3b()
|
||||
.with_model_device(args.device.as_str().try_into()?)
|
||||
.with_model_device(args.device.parse()?)
|
||||
.commit()?;
|
||||
let mut model = Sapiens::new(config)?;
|
||||
|
||||
|
||||
@@ -27,8 +27,8 @@ fn main() -> Result<()> {
|
||||
|
||||
// build model
|
||||
let config = Config::slanet_lcnet_v2_mobile_ch()
|
||||
.with_model_device(args.device.as_str().try_into()?)
|
||||
.with_model_dtype(args.dtype.as_str().try_into()?)
|
||||
.with_model_device(args.device.parse()?)
|
||||
.with_model_dtype(args.dtype.parse()?)
|
||||
.commit()?;
|
||||
let mut model = SLANet::new(config)?;
|
||||
|
||||
|
||||
@@ -29,12 +29,12 @@ fn main() -> Result<()> {
|
||||
let args: Args = argh::from_env();
|
||||
|
||||
// build model
|
||||
let config = match args.scale.as_str().try_into()? {
|
||||
let config = match args.scale.parse()? {
|
||||
Scale::Million(256.) => Config::smolvlm_256m(),
|
||||
Scale::Million(500.) => Config::smolvlm_500m(),
|
||||
_ => unimplemented!(),
|
||||
}
|
||||
.with_device_all(args.device.as_str().try_into()?)
|
||||
.with_device_all(args.device.parse()?)
|
||||
.commit()?;
|
||||
let mut model = SmolVLM::new(config)?;
|
||||
|
||||
|
||||
@@ -32,8 +32,8 @@ fn main() -> Result<()> {
|
||||
// ppocr_rec_v4_en()
|
||||
// repsvtr_ch()
|
||||
.with_model_ixx(0, 3, args.max_text_length.into())
|
||||
.with_model_device(args.device.as_str().try_into()?)
|
||||
.with_model_dtype(args.dtype.as_str().try_into()?)
|
||||
.with_model_device(args.device.parse()?)
|
||||
.with_model_dtype(args.dtype.parse()?)
|
||||
.commit()?;
|
||||
let mut model = SVTR::new(config)?;
|
||||
|
||||
|
||||
@@ -38,19 +38,19 @@ fn main() -> anyhow::Result<()> {
|
||||
])?;
|
||||
|
||||
// build model
|
||||
let config = match args.scale.as_str().try_into()? {
|
||||
Scale::S => match args.kind.as_str().try_into()? {
|
||||
let config = match args.scale.parse()? {
|
||||
Scale::S => match args.kind.parse()? {
|
||||
TrOCRKind::Printed => Config::trocr_small_printed(),
|
||||
TrOCRKind::HandWritten => Config::trocr_small_handwritten(),
|
||||
},
|
||||
Scale::B => match args.kind.as_str().try_into()? {
|
||||
Scale::B => match args.kind.parse()? {
|
||||
TrOCRKind::Printed => Config::trocr_base_printed(),
|
||||
TrOCRKind::HandWritten => Config::trocr_base_handwritten(),
|
||||
},
|
||||
x => anyhow::bail!("Unsupported TrOCR scale: {:?}", x),
|
||||
}
|
||||
.with_device_all(args.device.as_str().try_into()?)
|
||||
.with_dtype_all(args.dtype.as_str().try_into()?)
|
||||
.with_device_all(args.device.parse()?)
|
||||
.with_dtype_all(args.dtype.parse()?)
|
||||
.commit()?;
|
||||
|
||||
let mut model = TrOCR::new(config)?;
|
||||
|
||||
@@ -23,8 +23,8 @@ fn main() -> Result<()> {
|
||||
|
||||
// build model
|
||||
let config = Config::ultralytics_rtdetr_l()
|
||||
.with_model_dtype(args.dtype.as_str().try_into()?)
|
||||
.with_model_device(args.device.as_str().try_into()?)
|
||||
.with_model_dtype(args.dtype.parse()?)
|
||||
.with_model_device(args.device.parse()?)
|
||||
.commit()?;
|
||||
let mut model = YOLO::new(config)?;
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ fn main() -> Result<()> {
|
||||
let options_yolo = Config::yolo_detect()
|
||||
.with_scale(Scale::N)
|
||||
.with_version(8.into())
|
||||
.with_model_device(args.device.as_str().try_into()?)
|
||||
.with_model_device(args.device.parse()?)
|
||||
.commit()?;
|
||||
let mut yolo = YOLO::new(options_yolo)?;
|
||||
|
||||
|
||||
@@ -132,12 +132,12 @@ fn main() -> Result<()> {
|
||||
let args: Args = argh::from_env();
|
||||
let mut config = Config::yolo()
|
||||
.with_model_file(&args.model.unwrap_or_default())
|
||||
.with_task(args.task.as_str().try_into()?)
|
||||
.with_task(args.task.parse()?)
|
||||
.with_version(args.ver.try_into()?)
|
||||
.with_scale(args.scale.as_str().try_into()?)
|
||||
.with_model_dtype(args.dtype.as_str().try_into()?)
|
||||
.with_model_device(args.device.as_str().try_into()?)
|
||||
.with_model_trt_fp16(args.trt_fp16)
|
||||
.with_scale(args.scale.parse()?)
|
||||
.with_model_dtype(args.dtype.parse()?)
|
||||
.with_model_device(args.device.parse()?)
|
||||
.with_model_tensorrt_fp16(args.trt_fp16)
|
||||
.with_model_ixx(
|
||||
0,
|
||||
0,
|
||||
|
||||
@@ -28,8 +28,8 @@ fn main() -> Result<()> {
|
||||
// yoloe_11s_seg_pf()
|
||||
// yoloe_11m_seg_pf()
|
||||
// yoloe_11l_seg_pf()
|
||||
.with_model_dtype(args.dtype.as_str().try_into()?)
|
||||
.with_model_device(args.device.as_str().try_into()?)
|
||||
.with_model_dtype(args.dtype.as_str().parse()?)
|
||||
.with_model_device(args.device.as_str().parse()?)
|
||||
.commit()?;
|
||||
let mut model = YOLO::new(config)?;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user