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:
@ -16,7 +16,6 @@ cargo run -r --example db
|
||||
```Rust
|
||||
let options = Options::default()
|
||||
.with_model("ONNX_PATH") // <= modify this
|
||||
.with_profile(false);
|
||||
```
|
||||
|
||||
### 3. Run
|
||||
@ -27,10 +26,10 @@ cargo run -r --example db
|
||||
|
||||
### Speed test
|
||||
|
||||
| Model | Image size | TensorRT<br />f16 | TensorRT<br />f32 | CUDA<br />f32 |
|
||||
| --------------- | ---------- | ----------------- | ----------------- | ------------- |
|
||||
| ppocr-v3-db-dyn | 640x640 | 1.8585ms | 2.5739ms | 4.3314ms |
|
||||
| ppocr-v4-db-dyn | 640x640 | 2.0507ms | 2.8264ms | 6.6064ms |
|
||||
| Model | Image size | TensorRT<br />f16<br />batch=1<br />(ms) | TensorRT<br />f32<br />batch=1<br />(ms) | CUDA<br />f32<br />batch=1<br />(ms) |
|
||||
| --------------- | ---------- | ---------------------------------------- | ---------------------------------------- | ------------------------------------ |
|
||||
| ppocr-v3-db-dyn | 640x640 | 1.8585 | 2.5739 | 4.3314 |
|
||||
| ppocr-v4-db-dyn | 640x640 | 2.0507 | 2.8264 | 6.6064 |
|
||||
|
||||
***Test on RTX3060***
|
||||
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 68 KiB After Width: | Height: | Size: 165 KiB |
@ -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