__init__.py 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. # -*- coding: utf-8 -*-
  2. # 修复 uniface 内部导入路径
  3. import sys
  4. import os
  5. # 获取当前文件所在目录(digitalHuman/uniface)
  6. _current_dir = os.path.dirname(os.path.abspath(__file__))
  7. # 获取 digitalHuman 目录
  8. _digital_human_dir = os.path.dirname(_current_dir)
  9. # 将 digitalHuman 目录添加到 sys.path,这样 uniface 内部的导入可以正常工作
  10. # 因为 uniface 内部使用 from uniface.xxx,需要让 uniface 作为顶级包
  11. if _digital_human_dir not in sys.path:
  12. sys.path.insert(0, _digital_human_dir)
  13. # 现在导入 uniface 的公共接口(使用相对导入以避免路径问题)
  14. from .face_utils import compute_similarity, face_alignment
  15. from .log import Logger, enable_logging
  16. from .model_store import verify_model_weights
  17. from .visualization import draw_detections
  18. from .analyzer import FaceAnalyzer
  19. from .attribute import AgeGender
  20. from .face import Face
  21. try:
  22. from .attribute import Emotion
  23. except ImportError:
  24. Emotion = None # PyTorch not installed
  25. from .detection import (
  26. SCRFD,
  27. RetinaFace,
  28. create_detector,
  29. detect_faces,
  30. list_available_detectors,
  31. )
  32. from .landmark import Landmark106, create_landmarker
  33. from .recognition import ArcFace, MobileFace, SphereFace, create_recognizer
  34. __all__ = [
  35. '__author__',
  36. '__license__',
  37. '__version__',
  38. # Core classes
  39. 'Face',
  40. 'FaceAnalyzer',
  41. # Factory functions
  42. 'create_detector',
  43. 'create_landmarker',
  44. 'create_recognizer',
  45. 'detect_faces',
  46. 'list_available_detectors',
  47. # Detection models
  48. 'RetinaFace',
  49. 'SCRFD',
  50. # Recognition models
  51. 'ArcFace',
  52. 'MobileFace',
  53. 'SphereFace',
  54. # Landmark models
  55. 'Landmark106',
  56. # Attribute models
  57. 'AgeGender',
  58. 'Emotion',
  59. # Utilities
  60. 'compute_similarity',
  61. 'draw_detections',
  62. 'face_alignment',
  63. 'verify_model_weights',
  64. 'Logger',
  65. 'enable_logging',
  66. ]