mirror of
https://github.com/mii443/usls.git
synced 2025-12-03 02:58:22 +00:00
Add PPOCRv5 DET and REC models (#98)
* Add PPOCRv5 DET and REC models * Add Text Struct
This commit is contained in:
@@ -28,9 +28,13 @@ struct Args {
|
||||
#[argh(option, default = "false")]
|
||||
show_hbbs_conf: bool,
|
||||
|
||||
/// show mbrs confidence
|
||||
/// show obbs confidence
|
||||
#[argh(option, default = "false")]
|
||||
show_obbs_conf: bool,
|
||||
|
||||
/// show polygons confidence
|
||||
#[argh(option, default = "false")]
|
||||
show_polygons_conf: bool,
|
||||
}
|
||||
|
||||
fn main() -> Result<()> {
|
||||
@@ -43,7 +47,7 @@ fn main() -> Result<()> {
|
||||
// build model
|
||||
let config = match &args.model {
|
||||
Some(m) => Config::db().with_model_file(m),
|
||||
None => Config::ppocr_det_v4_ch().with_model_dtype(args.dtype.as_str().try_into()?),
|
||||
None => Config::ppocr_det_v5_mobile().with_model_dtype(args.dtype.as_str().try_into()?),
|
||||
}
|
||||
.with_device_all(args.device.as_str().try_into()?)
|
||||
.commit()?;
|
||||
@@ -66,16 +70,16 @@ fn main() -> Result<()> {
|
||||
.with_polygon_style(
|
||||
Style::polygon()
|
||||
.with_visible(true)
|
||||
.with_text_visible(false)
|
||||
.show_confidence(true)
|
||||
.show_id(true)
|
||||
.show_name(true)
|
||||
.with_text_visible(true)
|
||||
.show_confidence(args.show_polygons_conf)
|
||||
.show_id(false)
|
||||
.show_name(false)
|
||||
.with_color(usls::StyleColors::default().with_outline([255, 105, 180, 255].into())),
|
||||
)
|
||||
.with_hbb_style(
|
||||
Style::hbb()
|
||||
.with_visible(args.show_hbbs)
|
||||
.with_text_visible(false)
|
||||
.with_text_visible(true)
|
||||
.with_thickness(1)
|
||||
.show_confidence(args.show_hbbs_conf)
|
||||
.show_id(false)
|
||||
@@ -84,7 +88,7 @@ fn main() -> Result<()> {
|
||||
.with_obb_style(
|
||||
Style::obb()
|
||||
.with_visible(args.show_obbs)
|
||||
.with_text_visible(false)
|
||||
.with_text_visible(true)
|
||||
.show_confidence(args.show_obbs_conf)
|
||||
.show_id(false)
|
||||
.show_name(false),
|
||||
|
||||
@@ -47,7 +47,7 @@ fn main() -> Result<()> {
|
||||
for y in ys.iter() {
|
||||
if let Some(texts) = y.texts() {
|
||||
for text in texts {
|
||||
println!("[User]: {}\n\n[Assistant]:{}", args.prompt, text);
|
||||
println!("[User]: {}\n\n[Assistant]:{:?}", args.prompt, text);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,15 +7,14 @@ cargo run -r -F cuda --example svtr -- --device cuda
|
||||
## Results
|
||||
|
||||
```shell
|
||||
["./examples/svtr/images/license-ch-2.png"]: Ys([Y { Texts: [Text("粤A·68688")] }])
|
||||
["./examples/svtr/images/license-ch.png"]: Ys([Y { Texts: [Text("冀B6G000")] }])
|
||||
["./examples/svtr/images/sign-ch-2.png"]: Ys([Y { Texts: [Text("我在南锣鼓捣猫呢")] }])
|
||||
["./examples/svtr/images/sign-ch.png"]: Ys([Y { Texts: [Text("小菊儿胡同71号")] }])
|
||||
["./examples/svtr/images/text-110022345.png"]: Ys([Y { Texts: [Text("110022345")] }])
|
||||
["./examples/svtr/images/text-ch.png"]: Ys([Y { Texts: [Text("你有这么高速运转的机械进入中国,记住我给出的原理")] }])
|
||||
["./examples/svtr/images/text-en-2.png"]: Ys([Y { Texts: [Text("from the background, but also separate text instances which")] }])
|
||||
["./examples/svtr/images/text-en-dark.png"]: Ys([Y { Texts: [Text("Please lower your volume")] }])
|
||||
["./examples/svtr/images/text-en.png"]: Ys([Y { Texts: [Text("are closely jointed. Some examples are illustrated in Fig.7.")] }])
|
||||
["./examples/svtr/images/text-hello-rust-handwritten.png"]: Ys([Y { Texts: [Text("HeloRuSt")] }])
|
||||
|
||||
```
|
||||
ys: [Y { Texts: [Text { text: "粤A68688", confidence: 0.9940011 }] }]
|
||||
ys: [Y { Texts: [Text { text: "冀B6G000", confidence: 0.86073524 }] }]
|
||||
ys: [Y { Texts: [Text { text: "我在南锣鼓捣猫呢", confidence: 0.99346924 }] }]
|
||||
ys: [Y { Texts: [Text { text: "小菊儿胡同71号", confidence: 0.99450684 }] }]
|
||||
ys: [Y { Texts: [Text { text: "110022345", confidence: 0.99994576 }] }]
|
||||
ys: [Y { Texts: [Text { text: "你有这么高速运转的机械进入中国,记住我给出的原理", confidence: 0.9996338 }] }]
|
||||
ys: [Y { Texts: [Text { text: "from the background, but also separate text instances which", confidence: 0.9954648 }] }]
|
||||
ys: [Y { Texts: [Text { text: "Please lower your yolume", confidence: 0.93910724 }] }]
|
||||
ys: [Y { Texts: [Text { text: "are closely jointed. Some examples are illustrated in Fig.7.", confidence: 0.9959717 }] }]
|
||||
ys: [Y { Texts: [Text { text: "HelloRust", confidence: 0.97661674 }] }]
|
||||
```
|
||||
|
||||
@@ -11,6 +11,10 @@ struct Args {
|
||||
/// dtype
|
||||
#[argh(option, default = "String::from(\"auto\")")]
|
||||
dtype: String,
|
||||
|
||||
/// max text length
|
||||
#[argh(option, default = "960")]
|
||||
max_text_length: usize,
|
||||
}
|
||||
|
||||
fn main() -> Result<()> {
|
||||
@@ -22,9 +26,12 @@ fn main() -> Result<()> {
|
||||
let args: Args = argh::from_env();
|
||||
|
||||
// build model
|
||||
let config = Config::ppocr_rec_v4_ch()
|
||||
let config = Config::ppocr_rec_v5_mobile()
|
||||
// ppocr_rec_v5_server()
|
||||
// ppocr_rec_v4_ch()
|
||||
// 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()?)
|
||||
.commit()?;
|
||||
|
||||
Reference in New Issue
Block a user