__init__.py 2.4 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 collections import defaultdict, Counter
  14. import json
  15. from ...base import BaseDatasetChecker
  16. from .dataset_src import check, split_dataset, deep_analyse
  17. from ..model_list import MODELS
  18. class TextDetDatasetChecker(BaseDatasetChecker):
  19. """Dataset Checker for Text Detection Model
  20. """
  21. entities = MODELS
  22. def convert_dataset(self, src_dataset_dir: str) -> str:
  23. """convert the dataset from other type to specified type
  24. Args:
  25. src_dataset_dir (str): the root directory of dataset.
  26. Returns:
  27. str: the root directory of converted dataset.
  28. """
  29. return src_dataset_dir
  30. def split_dataset(self, src_dataset_dir: str) -> str:
  31. """repartition the train and validation dataset
  32. Args:
  33. src_dataset_dir (str): the root directory of dataset.
  34. Returns:
  35. str: the root directory of splited dataset.
  36. """
  37. return split_dataset(src_dataset_dir,
  38. self.check_dataset_config.split.train_percent,
  39. self.check_dataset_config.split.val_percent)
  40. def check_dataset(self, dataset_dir: str) -> 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. Returns:
  45. dict: dataset summary.
  46. """
  47. return check(dataset_dir, self.global_config.output, sample_num=10)
  48. def analyse(self, dataset_dir: str) -> dict:
  49. """deep analyse dataset
  50. Args:
  51. dataset_dir (str): the root directory of dataset.
  52. Returns:
  53. dict: the deep analysis results.
  54. """
  55. return deep_analyse(dataset_dir, self.output)
  56. def get_show_type(self) -> str:
  57. """get the show type of dataset
  58. Returns:
  59. str: show type
  60. """
  61. return "image"
  62. def get_dataset_type(self) -> str:
  63. """return the dataset type
  64. Returns:
  65. str: dataset type
  66. """
  67. return "TextDetDataset"