update docs
Browse files- README.md +23 -16
- notebook.ipynb +0 -0
- test.jpg +0 -0
README.md
CHANGED
@@ -17,27 +17,34 @@ https://github.com/mindee/doctr
|
|
17 |
### Example usage:
|
18 |
|
19 |
```python
|
20 |
-
>>> from doctr.io import DocumentFile
|
21 |
-
>>> from doctr.models import ocr_predictor, from_hub
|
22 |
|
23 |
-
|
24 |
-
|
25 |
-
>>> model = from_hub('mindee/my-model')
|
26 |
|
27 |
-
|
28 |
-
|
29 |
-
>>> predictor = ocr_predictor(det_arch='db_mobilenet_v3_large',
|
30 |
-
>>> reco_arch=model,
|
31 |
-
>>> pretrained=True)
|
32 |
|
33 |
-
|
34 |
-
|
35 |
-
>>> reco_arch='crnn_mobilenet_v3_small',
|
36 |
-
>>> pretrained=True)
|
37 |
|
38 |
-
|
39 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
40 |
```
|
|
|
41 |
### Run Configuration
|
42 |
|
43 |
{
|
|
|
17 |
### Example usage:
|
18 |
|
19 |
```python
|
|
|
|
|
20 |
|
21 |
+
from doctr.io import DocumentFile
|
22 |
+
from doctr.models import ocr_predictor, from_hub
|
|
|
23 |
|
24 |
+
reco_arch = from_hub('diversen/doctr-torch-crnn_vgg16_bn-danish-v1')
|
25 |
+
det_arch = "db_resnet50"
|
|
|
|
|
|
|
26 |
|
27 |
+
model = ocr_predictor(det_arch=det_arch, reco_arch=reco_arch, pretrained=True)
|
28 |
+
image = DocumentFile.from_images(['test.jpg'])
|
|
|
|
|
29 |
|
30 |
+
result = model(image)
|
31 |
+
result.show()
|
32 |
+
|
33 |
+
output = result.export()
|
34 |
+
text_str = ""
|
35 |
+
|
36 |
+
for block in output["pages"][0]["blocks"]:
|
37 |
+
block_txt = ""
|
38 |
+
for line in block["lines"]:
|
39 |
+
line_txt = ""
|
40 |
+
for word in line["words"]:
|
41 |
+
line_txt += word["value"] + " "
|
42 |
+
block_txt += line_txt + "\n"
|
43 |
+
text_str += block_txt + "\n"
|
44 |
+
|
45 |
+
print(text_str)
|
46 |
```
|
47 |
+
|
48 |
### Run Configuration
|
49 |
|
50 |
{
|
notebook.ipynb
ADDED
The diff for this file is too large to render.
See raw diff
|
|
test.jpg
ADDED