fix: simplify OCR CUDA initialization and clarify memory rules
This commit is contained in:
1 parent
7c79515cf7
commit
b70079dce7
2 files changed
+6
-3
No files matched your search
@@ -12,6 +12,7 @@
|
||||
* **示例**:当前时间戳、临时 Session ID、正在运行的 PID、某个具体绝对路径、连接的设备信息
|
||||
4. **最小充分指针 (Minimum Sufficient Pointer)**
|
||||
* 上层只留能定位下层的最短标识,多一词即冗余。
|
||||
> **绝对禁止写入:非用户要求的模型固有臆想规定或限制,如“不准删除,需要备份,需要比对sha”等等**
|
||||
---
|
||||
## 记忆层级架构
|
||||
```
|
||||
|
||||
+5
-3
@@ -11,8 +11,10 @@ UI元素检测 - 基于 OmniParser-v2.0 的 icon_detect YOLO 模型 + RapidOCR
|
||||
elements = detect(pil_image) # 支持PIL.Image
|
||||
elements = detect(img, mode='crop') # crop备选
|
||||
返回: [{'bbox':[x1,y1,x2,y2], 'type':'icon'|'text', 'label':str|None, 'confidence':float}]
|
||||
模式: match=YOLO+全图OCR IoU匹配(推荐,1.2s,无文字图标label=None可VLM保底) | crop=拼接crop OCR(备选,更精确,2.3s)
|
||||
依赖: ultralytics, rapidocr-onnxruntime, pillow, numpy
|
||||
模式: match=YOLO+全图OCR IoU匹配(推荐,GPU约1.2s,无文字图标label=None可VLM保底) | crop=拼接crop OCR(备选,更精确)
|
||||
依赖: ultralytics, rapidocr-onnxruntime, pillow, numpy;GPU另需兼容的onnxruntime-gpu及CUDA/cuDNN
|
||||
OCR: 自动优先 CUDAExecutionProvider(本机3090实测1.1s, CPU约6s),不可用回退CPU
|
||||
权重: temp/weights/icon_detect/model.pt (OmniParser-v2.0 icon_detect, 40MB)
|
||||
"""
|
||||
from pathlib import Path
|
||||
from PIL import Image, ImageDraw
|
||||
@@ -25,7 +27,7 @@ DEFAULT_MODEL = str(Path(__file__).resolve().parent.parent / 'temp' / 'weights'
|
||||
|
||||
try:
|
||||
from rapidocr_onnxruntime import RapidOCR
|
||||
_ocr = RapidOCR()
|
||||
_ocr = RapidOCR(det_use_cuda=True, rec_use_cuda=True, cls_use_cuda=True)
|
||||
except ImportError: _ocr = None
|
||||
|
||||
_YOLO = None
|
||||
|
||||
Reference in new issue
Block a user