From c1ff5d1f0445248101ff592c8f9ffd79c4f8d5e8 Mon Sep 17 00:00:00 2001 From: Balearica Date: Tue, 24 Dec 2024 01:17:21 -0800 Subject: [PATCH] Disabled non-text output formats by default per #916 --- benchmarks/node/memory-benchmark.js | 2 +- docs/api.md | 3 ++- src/createWorker.js | 2 +- src/worker-script/constants/defaultOutput.js | 6 +++--- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/benchmarks/node/memory-benchmark.js b/benchmarks/node/memory-benchmark.js index 19aaea725..fb65e9bdf 100644 --- a/benchmarks/node/memory-benchmark.js +++ b/benchmarks/node/memory-benchmark.js @@ -50,7 +50,7 @@ const workerGen = async () => { const promises = []; for (let j = 0; j < 10; j++) { // Results are purposefully not saved as this would increase memory usage over time. - promises.push(scheduler.addJob('recognize', file).then(() => (true))); + promises.push(scheduler.addJob('recognize', file, {}, { blocks: true }).then(() => (true))); } // eslint-disable-next-line no-await-in-loop await Promise.all(promises); diff --git a/docs/api.md b/docs/api.md index 25608fb89..cc3f82d7d 100644 --- a/docs/api.md +++ b/docs/api.md @@ -82,7 +82,8 @@ Figures out what words are in `image`, where the words are in `image`, etc. - `image` see [Image Format](./image-format.md) for more details. - `options` an object of customized options - `rectangle` an object to specify the regions you want to recognized in the image, should contain top, left, width and height, see example below. -- `output` an object specifying which output formats to return (by default `text`, `blocks`, `hocr`, and `tsv` are returned) +- `output` an object specifying which output formats to return (by default only `text` is returned) + - Other options include `blocks` (json), `hocr`, and `tsv` - `jobId` Please see details above **Output:** diff --git a/src/createWorker.js b/src/createWorker.js index 3eb279597..f94d51865 100644 --- a/src/createWorker.js +++ b/src/createWorker.js @@ -165,7 +165,7 @@ module.exports = async (langs = 'eng', oem = OEM.LSTM_ONLY, _options = {}, confi ); const recognize = async (image, opts = {}, output = { - blocks: true, text: true, hocr: true, tsv: true, + text: true, }, jobId) => ( startJob(createJob({ id: jobId, diff --git a/src/worker-script/constants/defaultOutput.js b/src/worker-script/constants/defaultOutput.js index 0c16697b8..1f36dcab2 100644 --- a/src/worker-script/constants/defaultOutput.js +++ b/src/worker-script/constants/defaultOutput.js @@ -4,10 +4,10 @@ module.exports = { text: true, - blocks: true, + blocks: false, layoutBlocks: false, - hocr: true, - tsv: true, + hocr: false, + tsv: false, box: false, unlv: false, osd: false,