config.py 834 B

1234567891011121314151617181920212223242526272829303132333435
  1. import os
  2. import ppmatting
  3. current_path = os.path.abspath(os.path.dirname(__file__))
  4. def get_rel_path(path: str):
  5. return os.path.join(current_path, '..', path)
  6. class MattingModel:
  7. path = ""
  8. config = ""
  9. model = None
  10. transforms: ppmatting.transforms.Compose
  11. init = False
  12. def __init__(self, p, c):
  13. self.path = get_rel_path(p)
  14. self.config = get_rel_path(c)
  15. _model: MattingModel
  16. modelDict = {
  17. "ppmattingv2": MattingModel("models/ppmattingv2-stdc1-human_512.pdparams",
  18. "configs/ppmattingv2/ppmattingv2-stdc1-human_512.yml"),
  19. "ppmatting": MattingModel("models/ppmatting-hrnet_w18-human_512.pdparams",
  20. "configs/quick_start/ppmattingv2-stdc1-human_512.yml")
  21. }
  22. def get_model():
  23. return modelDict.get("ppmattingv2")