mirror of
https://github.com/mii443/usls.git
synced 2025-08-22 15:45:41 +00:00
Dev (#1)
* Update imageproc crates * Add top-p method for sampling * Add SVTR for text recognition & bug fix
This commit is contained in:
@ -1,25 +1,33 @@
|
||||
use usls::{models::DB, DataLoader, Options};
|
||||
use usls::{models::DB, Annotator, DataLoader, Options};
|
||||
|
||||
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
// build model
|
||||
let options = Options::default()
|
||||
.with_model("../models/ppocr-v4-db-dyn.onnx")
|
||||
.with_i00((1, 1, 4).into())
|
||||
.with_i02((608, 640, 960).into())
|
||||
.with_i03((608, 640, 960).into())
|
||||
.with_confs(&[0.7])
|
||||
.with_saveout("DB-Text-Detection")
|
||||
.with_dry_run(5)
|
||||
.with_i00((1, 4, 8).into())
|
||||
.with_i02((608, 960, 1280).into())
|
||||
.with_i03((608, 960, 1280).into())
|
||||
.with_confs(&[0.4])
|
||||
.with_min_width(5.0)
|
||||
.with_min_height(12.0)
|
||||
// .with_trt(0)
|
||||
// .with_fp16(true)
|
||||
.with_profile(true);
|
||||
.with_model("../models/ppocr-v4-db-dyn.onnx");
|
||||
|
||||
let mut model = DB::new(&options)?;
|
||||
|
||||
// load image
|
||||
let x = DataLoader::try_read("./assets/math.jpg")?;
|
||||
let x = vec![DataLoader::try_read("./assets/db.png")?];
|
||||
|
||||
// run
|
||||
let _y = model.run(&[x])?;
|
||||
let y = model.run(&x)?;
|
||||
|
||||
// annotate
|
||||
let annotator = Annotator::default()
|
||||
.with_polygon_color([255u8, 0u8, 0u8])
|
||||
.without_name(true)
|
||||
.without_polygons(false)
|
||||
.without_bboxes(false)
|
||||
.with_saveout("DB-Text-Detection");
|
||||
annotator.annotate(&x, &y);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
Reference in New Issue
Block a user