fix: align paddleocr init with new api
Browse files
app.py
CHANGED
|
@@ -4,6 +4,7 @@ from typing import Any, Dict, List, Optional, Sequence
|
|
| 4 |
|
| 5 |
import gradio as gr
|
| 6 |
import numpy as np
|
|
|
|
| 7 |
import torch
|
| 8 |
from PIL import Image, ImageDraw
|
| 9 |
from paddleocr import PaddleOCR
|
|
@@ -17,11 +18,17 @@ LLM_MODEL_ID = "Qwen/Qwen2.5-1.5B-Instruct"
|
|
| 17 |
|
| 18 |
def _load_ocr():
|
| 19 |
use_gpu = torch.cuda.is_available()
|
|
|
|
|
|
|
| 20 |
return PaddleOCR(
|
| 21 |
-
use_angle_cls=True,
|
| 22 |
lang=OCR_LANGS[0],
|
|
|
|
| 23 |
show_log=False,
|
| 24 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 25 |
)
|
| 26 |
|
| 27 |
|
|
|
|
| 4 |
|
| 5 |
import gradio as gr
|
| 6 |
import numpy as np
|
| 7 |
+
import paddle
|
| 8 |
import torch
|
| 9 |
from PIL import Image, ImageDraw
|
| 10 |
from paddleocr import PaddleOCR
|
|
|
|
| 18 |
|
| 19 |
def _load_ocr():
|
| 20 |
use_gpu = torch.cuda.is_available()
|
| 21 |
+
device = "gpu" if use_gpu else "cpu"
|
| 22 |
+
paddle.device.set_device(device)
|
| 23 |
return PaddleOCR(
|
|
|
|
| 24 |
lang=OCR_LANGS[0],
|
| 25 |
+
use_textline_orientation=True,
|
| 26 |
show_log=False,
|
| 27 |
+
det_limit_side_len=2048,
|
| 28 |
+
use_mp=False,
|
| 29 |
+
det_db_box_thresh=0.5,
|
| 30 |
+
rec_algorithm="SVTR_LCNet",
|
| 31 |
+
det_algorithm="DB",
|
| 32 |
)
|
| 33 |
|
| 34 |
|