Script 'mail_helper' called by obssrc
Hello community,

here is the log from the commit of package ocrs for openSUSE:Factory checked in 
at 2024-09-18 15:28:19
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/ocrs (Old)
 and      /work/SRC/openSUSE:Factory/.ocrs.new.29891 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "ocrs"

Wed Sep 18 15:28:19 2024 rev:4 rq:1201771 version:0.8.1

Changes:
--------
--- /work/SRC/openSUSE:Factory/ocrs/ocrs.changes        2024-06-05 
17:43:29.920505706 +0200
+++ /work/SRC/openSUSE:Factory/.ocrs.new.29891/ocrs.changes     2024-09-18 
15:29:21.043012637 +0200
@@ -1,0 +2,9 @@
+Wed Sep 18 10:11:01 UTC 2024 - Muhammad Akbar Yanuar Mantari <mantari...@pm.me>
+
+- Update to version 0.8.1:
+  * Added ability to customize the alphabet used by the recognition
+    model.
+  * Updated rten to v0.13.1. This enables running custom models in
+    the V2 rten model format
+
+-------------------------------------------------------------------

Old:
----
  ocrs-ocrs-v0.8.0.tar.gz

New:
----
  ocrs-ocrs-v0.8.1.tar.gz

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ ocrs.spec ++++++
--- /var/tmp/diff_new_pack.sTE29T/_old  2024-09-18 15:29:22.019053447 +0200
+++ /var/tmp/diff_new_pack.sTE29T/_new  2024-09-18 15:29:22.019053447 +0200
@@ -22,7 +22,7 @@
 %bcond_without test
 %endif
 Name:           ocrs
-Version:        0.8.0
+Version:        0.8.1
 Release:        0
 Summary:        A modern OCR engine written in Rust
 License:        Apache-2.0 AND MIT

++++++ ocrs-ocrs-v0.8.0.tar.gz -> ocrs-ocrs-v0.8.1.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/ocrs-ocrs-v0.8.0/.github/workflows/ci.yml 
new/ocrs-ocrs-v0.8.1/.github/workflows/ci.yml
--- old/ocrs-ocrs-v0.8.0/.github/workflows/ci.yml       2024-05-25 
10:41:11.000000000 +0200
+++ new/ocrs-ocrs-v0.8.1/.github/workflows/ci.yml       2024-09-01 
07:23:06.000000000 +0200
@@ -26,7 +26,7 @@
           target/
         key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
     - name: Install wasm-bindgen
-      run: cargo install wasm-bindgen-cli --version 0.2.89
+      run: cargo install wasm-bindgen-cli --version 0.2.93
       if: ${{ matrix.os == 'ubuntu-latest' }}
     - name: Build
       run: cargo build
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/ocrs-ocrs-v0.8.0/CHANGELOG.md 
new/ocrs-ocrs-v0.8.1/CHANGELOG.md
--- old/ocrs-ocrs-v0.8.0/CHANGELOG.md   2024-05-25 10:41:11.000000000 +0200
+++ new/ocrs-ocrs-v0.8.1/CHANGELOG.md   2024-09-01 07:23:06.000000000 +0200
@@ -5,6 +5,14 @@
 The format is based on [Keep a 
Changelog](https://keepachangelog.com/en/1.0.0/),
 and this project adheres to [Semantic 
Versioning](https://semver.org/spec/v2.0.0.html).
 
+## [0.8.1] - 2024-08-01
+
+- Added ability to customize the alphabet used by the recognition model
+  (https://github.com/robertknight/ocrs/pull/100). Thanks @Phaired.
+
+- Updated rten to v0.13.1. This enables running custom models in the V2
+  [rten model 
format](https://github.com/robertknight/rten/blob/main/docs/rten-file-format.md)
+
 ## [0.8.0] - 2024-05-25
 
 ### Breaking changes
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/ocrs-ocrs-v0.8.0/Cargo.lock 
new/ocrs-ocrs-v0.8.1/Cargo.lock
--- old/ocrs-ocrs-v0.8.0/Cargo.lock     2024-05-25 10:41:11.000000000 +0200
+++ new/ocrs-ocrs-v0.8.1/Cargo.lock     2024-09-01 07:23:06.000000000 +0200
@@ -10,9 +10,9 @@
 
 [[package]]
 name = "anyhow"
-version = "1.0.80"
+version = "1.0.86"
 source = "registry+https://github.com/rust-lang/crates.io-index";
-checksum = "5ad32ce52e4161730f7098c077cd2ed6229b5804ccf99e5366be1ab72a98b4e1"
+checksum = "b3d1d046238990b9cf5bcde22a3fb3584ee5cf65fb2765f454ed428c7a0063da"
 
 [[package]]
 name = "autocfg"
@@ -134,9 +134,9 @@
 
 [[package]]
 name = "flatbuffers"
-version = "22.12.6"
+version = "24.3.25"
 source = "registry+https://github.com/rust-lang/crates.io-index";
-checksum = "5ae1bfc84d904f75e7ef6f8796b020c606a9e8e271e2004c0a74f7edeedba45f"
+checksum = "8add37afff2d4ffa83bc748a70b4b1370984f6980768554182424ef71447c35f"
 dependencies = [
  "bitflags",
  "rustc_version",
@@ -253,6 +253,12 @@
 checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f"
 
 [[package]]
+name = "memchr"
+version = "2.7.4"
+source = "registry+https://github.com/rust-lang/crates.io-index";
+checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3"
+
+[[package]]
 name = "miniz_oxide"
 version = "0.7.1"
 source = "registry+https://github.com/rust-lang/crates.io-index";
@@ -283,7 +289,7 @@
 
 [[package]]
 name = "ocrs"
-version = "0.8.0"
+version = "0.8.1"
 dependencies = [
  "anyhow",
  "fastrand",
@@ -299,7 +305,7 @@
 
 [[package]]
 name = "ocrs-cli"
-version = "0.8.0"
+version = "0.8.1"
 dependencies = [
  "anyhow",
  "home",
@@ -329,9 +335,9 @@
 
 [[package]]
 name = "png"
-version = "0.17.10"
+version = "0.17.13"
 source = "registry+https://github.com/rust-lang/crates.io-index";
-checksum = "dd75bf2d8dd3702b9707cdbc56a5b9ef42cec752eb8b3bafc01234558442aa64"
+checksum = "06e4b0d3d1312775e782c86c91a111aa1f910cbb65e1337f9975b5f9a554b5e1"
 dependencies = [
  "bitflags",
  "crc32fast",
@@ -394,9 +400,9 @@
 
 [[package]]
 name = "rten"
-version = "0.10.0"
+version = "0.13.1"
 source = "registry+https://github.com/rust-lang/crates.io-index";
-checksum = "09c030cdf90e64c5eeeba389ca59da14b0a106b1b8366c15591251bb6a2e777f"
+checksum = "52026aa6d9bc40ac0d52bfeb4bc81d4fd5b7866825af1826ed7a4d74bd7574c4"
 dependencies = [
  "flatbuffers",
  "libm",
@@ -412,42 +418,42 @@
 
 [[package]]
 name = "rten-imageproc"
-version = "0.10.0"
+version = "0.13.1"
 source = "registry+https://github.com/rust-lang/crates.io-index";
-checksum = "5ba61077269b2b2c90445bfd55fb798dcd544b56e7fd78faaea51940b8e429ae"
+checksum = "2cbf57cb94ff55c8107d534114d23bc8116bb64d68da0927c972db150bea3279"
 dependencies = [
  "rten-tensor",
 ]
 
 [[package]]
 name = "rten-simd"
-version = "0.10.0"
+version = "0.11.0"
 source = "registry+https://github.com/rust-lang/crates.io-index";
-checksum = "8eb16da64e0d08ce56dc17d8304ab2da541176ee30430c0b0e581a7841a660ae"
+checksum = "7f1bb63fc8a157699e42a501cf43512871b20d3bea755f3ffac3ab63f1af10c4"
 
 [[package]]
 name = "rten-tensor"
-version = "0.10.0"
+version = "0.13.1"
 source = "registry+https://github.com/rust-lang/crates.io-index";
-checksum = "52f5e53d2e43bb736e89e4ea41b707e024190f8ba47c3eddf5a3c2d022089909"
+checksum = "575ec5dbc7e7059eb4271bca1c06420d240e8a377593cbac41a0c7227ec8645d"
 dependencies = [
  "smallvec",
 ]
 
 [[package]]
 name = "rten-vecmath"
-version = "0.10.0"
+version = "0.11.0"
 source = "registry+https://github.com/rust-lang/crates.io-index";
-checksum = "56eccc46a7e7a2df2cebb7ba95e613a01942a01e0f2f2f7d6122176ab7372e9f"
+checksum = "af98a4e48d69c5aa2167d3adb7a8c1585602486a1aedd1ee8b3d684f98059396"
 dependencies = [
  "rten-simd",
 ]
 
 [[package]]
 name = "rustc-hash"
-version = "1.1.0"
+version = "2.0.0"
 source = "registry+https://github.com/rust-lang/crates.io-index";
-checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2"
+checksum = "583034fd73374156e66797ed8e5b0d5690409c9226b22d87cb7f19821c05d152"
 
 [[package]]
 name = "rustc_version"
@@ -523,11 +529,12 @@
 
 [[package]]
 name = "serde_json"
-version = "1.0.116"
+version = "1.0.122"
 source = "registry+https://github.com/rust-lang/crates.io-index";
-checksum = "3e17db7126d17feb94eb3fad46bf1a96b034e8aacbc2e775fe81505f8b0b2813"
+checksum = "784b6203951c57ff748476b126ccb5e8e2959a5c19e5c617ab1956be3dbc68da"
 dependencies = [
  "itoa",
+ "memchr",
  "ryu",
  "serde",
 ]
@@ -569,18 +576,18 @@
 
 [[package]]
 name = "thiserror"
-version = "1.0.59"
+version = "1.0.63"
 source = "registry+https://github.com/rust-lang/crates.io-index";
-checksum = "f0126ad08bff79f29fc3ae6a55cc72352056dfff61e3ff8bb7129476d44b23aa"
+checksum = "c0342370b38b6a11b6cc11d6a805569958d54cfa061a29969c3b5ce2ea405724"
 dependencies = [
  "thiserror-impl",
 ]
 
 [[package]]
 name = "thiserror-impl"
-version = "1.0.59"
+version = "1.0.63"
 source = "registry+https://github.com/rust-lang/crates.io-index";
-checksum = "d1cd413b5d558b4c5bf3680e324a6fa5014e7b7c067a51e69dbdf47eb7148b66"
+checksum = "a4558b58466b9ad7ca0f102865eccc95938dca1a74a856f2b57b6629050da261"
 dependencies = [
  "proc-macro2",
  "quote",
@@ -665,19 +672,20 @@
 
 [[package]]
 name = "wasm-bindgen"
-version = "0.2.89"
+version = "0.2.93"
 source = "registry+https://github.com/rust-lang/crates.io-index";
-checksum = "0ed0d4f68a3015cc185aff4db9506a015f4b96f95303897bfa23f846db54064e"
+checksum = "a82edfc16a6c469f5f44dc7b571814045d60404b55a0ee849f9bcfa2e63dd9b5"
 dependencies = [
  "cfg-if",
+ "once_cell",
  "wasm-bindgen-macro",
 ]
 
 [[package]]
 name = "wasm-bindgen-backend"
-version = "0.2.89"
+version = "0.2.93"
 source = "registry+https://github.com/rust-lang/crates.io-index";
-checksum = "1b56f625e64f3a1084ded111c4d5f477df9f8c92df113852fa5a374dbda78826"
+checksum = "9de396da306523044d3302746f1208fa71d7532227f15e347e2d93e4145dd77b"
 dependencies = [
  "bumpalo",
  "log",
@@ -690,9 +698,9 @@
 
 [[package]]
 name = "wasm-bindgen-macro"
-version = "0.2.89"
+version = "0.2.93"
 source = "registry+https://github.com/rust-lang/crates.io-index";
-checksum = "0162dbf37223cd2afce98f3d0785506dcb8d266223983e4b5b525859e6e182b2"
+checksum = "585c4c91a46b072c92e908d99cb1dcdf95c5218eeb6f3bf1efa991ee7a68cccf"
 dependencies = [
  "quote",
  "wasm-bindgen-macro-support",
@@ -700,9 +708,9 @@
 
 [[package]]
 name = "wasm-bindgen-macro-support"
-version = "0.2.89"
+version = "0.2.93"
 source = "registry+https://github.com/rust-lang/crates.io-index";
-checksum = "f0eb82fcb7930ae6219a7ecfd55b217f5f0893484b7a13022ebb2b2bf20b5283"
+checksum = "afc340c74d9005395cf9dd098506f7f44e38f2b4a21c6aaacf9a105ea5e1e836"
 dependencies = [
  "proc-macro2",
  "quote",
@@ -713,9 +721,9 @@
 
 [[package]]
 name = "wasm-bindgen-shared"
-version = "0.2.89"
+version = "0.2.93"
 source = "registry+https://github.com/rust-lang/crates.io-index";
-checksum = "7ab9b36309365056cd639da3134bf87fa8f3d86008abf99e612384a6eecd459f"
+checksum = "c62a0a307cb4a311d3a07867860911ca130c3494e8c2719593806c08bc5d0484"
 
 [[package]]
 name = "webpki-roots"
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/ocrs-ocrs-v0.8.0/Cargo.toml 
new/ocrs-ocrs-v0.8.1/Cargo.toml
--- old/ocrs-ocrs-v0.8.0/Cargo.toml     2024-05-25 10:41:11.000000000 +0200
+++ new/ocrs-ocrs-v0.8.1/Cargo.toml     2024-09-01 07:23:06.000000000 +0200
@@ -6,6 +6,6 @@
 ]
 
 [workspace.dependencies]
-rten = { version = "0.10.0" }
-rten-imageproc = { version = "0.10.0" }
-rten-tensor = { version = "0.10.0" }
+rten = { version = "0.13.1" }
+rten-imageproc = { version = "0.13.1" }
+rten-tensor = { version = "0.13.1" }
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/ocrs-ocrs-v0.8.0/ocrs/Cargo.toml 
new/ocrs-ocrs-v0.8.1/ocrs/Cargo.toml
--- old/ocrs-ocrs-v0.8.0/ocrs/Cargo.toml        2024-05-25 10:41:11.000000000 
+0200
+++ new/ocrs-ocrs-v0.8.1/ocrs/Cargo.toml        2024-09-01 07:23:06.000000000 
+0200
@@ -1,6 +1,6 @@
 [package]
 name = "ocrs"
-version = "0.8.0"
+version = "0.8.1"
 edition = "2021"
 authors = ["Robert Knight"]
 description = "OCR engine"
@@ -9,17 +9,17 @@
 repository = "https://github.com/robertknight/ocrs";
 
 [dependencies]
-anyhow = "1.0.80"
+anyhow = "1.0.86"
 rayon = "1.10.0"
 rten = { workspace = true }
 rten-imageproc = { workspace = true }
 rten-tensor = { workspace = true }
-thiserror = "1.0.59"
+thiserror = "1.0.63"
 
 [target.'cfg(target_arch = "wasm32")'.dependencies]
 # nb. When changing this, make sure the version of wasm-bindgen-cli installed
 # in CI etc. is in sync.
-wasm-bindgen = "0.2.89"
+wasm-bindgen = "0.2.93"
 
 [dev-dependencies]
 fastrand = "2.1.0"
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/ocrs-ocrs-v0.8.0/ocrs/src/lib.rs 
new/ocrs-ocrs-v0.8.1/ocrs/src/lib.rs
--- old/ocrs-ocrs-v0.8.0/ocrs/src/lib.rs        2024-05-25 10:41:11.000000000 
+0200
+++ new/ocrs-ocrs-v0.8.1/ocrs/src/lib.rs        2024-09-01 07:23:06.000000000 
+0200
@@ -29,6 +29,9 @@
 pub use recognition::DecodeMethod;
 pub use text_items::{TextChar, TextItem, TextLine, TextWord};
 
+// nb. The "E" before "ABCDE" should be the EUR symbol.
+const DEFAULT_ALPHABET: &str = " 
0123456789!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~EABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
+
 /// Configuration for an [OcrEngine] instance.
 #[derive(Default)]
 pub struct OcrEngineParams {
@@ -36,6 +39,9 @@
     pub detection_model: Option<Model>,
 
     /// Model used to recognize lines of text in the image.
+    ///
+    /// If using a custom model, you may need to adjust the
+    /// [`alphabet`](Self::alphabet) to match.
     pub recognition_model: Option<Model>,
 
     /// Enable debug logging.
@@ -43,6 +49,14 @@
 
     /// Method used to decode outputs of text recognition model.
     pub decode_method: DecodeMethod,
+
+    /// Alphabet used for text recognition.
+    ///
+    /// This is useful if you are using a custom recognition model with a
+    /// modified alphabet. If not specified a default alphabet will be used
+    /// which matches the one used to train the [original
+    /// models](https://github.com/robertknight/ocrs-models).
+    pub alphabet: Option<String>,
 }
 
 /// Detects and recognizes text in images.
@@ -54,6 +68,7 @@
     recognizer: Option<TextRecognizer>,
     debug: bool,
     decode_method: DecodeMethod,
+    alphabet: String,
 }
 
 /// Input image for OCR analysis. Instances are created using
@@ -79,6 +94,9 @@
             recognizer,
             debug: params.debug,
             decode_method: params.decode_method,
+            alphabet: params
+                .alphabet
+                .unwrap_or_else(|| DEFAULT_ALPHABET.to_string()),
         })
     }
 
@@ -149,6 +167,7 @@
                 RecognitionOpt {
                     debug: self.debug,
                     decode_method: self.decode_method,
+                    alphabet: self.alphabet.clone(),
                 },
             )
         } else {
@@ -205,7 +224,7 @@
 mod tests {
     use std::error::Error;
 
-    use rten::model_builder::{ModelBuilder, OpType};
+    use rten::model_builder::{ModelBuilder, ModelFormat, OpType};
     use rten::ops::{MaxPool, Transpose};
     use rten::Dimension;
     use rten::Model;
@@ -240,8 +259,10 @@
     /// Takes a CHW input tensor with values in `[-0.5, 0.5]` and adds a +0.5
     /// bias to produce an output "probability map".
     fn fake_detection_model() -> Model {
-        let mut mb = ModelBuilder::new();
-        let input_id = mb.add_value(
+        let mut mb = ModelBuilder::new(ModelFormat::V1);
+        let mut gb = mb.graph_builder();
+
+        let input_id = gb.add_value(
             "input",
             Some(&[
                 Dimension::Symbolic("batch".to_string()),
@@ -252,20 +273,23 @@
                 Dimension::Fixed(100),
             ]),
         );
-        mb.add_input(input_id);
+        gb.add_input(input_id);
 
-        let output_id = mb.add_value("output", None);
-        mb.add_output(output_id);
+        let output_id = gb.add_value("output", None);
+        gb.add_output(output_id);
 
         let bias = Tensor::from_scalar(0.5);
-        let bias_id = mb.add_float_constant(&bias);
-        mb.add_operator(
+        let bias_id = gb.add_constant(bias.view());
+        gb.add_operator(
             "add",
             OpType::Add,
             &[Some(input_id), Some(bias_id)],
             &[output_id],
         );
 
+        let graph = gb.finish();
+        mb.set_graph(graph);
+
         let model_data = mb.finish();
         Model::load(model_data).unwrap()
     }
@@ -277,8 +301,10 @@
     /// log-probability of each class label. In this fake we just re-interpret
     /// each column of the input as a one-hot vector of probabilities.
     fn fake_recognition_model() -> Model {
-        let mut mb = ModelBuilder::new();
-        let input_id = mb.add_value(
+        let mut mb = ModelBuilder::new(ModelFormat::V1);
+        let mut gb = mb.graph_builder();
+
+        let input_id = gb.add_value(
             "input",
             Some(&[
                 Dimension::Symbolic("batch".to_string()),
@@ -287,11 +313,11 @@
                 Dimension::Symbolic("seq".to_string()),
             ]),
         );
-        mb.add_input(input_id);
+        gb.add_input(input_id);
 
         // MaxPool to scale width by 1/4: NCHW => NCHW/4
-        let pool_out = mb.add_value("max_pool_out", None);
-        mb.add_operator(
+        let pool_out = gb.add_value("max_pool_out", None);
+        gb.add_operator(
             "max_pool",
             OpType::MaxPool(MaxPool {
                 kernel_size: [1, 4],
@@ -304,9 +330,9 @@
 
         // Squeeze to remove the channel dim: NCHW/4 => NHW/4
         let squeeze_axes = Tensor::from_vec(vec![1]);
-        let squeeze_axes_id = mb.add_int_constant(&squeeze_axes);
-        let squeeze_out = mb.add_value("squeeze_out", None);
-        mb.add_operator(
+        let squeeze_axes_id = gb.add_constant(squeeze_axes.view());
+        let squeeze_out = gb.add_value("squeeze_out", None);
+        gb.add_operator(
             "squeeze",
             OpType::Squeeze,
             &[Some(pool_out), Some(squeeze_axes_id)],
@@ -314,8 +340,8 @@
         );
 
         // Transpose: NHW/4 => W/4NH
-        let transpose_out = mb.add_value("transpose_out", None);
-        mb.add_operator(
+        let transpose_out = gb.add_value("transpose_out", None);
+        gb.add_operator(
             "transpose",
             OpType::Transpose(Transpose {
                 perm: Some(vec![2, 0, 1]),
@@ -324,7 +350,10 @@
             &[transpose_out],
         );
 
-        mb.add_output(transpose_out);
+        gb.add_output(transpose_out);
+        let graph = gb.finish();
+
+        mb.set_graph(graph);
 
         let model_data = mb.finish();
         Model::load(model_data).unwrap()
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/ocrs-ocrs-v0.8.0/ocrs/src/recognition.rs 
new/ocrs-ocrs-v0.8.1/ocrs/src/recognition.rs
--- old/ocrs-ocrs-v0.8.0/ocrs/src/recognition.rs        2024-05-25 
10:41:11.000000000 +0200
+++ new/ocrs-ocrs-v0.8.1/ocrs/src/recognition.rs        2024-09-01 
07:23:06.000000000 +0200
@@ -15,9 +15,6 @@
 use crate::preprocess::BLACK_VALUE;
 use crate::text_items::{TextChar, TextLine};
 
-// nb. The "E" before "ABCDE" should be the EUR symbol.
-const DEFAULT_ALPHABET: &str = " 
0123456789!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~EABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
-
 /// Return the smallest multiple of `factor` that is >= `val`.
 fn round_up<
     T: Copy
@@ -226,6 +223,8 @@
 
     /// Method used to decode character sequence outputs to character values.
     pub decode_method: DecodeMethod,
+
+    pub alphabet: String,
 }
 
 /// Input and output from recognition for a single text line.
@@ -250,13 +249,15 @@
 /// for each line.
 ///
 /// Entries in the result may be `None` if no text was recognized for a line.
-fn text_lines_from_recognition_results(results: &[LineRecResult]) -> 
Vec<Option<TextLine>> {
+fn text_lines_from_recognition_results(
+    results: &[LineRecResult],
+    alphabet: &str,
+) -> Vec<Option<TextLine>> {
     results
         .iter()
         .map(|result| {
             let line_rect = result.line.region.bounding_rect();
             let x_scale_factor = (line_rect.width() as f32) / 
(result.line.resized_width as f32);
-
             // Calculate how much the recognition model downscales the image
             // width. We assume this will be an integer factor, or close to it
             // if the input width is not an exact multiple of the downscaling
@@ -289,7 +290,7 @@
                         return None;
                     }
 
-                    let char = DEFAULT_ALPHABET
+                    let char = alphabet
                         .chars()
                         .nth((step.label - 1) as usize)
                         .unwrap_or('?');
@@ -364,7 +365,11 @@
         let input: Tensor<f32> = input.into();
         let [output] = self
             .model
-            .run_n(&[(self.input_id, (&input).into())], [self.output_id], None)
+            .run_n(
+                vec![(self.input_id, (&input).into())],
+                [self.output_id],
+                None,
+            )
             .map_err(|err| ModelRunError::RunFailed(err.into()))?;
         let mut rec_sequence: NdTensor<f32, 3> =
             output.try_into().map_err(|_| ModelRunError::WrongOutput)?;
@@ -426,6 +431,7 @@
         let RecognitionOpt {
             debug,
             decode_method,
+            alphabet,
         } = opts;
 
         let [_, img_height, img_width] = image.shape();
@@ -531,7 +537,7 @@
         // batching and parallel processing. Re-sort them into input order.
         line_rec_results.sort_by_key(|result| result.line.index);
 
-        let text_lines = 
text_lines_from_recognition_results(&line_rec_results);
+        let text_lines = 
text_lines_from_recognition_results(&line_rec_results, &alphabet);
 
         Ok(text_lines)
     }
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/ocrs-ocrs-v0.8.0/ocrs-cli/Cargo.toml 
new/ocrs-ocrs-v0.8.1/ocrs-cli/Cargo.toml
--- old/ocrs-ocrs-v0.8.0/ocrs-cli/Cargo.toml    2024-05-25 10:41:11.000000000 
+0200
+++ new/ocrs-ocrs-v0.8.1/ocrs-cli/Cargo.toml    2024-09-01 07:23:06.000000000 
+0200
@@ -1,6 +1,6 @@
 [package]
 name = "ocrs-cli"
-version = "0.8.0"
+version = "0.8.1"
 edition = "2021"
 authors = ["Robert Knight"]
 description = "OCR CLI tool for extracting text from images"
@@ -10,15 +10,15 @@
 
 [dependencies]
 image = { version = "0.25.1", default-features = false, features = ["png", 
"jpeg", "webp"] }
-png = "0.17.6"
-serde_json = "1.0.116"
+png = "0.17.13"
+serde_json = "1.0.122"
 rten = { workspace = true }
 rten-imageproc = { workspace = true }
 rten-tensor = { workspace = true }
-ocrs = { path = "../ocrs", version = "0.8.0" }
+ocrs = { path = "../ocrs", version = "0.8.1" }
 lexopt = "0.3.0"
 url = "2.4.0"
-anyhow = "1.0.79"
+anyhow = "1.0.86"
 
 [target.'cfg(not(target_arch = "wasm32"))'.dependencies]
 ureq = "2.9.7"
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/ocrs-ocrs-v0.8.0/ocrs-cli/src/main.rs 
new/ocrs-ocrs-v0.8.1/ocrs-cli/src/main.rs
--- old/ocrs-ocrs-v0.8.0/ocrs-cli/src/main.rs   2024-05-25 10:41:11.000000000 
+0200
+++ new/ocrs-ocrs-v0.8.1/ocrs-cli/src/main.rs   2024-09-01 07:23:06.000000000 
+0200
@@ -283,6 +283,7 @@
         } else {
             DecodeMethod::Greedy
         },
+        ..Default::default()
     })?;
 
     // Read image into HWC tensor.

++++++ vendor.tar.zst ++++++
/work/SRC/openSUSE:Factory/ocrs/vendor.tar.zst 
/work/SRC/openSUSE:Factory/.ocrs.new.29891/vendor.tar.zst differ: char 7, line 1

Reply via email to