Handle OneOCR errors
This commit is contained in:
@@ -35,7 +35,7 @@ Additionally:
|
||||
- Apple Vision framework: this will work on macOS Ventura or later. In my experience, the best of the local providers for horizontal text ("a" key)
|
||||
- Apple Live Text (VisionKit framework): this will work on macOS Ventura or later. It should be the same as Vision except that in Sonoma Apple added vertical text reading ("d" key)
|
||||
- WinRT OCR: install with `pip install owocr[winocr]` on Windows 10 and later. It can also be used by installing winocr on a Windows virtual machine and running the server there (`winocr_serve`) and specifying the IP address of the Windows VM/machine in the config file ("w" key)
|
||||
- OneOCR: install with `pip install owocr[oneocr]` on Windows 10 and later. In my experience it's pretty good, though not as much as the Apple one. You need to copy 3 system files from Windows 11 to use it, refer to the readme (here)[https://github.com/AuroraWright/oneocr] ("z" key)
|
||||
- OneOCR: install with `pip install owocr[oneocr]` on Windows 10 and later. In my experience it's pretty good, though not as much as the Apple one. You need to copy 3 system files from Windows 11 to use it, refer to the readme [here](https://github.com/AuroraWright/oneocr) ("z" key)
|
||||
|
||||
## Cloud providers
|
||||
- Google Lens: Google Vision in disguise (no need for API keys!), install with `pip install owocr[lens]` ("l" key)
|
||||
|
||||
15
owocr/ocr.py
15
owocr/ocr.py
@@ -730,9 +730,13 @@ class OneOCR:
|
||||
elif 'oneocr' not in sys.modules:
|
||||
logger.warning('oneocr not available, OneOCR will not work!')
|
||||
else:
|
||||
self.model = oneocr.OcrEngine()
|
||||
self.available = True
|
||||
logger.info('OneOCR ready')
|
||||
try:
|
||||
self.model = oneocr.OcrEngine()
|
||||
except RuntimeError as e:
|
||||
logger.warning(e + ' , OneOCR will not work!')
|
||||
else:
|
||||
self.available = True
|
||||
logger.info('OneOCR ready')
|
||||
else:
|
||||
try:
|
||||
self.url = config['url']
|
||||
@@ -750,7 +754,10 @@ class OneOCR:
|
||||
raise ValueError(f'img_or_path must be a path or PIL.Image, instead got: {img_or_path}')
|
||||
|
||||
if sys.platform == 'win32':
|
||||
res = self.model.recognize_pil(img)['text']
|
||||
try:
|
||||
res = self.model.recognize_pil(img)['text']
|
||||
except RuntimeError as e:
|
||||
return (False, e)
|
||||
else:
|
||||
try:
|
||||
res = requests.post(self.url, data=self._preprocess(img), timeout=3)
|
||||
|
||||
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
||||
|
||||
[project]
|
||||
name = "owocr"
|
||||
version = "1.13.2"
|
||||
version = "1.13.5"
|
||||
description = "Japanese OCR"
|
||||
readme = "README.md"
|
||||
requires-python = ">=3.11"
|
||||
|
||||
Reference in New Issue
Block a user