Skip to content

Commit

Permalink
fix: svtr decode bug (#8)
Browse files Browse the repository at this point in the history
  • Loading branch information
oatiz authored Apr 17, 2024
1 parent a86000d commit 91049fc
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 4 deletions.
5 changes: 3 additions & 2 deletions examples/svtr/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@ cargo run -r --example svtr
## Results

```shell
[Texts] from the background, but also separate text instances which
[Texts] are closely jointed. Some examples are illustrated in Fig.7.
[Texts] from the background, but also separate text instances which
[Texts] are closely jointed. Some examples are illustrated in Fig.7.
[Texts] 你有这么高速运转的机械进入中国,记住我给出的原理
[Texts] 110022345
[Texts] 冀B6G000
```
5 changes: 3 additions & 2 deletions examples/svtr/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
// build model
let options = Options::default()
.with_i00((1, 2, 8).into())
.with_i03((320, 1500, 2200).into())
.with_confs(&[0.6])
.with_i03((320, 960, 1600).into())
.with_confs(&[0.4])
.with_vocab("../ppocr_rec_vocab.txt")
.with_model("../models/ppocr-v4-svtr-ch-dyn.onnx");
let mut model = SVTR::new(&options)?;
Expand All @@ -16,6 +16,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
DataLoader::try_read("./examples/svtr/text2.png")?,
DataLoader::try_read("./examples/svtr/text3.png")?,
DataLoader::try_read("./examples/svtr/text4.png")?,
DataLoader::try_read("./examples/svtr/text5.png")?,
];

// run
Expand Down
Binary file added examples/svtr/text5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions src/models/svtr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ impl SVTR {
}

if idx == 0 || idx == self.vocab.len() - 1 {
text_ids.push(*text_id);
return text_ids;
}

Expand Down

0 comments on commit 91049fc

Please sign in to comment.