CodexParas commited on
Commit
15387ca
·
verified ·
1 Parent(s): aa59c8e

Upload README.md with huggingface_hub

Browse files
Files changed (1) hide show
  1. README.md +13 -10
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 inference on an image:
40
 
41
  ```python
42
  from paddleocr import PaddleOCR
43
- import cv2
44
 
45
- # Initialize the OCR engine with the custom model
46
- # Note: Since this is a detection-only model, we use it as the 'det_model_dir'
47
- ocr = PaddleOCR(
48
- det_model_dir='path/to/downloaded/model/', # Path to the folder containing .pdiparams
49
- use_angle_cls=False,
50
- lang='en',
51
- use_gpu=False # Set to True if you have a GPU
 
 
 
52
  )
53
 
54
  img_path = 'car_image.jpg'
55
- result = ocr.ocr(img_path, det=True, rec=False)
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: