Upload README.md with huggingface_hub
Browse files
README.md
CHANGED
|
@@ -36,23 +36,26 @@ pip install paddlepaddle paddleocr
|
|
| 36 |
```
|
| 37 |
|
| 38 |
### 2. Inference Code
|
| 39 |
-
You can use the following snippet to run
|
| 40 |
|
| 41 |
```python
|
| 42 |
from paddleocr import PaddleOCR
|
| 43 |
-
import
|
| 44 |
|
| 45 |
-
#
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
|
|
|
|
|
|
|
|
|
| 52 |
)
|
| 53 |
|
| 54 |
img_path = 'car_image.jpg'
|
| 55 |
-
result =
|
| 56 |
|
| 57 |
# Visualize results
|
| 58 |
for line in result:
|
|
|
|
| 36 |
```
|
| 37 |
|
| 38 |
### 2. Inference Code
|
| 39 |
+
You can use the following snippet to run detection on an image:
|
| 40 |
|
| 41 |
```python
|
| 42 |
from paddleocr import PaddleOCR
|
| 43 |
+
from pathlib import Path
|
| 44 |
|
| 45 |
+
# Path to the directory containing the downloaded model files
|
| 46 |
+
MODELS_DIR = Path("path/to/models")
|
| 47 |
+
|
| 48 |
+
# Initialize the OCR engine
|
| 49 |
+
pp_v4 = PaddleOCR(
|
| 50 |
+
use_textline_orientation=True,
|
| 51 |
+
lang='en',
|
| 52 |
+
device='cpu',
|
| 53 |
+
text_detection_model_dir=str(MODELS_DIR / "ppocr_v4"),
|
| 54 |
+
text_detection_model_name="PP-OCRv4_mobile_det"
|
| 55 |
)
|
| 56 |
|
| 57 |
img_path = 'car_image.jpg'
|
| 58 |
+
result = pp_v4.ocr(img_path, det=True, rec=False)
|
| 59 |
|
| 60 |
# Visualize results
|
| 61 |
for line in result:
|