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

ConverterBase.py 1.3 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
43
44
45
46
  1. import copy
  2. '''
  3. You can implement your own Converter, check example ConverterMasked.py
  4. '''
  5. class ConverterBase(object):
  6. MODE_FACE = 0
  7. MODE_IMAGE = 1
  8. MODE_IMAGE_WITH_LANDMARKS = 2
  9. #overridable
  10. def __init__(self, predictor):
  11. self.predictor = predictor
  12. #overridable
  13. def get_mode(self):
  14. #MODE_FACE calls convert_face
  15. #MODE_IMAGE calls convert_image without landmarks
  16. #MODE_IMAGE_WITH_LANDMARKS calls convert_image with landmarks
  17. return ConverterBase.MODE_FACE
  18. #overridable
  19. def convert_face (self, img_bgr, img_face_landmarks, debug):
  20. #return float32 image
  21. #if debug , return tuple ( images of any size and channels, ...)
  22. return image
  23. #overridable
  24. def convert_image (self, img_bgr, img_landmarks, debug):
  25. #img_landmarks not None, if input image is png with embedded data
  26. #return float32 image
  27. #if debug , return tuple ( images of any size and channels, ...)
  28. return image
  29. #overridable
  30. def dummy_predict(self):
  31. #do dummy predict here
  32. pass
  33. def copy(self):
  34. return copy.copy(self)
  35. def copy_and_set_predictor(self, predictor):
  36. result = self.copy()
  37. result.predictor = predictor
  38. return result
Tip!

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

Comments

Loading...