mirror of
https://github.com/mii443/usls.git
synced 2025-08-22 15:45:41 +00:00
Add DB model for text detection
This commit is contained in:
39
examples/db/README.md
Normal file
39
examples/db/README.md
Normal file
@ -0,0 +1,39 @@
|
||||
## Quick Start
|
||||
|
||||
```shell
|
||||
cargo run -r --example db
|
||||
```
|
||||
|
||||
## Or you can manully
|
||||
|
||||
### 1. Donwload ONNX Model
|
||||
|
||||
[ppocr-v3-db-dyn](https://github.com/jamjamjon/assets/releases/download/v0.0.1/ppocr-v3-db-dyn.onnx)
|
||||
[ppocr-v4-db-dyn](https://github.com/jamjamjon/assets/releases/download/v0.0.1/ppocr-v4-db-dyn.onnx)
|
||||
|
||||
### 2. Specify the ONNX model path in `main.rs`
|
||||
|
||||
```Rust
|
||||
let options = Options::default()
|
||||
.with_model("ONNX_PATH") // <= modify this
|
||||
.with_profile(false);
|
||||
```
|
||||
|
||||
### 3. Run
|
||||
|
||||
```bash
|
||||
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 |
|
||||
|
||||
***Test on RTX3060***
|
||||
|
||||
## Results
|
||||
|
||||

|
BIN
examples/db/demo.jpg
Normal file
BIN
examples/db/demo.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 68 KiB |
25
examples/db/main.rs
Normal file
25
examples/db/main.rs
Normal file
@ -0,0 +1,25 @@
|
||||
use usls::{models::DB, 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_trt(0)
|
||||
// .with_fp16(true)
|
||||
.with_profile(true);
|
||||
let mut model = DB::new(&options)?;
|
||||
|
||||
// load image
|
||||
let x = DataLoader::try_read("./assets/math.jpg")?;
|
||||
|
||||
// run
|
||||
let _y = model.run(&[x])?;
|
||||
|
||||
Ok(())
|
||||
}
|
Reference in New Issue
Block a user