From 3982586db478cb919368574fd25aa35a2609909b Mon Sep 17 00:00:00 2001 From: awtkns <32209255+awtkns@users.noreply.github.com> Date: Sat, 11 Nov 2023 11:38:29 -0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=A7=B9=20Cleanup=20readme?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 4 ++++ tarsier/ocr/google.py | 10 +++++++--- tests/ocr/test_google.py | 12 ++++++++++++ 3 files changed, 23 insertions(+), 3 deletions(-) create mode 100644 tests/ocr/test_google.py diff --git a/README.md b/README.md index ad580801..cb759017 100644 --- a/README.md +++ b/README.md @@ -75,6 +75,10 @@ async def main(): if __name__ == '__main__': asyncio.run(main()) ``` +## Supported OCR Services +- [x] [Google Cloud Vision](https://cloud.google.com/vision) +- [ ] [Amazon Textract](https://aws.amazon.com/textract/) (Coming Soon) +- [ ] [Microsoft Azure Computer Vision](https://azure.microsoft.com/en-us/services/cognitive-services/computer-vision/) (Coming Soon) ## Roadmap - [x] Add documentation and examples diff --git a/tarsier/ocr/google.py b/tarsier/ocr/google.py index eb6f492e..8124d8b8 100644 --- a/tarsier/ocr/google.py +++ b/tarsier/ocr/google.py @@ -1,9 +1,9 @@ -from typing import Any, Dict, List +from typing import Any, Dict from google.cloud import vision from tarsier.ocr._base import OCRService -from tarsier.ocr.types import ImageAnnotation, ImageAnnotatorResponse +from tarsier.ocr.types import ImageAnnotatorResponse class GoogleVisionOCRService(OCRService): @@ -13,7 +13,11 @@ def __init__(self, credentials: Dict[str, Any]): credentials ) except Exception: # TODO: specify exception - raise ValueError("OCR client creation from credentials failed.") + raise ValueError( + "OCR client creation from credentials failed.\n" + "Google your google cloud vision credentials can be created here:\n" + "https://console.cloud.google.com/apis/api/vision.googleapis.com" + ) text_detection = vision.Feature() text_detection.type_ = vision.Feature.Type.TEXT_DETECTION # type: ignore diff --git a/tests/ocr/test_google.py b/tests/ocr/test_google.py new file mode 100644 index 00000000..f8d62ca8 --- /dev/null +++ b/tests/ocr/test_google.py @@ -0,0 +1,12 @@ +import pytest + +from tarsier import GoogleVisionOCRService + + +def test_invalid_credentials(): + with pytest.raises(ValueError): + GoogleVisionOCRService( + { + "type": "service_account", + } + )