問題描述
Tesseract Worker.Load 掛在 Vercel 上 (Tesseract Worker.Load hangs on Vercel)
不確定是否有人可以提供幫助,但我在我的 Next JS 應用程序中使用 Tesseract.js 在我的本地站點上有一個 OCR 閱讀器。它在本地和讀取 smy 圖像上工作正常,但是當我部署到 Vercel 時它掛在這條線上....
await worker.load()
這就是全部內容
const worker = createWorker()
console.log('createWorker')
//attempt ocr on processed image
await worker.load()
console.log('worker.load')
//set language to plain english
await worker.loadLanguage('eng')
await worker.initialize('eng')
//set character whitelist and disable dictionary functions that won't help us here
await worker.setParameters({
tessedit_char_whitelist:
'0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz‑/$.@| ',
load_system_dawg: 0,
load_freq_dawg: 0,
})
console.log('setParameters')
//process editted image
const OcrResult = await worker.recognize(imageb64)
if (process.env.DEBUG >= 1) {
console.log('[DEBUG] OCR: Process complete, results: ', OcrResult.data.text)
}
關於 Vercel 的任何怪癖會使它無法在測試站點上運行嗎?
謝謝
參考解法
方法 1:
You might try using something like this instead, designed to use in lambda functions.
https://github.com/shelfio/aws‑lambda‑tesseract