Spaces:
Sleeping
Sleeping
Update utility/utils.py
Browse files- utility/utils.py +13 -4
utility/utils.py
CHANGED
|
@@ -21,6 +21,7 @@ logging.basicConfig(
|
|
| 21 |
)
|
| 22 |
|
| 23 |
# Set the PaddleOCR home directory to a writable location
|
|
|
|
| 24 |
|
| 25 |
os.environ['PADDLEOCR_HOME'] = '/tmp/.paddleocr'
|
| 26 |
|
|
@@ -109,11 +110,19 @@ def ocr_with_paddle(img):
|
|
| 109 |
# Initialize PaddleOCR
|
| 110 |
ocr = PaddleOCR(
|
| 111 |
lang='en',
|
| 112 |
-
use_angle_cls=
|
| 113 |
-
det_model_dir=os.path.join(os.environ['PADDLEOCR_HOME'], 'whl/det'),
|
| 114 |
-
rec_model_dir=os.path.join(os.environ['PADDLEOCR_HOME'], 'whl/rec/en/en_PP-OCRv4_rec_infer'),
|
| 115 |
-
cls_model_dir=os.path.join(os.environ['PADDLEOCR_HOME'], 'whl/cls/ch_ppocr_mobile_v2.0_cls_infer')
|
| 116 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 117 |
|
| 118 |
# Check if img is a file path or an image array
|
| 119 |
if isinstance(img, str):
|
|
|
|
| 21 |
)
|
| 22 |
|
| 23 |
# Set the PaddleOCR home directory to a writable location
|
| 24 |
+
import os
|
| 25 |
|
| 26 |
os.environ['PADDLEOCR_HOME'] = '/tmp/.paddleocr'
|
| 27 |
|
|
|
|
| 110 |
# Initialize PaddleOCR
|
| 111 |
ocr = PaddleOCR(
|
| 112 |
lang='en',
|
| 113 |
+
use_angle_cls=False
|
| 114 |
+
# det_model_dir=os.path.join(os.environ['PADDLEOCR_HOME'], 'whl/det'),
|
| 115 |
+
# rec_model_dir=os.path.join(os.environ['PADDLEOCR_HOME'], 'whl/rec/en/en_PP-OCRv4_rec_infer'),
|
| 116 |
+
# cls_model_dir=os.path.join(os.environ['PADDLEOCR_HOME'], 'whl/cls/ch_ppocr_mobile_v2.0_cls_infer')
|
| 117 |
)
|
| 118 |
+
# ocr = PaddleOCR(
|
| 119 |
+
# use_angle_cls=True,
|
| 120 |
+
# lang='en',
|
| 121 |
+
# det_model_dir='/app/paddleocr_models/whl/det/ch_ppocr_mobile_v2.0_det_infer',
|
| 122 |
+
# rec_model_dir='/app/paddleocr_models/whl/rec/ch_ppocr_mobile_v2.0_rec_infer',
|
| 123 |
+
# cls_model_dir='/app/paddleocr_models/whl/cls/ch_ppocr_mobile_v2.0_cls_infer'
|
| 124 |
+
# )
|
| 125 |
+
|
| 126 |
|
| 127 |
# Check if img is a file path or an image array
|
| 128 |
if isinstance(img, str):
|