__init__.py 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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. import os
  12. import os.path as osp
  13. from ...base import BaseDatasetChecker
  14. from .dataset_src import check_dataset, convert_dataset, split_dataset, anaylse_dataset
  15. from ..model_list import MODELS
  16. class SegDatasetChecker(BaseDatasetChecker):
  17. """ Dataset Checker for Semantic Segmentation Model """
  18. entities = MODELS
  19. sample_num = 10
  20. def convert_dataset(self, src_dataset_dir: str) -> str:
  21. """convert the dataset from other type to specified type
  22. Args:
  23. src_dataset_dir (str): the root directory of dataset.
  24. Returns:
  25. str: the root directory of converted dataset.
  26. """
  27. return convert_dataset(self.check_dataset_config.src_dataset_type,
  28. src_dataset_dir)
  29. def split_dataset(self, src_dataset_dir: str) -> str:
  30. """repartition the train and validation dataset
  31. Args:
  32. src_dataset_dir (str): the root directory of dataset.
  33. Returns:
  34. str: the root directory of splited dataset.
  35. """
  36. return split_dataset(src_dataset_dir,
  37. self.check_dataset_config.split.train_percent,
  38. self.check_dataset_config.split.val_percent)
  39. def check_dataset(self, dataset_dir: str,
  40. sample_num: int=sample_num) -> dict:
  41. """check if the dataset meets the specifications and get dataset summary
  42. Args:
  43. dataset_dir (str): the root directory of dataset.
  44. sample_num (int): the number to be sampled.
  45. Returns:
  46. dict: dataset summary.
  47. """
  48. return check_dataset(dataset_dir, self.output, sample_num)
  49. def analyse(self, dataset_dir: str) -> dict:
  50. """deep analyse dataset
  51. Args:
  52. dataset_dir (str): the root directory of dataset.
  53. Returns:
  54. dict: the deep analysis results.
  55. """
  56. return anaylse_dataset(dataset_dir, self.output)
  57. def get_show_type(self) -> str:
  58. """get the show type of dataset
  59. Returns:
  60. str: show type
  61. """
  62. return "image"
  63. def get_dataset_type(self) -> str:
  64. """return the dataset type
  65. Returns:
  66. str: dataset type
  67. """
  68. return "SegDataset"