Skip to content

Commit

Permalink
🧹 Cleanup readme
Browse files Browse the repository at this point in the history
  • Loading branch information
awtkns committed Nov 11, 2023
1 parent eb04dc0 commit 3982586
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 3 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 7 additions & 3 deletions tarsier/ocr/google.py
Original file line number Diff line number Diff line change
@@ -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):
Expand All @@ -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
Expand Down
12 changes: 12 additions & 0 deletions tests/ocr/test_google.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import pytest

from tarsier import GoogleVisionOCRService


def test_invalid_credentials():
with pytest.raises(ValueError):
GoogleVisionOCRService(
{
"type": "service_account",
}
)

0 comments on commit 3982586

Please sign in to comment.