dddd_server.py 754 B

12345678910111213141516171819202122232425
  1. import os
  2. import pathlib
  3. root_dir = pathlib.Path(__file__).resolve().parent.parent
  4. onnx_path = os.path.join(root_dir, 'geeked', 'models', 'geetest_v4_icon.onnx')
  5. charsets_path = os.path.join(root_dir, 'geeked', 'models', 'charsets.json')
  6. class DdddService:
  7. def __init__(self):
  8. import ddddocr
  9. self.det = ddddocr.DdddOcr(det=True, show_ad=False)
  10. self.cnn = ddddocr.DdddOcr(det=False, ocr=False,
  11. show_ad=False,
  12. import_onnx_path=onnx_path,
  13. charsets_path=charsets_path)
  14. def detection(self, img):
  15. return self.det.detection(img)
  16. def classification(self, img):
  17. return self.cnn.classification(img)