Update README.md
Browse files
README.md
CHANGED
@@ -83,6 +83,29 @@ with torch.inference_mode():
|
|
83 |
print(result_text)
|
84 |
```
|
85 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
86 |
# Load model in 4bits
|
87 |
```python
|
88 |
|
|
|
83 |
print(result_text)
|
84 |
```
|
85 |
|
86 |
+
## Get OCR Image boxes
|
87 |
+
```python
|
88 |
+
from paddleocr import PaddleOCR, draw_ocr
|
89 |
+
from ast import literal_eval
|
90 |
+
import json
|
91 |
+
|
92 |
+
paddleocr = PaddleOCR(lang="en",ocr_version="PP-OCRv4",show_log = False,use_gpu=True)
|
93 |
+
|
94 |
+
def paddle_scan(paddleocr,img_path_or_nparray):
|
95 |
+
result = paddleocr.ocr(img_path_or_nparray,cls=True)
|
96 |
+
result = result[0]
|
97 |
+
boxes = [line[0] for line in result] #boundign box
|
98 |
+
txts = [line[1][0] for line in result] #raw text
|
99 |
+
scores = [line[1][1] for line in result] # scores
|
100 |
+
return txts, result
|
101 |
+
|
102 |
+
# perform ocr scan
|
103 |
+
receipt_texts, receipt_boxes = paddle_scan(paddleocr,receipt_image_array)
|
104 |
+
print(50*"--","\ntext only:\n",receipt_texts)
|
105 |
+
print(50*"--","\nocr boxes:\n",receipt_boxes)
|
106 |
+
|
107 |
+
```
|
108 |
+
|
109 |
# Load model in 4bits
|
110 |
```python
|
111 |
|