MCPcopy Create free account
hub / github.com/VitoHowe/glm-coding / get_engine

Function get_engine

app/services/tenvision_adapter.py:32–58  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

30
31
32def get_engine():
33 global _engine
34 if _engine is not None:
35 return _engine
36 if RapidOCR is None:
37 raise RuntimeError('缺少 rapidocr 依赖,无法使用 catpcha_v2 识别算法。')
38
39 _engine = RapidOCR(
40 params={
41 'Det.engine_type': EngineType.ONNXRUNTIME,
42 'Det.lang_type': LangDet.CH,
43 'Det.model_type': ModelType.MOBILE,
44 'Det.ocr_version': OCRVersion.PPOCRV5,
45 'Rec.engine_type': EngineType.ONNXRUNTIME,
46 'Rec.lang_type': LangRec.CH,
47 'Rec.model_type': ModelType.MOBILE,
48 'Rec.ocr_version': OCRVersion.PPOCRV5,
49 }
50 )
51 return _engine
52
53
54def normalize_text(text):
55 return (text or '').replace(' ', '').replace('\n', '').strip()
56
57
58def extract_chinese_chars(text):
59 return [char for char in normalize_text(text) if '\u4e00' <= char <= '\u9fff']
60
61

Callers 1

run_pipeline_bytesFunction · 0.85

Calls 1

get_settingsFunction · 0.90

Tested by

no test coverage detected