Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

easy_ocr.py 1.1 KB

You have to be logged in to leave a comment. Sign In
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
  1. import dagshub
  2. import mlflow
  3. conda_env = {'channels': ['defaults'],
  4. 'dependencies': [
  5. 'python~=3.12',
  6. 'pip',
  7. {'pip': ['mlflow',
  8. 'easyocr']}],
  9. 'name': 'env'}
  10. class EasyOCR(mlflow.pyfunc.PythonModel):
  11. def __init__(self):
  12. super().__init__()
  13. import easyocr
  14. self.easyocr = easyocr
  15. def load_context(self, context):
  16. self.model = self.easyocr.Reader(['mn','en'])
  17. def predict(self, context, model_input):
  18. if type(model_input) == list:
  19. res = []
  20. for filepath in model_input:
  21. res.append(self.model.readtext(filepath))
  22. return res
  23. else: return self.model.readtext(model_input)
  24. if __name__ == '__main__':
  25. dagshub.init('autolabelling-models', 'jinensetpal')
  26. model = EasyOCR()
  27. with mlflow.start_run():
  28. mlflow.pyfunc.log_model(
  29. artifact_path='models',
  30. python_model=model,
  31. conda_env=conda_env,
  32. registered_model_name='easy_ocr')
Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...