evaluator.py 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. # !/usr/bin/env python3
  2. # -*- coding: UTF-8 -*-
  3. ################################################################################
  4. #
  5. # Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved
  6. #
  7. ################################################################################
  8. """
  9. Author: PaddlePaddle Authors
  10. """
  11. from pathlib import Path
  12. from ..base import BaseEvaluator
  13. from .model_list import MODELS
  14. class SegEvaluator(BaseEvaluator):
  15. """ Semantic Segmentation Model Evaluator """
  16. entities = MODELS
  17. def update_config(self):
  18. """update evalution config
  19. """
  20. self.pdx_config.update_dataset(self.global_config.dataset_dir,
  21. "SegDataset")
  22. self.pdx_config.update_pretrained_weights(None, is_backbone=True)
  23. def get_config_path(self, weight_path):
  24. """
  25. get config path
  26. Args:
  27. weight_path (str): The path to the weight
  28. Returns:
  29. config_path (str): The path to the config
  30. """
  31. config_path = Path(weight_path).parent.parent / "config.yaml"
  32. return config_path
  33. def get_eval_kwargs(self) -> dict:
  34. """get key-value arguments of model evalution function
  35. Returns:
  36. dict: the arguments of evaluation function.
  37. """
  38. return {
  39. "weight_path": self.eval_config.weight_path,
  40. "device": self.get_device(),
  41. }