-
Notifications
You must be signed in to change notification settings - Fork 478
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'mindee:main' into main
Showing
10 changed files
with
118 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
# Template for your OCR API using docTR | ||
|
||
## Installation | ||
|
||
You will only need to install [Git](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git) and [Docker](https://docs.docker.com/get-docker/). The container environment will be self-sufficient and install the remaining dependencies on its own. | ||
|
||
## Usage | ||
|
||
### Starting your web server | ||
|
||
You will need to clone the repository first: | ||
```shell | ||
git clone https://github.com/mindee/doctr.git | ||
``` | ||
then from the repo root folder, you can start your container: | ||
|
||
```shell | ||
PORT=8050 docker-compose up -d --build | ||
``` | ||
Once completed, your [FastAPI](https://fastapi.tiangolo.com/) server should be running on port 8050 (feel free to change this in the previous command). | ||
|
||
### Documentation and swagger | ||
|
||
FastAPI comes with many advantages including speed and OpenAPI features. For instance, once your server is running, you can access the automatically built documentation and swagger in your browser at: http://localhost:8050/docs | ||
|
||
|
||
### Using the routes | ||
|
||
You will find detailed instructions in the live documentation when your server is up, but here are some examples to use your available API routes: | ||
|
||
#### Text detection | ||
|
||
Using the following image: | ||
<img src="https://user-images.githubusercontent.com/76527547/117319856-fc35bf00-ae8b-11eb-9b51-ca5aba673466.jpg" width="50%" height="50%"> | ||
|
||
with this snippet: | ||
|
||
```python | ||
import requests | ||
with open('/path/to/your/img.jpg', 'rb') as f: | ||
data = f.read() | ||
print(requests.post("http://localhost:8050/detection", files={'file': data}).json()) | ||
``` | ||
|
||
should yield | ||
``` | ||
[{'box': [0.826171875, 0.185546875, 0.90234375, 0.201171875]}, | ||
{'box': [0.75390625, 0.185546875, 0.8173828125, 0.201171875]}] | ||
``` | ||
|
||
|
||
#### Text recognition | ||
|
||
Using the following image: | ||
 | ||
|
||
with this snippet: | ||
|
||
```python | ||
import requests | ||
with open('/path/to/your/img.jpg', 'rb') as f: | ||
data = f.read() | ||
print(requests.post("http://localhost:8050/recognition", files={'file': data}).json()) | ||
``` | ||
|
||
should yield | ||
``` | ||
{'value': 'invite'} | ||
``` | ||
|
||
|
||
#### End-to-end OCR | ||
|
||
Using the following image: | ||
<img src="https://user-images.githubusercontent.com/76527547/117319856-fc35bf00-ae8b-11eb-9b51-ca5aba673466.jpg" width="50%" height="50%"> | ||
|
||
with this snippet: | ||
|
||
```python | ||
import requests | ||
with open('/path/to/your/img.jpg', 'rb') as f: | ||
data = f.read() | ||
print(requests.post("http://localhost:8050/ocr", files={'file': data}).json()) | ||
``` | ||
|
||
should yield | ||
``` | ||
[{'box': [0.75390625, 0.185546875, 0.8173828125, 0.201171875], | ||
'value': 'Hello'}, | ||
{'box': [0.826171875, 0.185546875, 0.90234375, 0.201171875], | ||
'value': 'world!'}] | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,6 +31,7 @@ Main Features | |
:hidden: | ||
|
||
installing | ||
notebooks | ||
|
||
|
||
Model zoo | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../notebooks/README.md |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# docTR Notebooks | ||
|
||
Here are some notebooks compiled for users to better leverage the library capabilities: | ||
|
||
| Notebook | Description | | | ||
|:----------|:-------------|------:| | ||
| [Quicktour](https://github.com/mindee/notebooks/blob/main/doctr/quicktour.ipynb) | A presentation of the main features of docTR | [](https://colab.research.google.com/github/mindee/notebooks/blob/main/doctr/quicktour.ipynb) | | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters