mirror of
https://gitlab.com/MrFry/mrfrys-node-server
synced 2025-04-01 20:24:18 +02:00
tesseract worker restart to aviod memory leak
This commit is contained in:
@@ -287,14 +287,16 @@ function createQuestion(
|
||||
async function recognizeQuestionImage(question: Question): Promise<Question> {
|
||||
const base64Data = question.data.base64
|
||||
if (Array.isArray(base64Data) && base64Data.length) {
|
||||
try {
|
||||
const res: string[] = []
|
||||
for (let i = 0; i < base64Data.length; i++) {
|
||||
const base64 = base64Data[i]
|
||||
const text = await recognizeTextFromBase64(base64)
|
||||
const res: string[] = []
|
||||
for (let i = 0; i < base64Data.length; i++) {
|
||||
const base64 = base64Data[i]
|
||||
const text = await recognizeTextFromBase64(base64)
|
||||
if (text && text.trim()) {
|
||||
res.push(text)
|
||||
}
|
||||
}
|
||||
|
||||
if (res.length) {
|
||||
return {
|
||||
...question,
|
||||
Q: res.join(' '),
|
||||
@@ -303,9 +305,6 @@ async function recognizeQuestionImage(question: Question): Promise<Question> {
|
||||
type: 'simple',
|
||||
},
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('Error happened in recognizeQuestionImage!')
|
||||
console.error(e)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -972,5 +971,4 @@ export {
|
||||
dataToString,
|
||||
doSearch,
|
||||
setNoPossibleAnswersPenalties,
|
||||
recognizeQuestionImage,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user