__init__.py 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. # copyright (c) 2024 PaddlePaddle Authors. All Rights Reserve.
  2. #
  3. # Licensed under the Apache License, Version 2.0 (the "License");
  4. # you may not use this file except in compliance with the License.
  5. # You may obtain a copy of the License at
  6. #
  7. # http://www.apache.org/licenses/LICENSE-2.0
  8. #
  9. # Unless required by applicable law or agreed to in writing, software
  10. # distributed under the License is distributed on an "AS IS" BASIS,
  11. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. # See the License for the specific language governing permissions and
  13. # limitations under the License.
  14. import os
  15. import os.path as osp
  16. from collections import defaultdict, Counter
  17. import json
  18. from ...base import BaseDatasetChecker
  19. from .dataset_src import check, split_dataset, deep_analyse
  20. from ..support_models import SUPPORT_MODELS
  21. class TextDetDatasetChecker(BaseDatasetChecker):
  22. """Dataset Checker for Text Detection Model
  23. """
  24. support_models = SUPPORT_MODELS
  25. def convert_dataset(self, src_dataset_dir: str) -> str:
  26. """convert the dataset from other type to specified type
  27. Args:
  28. src_dataset_dir (str): the root directory of dataset.
  29. Returns:
  30. str: the root directory of converted dataset.
  31. """
  32. return src_dataset_dir
  33. def split_dataset(self, src_dataset_dir: str) -> str:
  34. """repartition the train and validation dataset
  35. Args:
  36. src_dataset_dir (str): the root directory of dataset.
  37. Returns:
  38. str: the root directory of splited dataset.
  39. """
  40. return split_dataset(src_dataset_dir,
  41. self.check_dataset_config.split.train_percent,
  42. self.check_dataset_config.split.val_percent)
  43. def check_dataset(self, dataset_dir: str) -> dict:
  44. """check if the dataset meets the specifications and get dataset summary
  45. Args:
  46. dataset_dir (str): the root directory of dataset.
  47. Returns:
  48. dict: dataset summary.
  49. """
  50. return check(dataset_dir, self.global_config.output, sample_num=10)
  51. def analyse(self, dataset_dir: str) -> dict:
  52. """deep analyse dataset
  53. Args:
  54. dataset_dir (str): the root directory of dataset.
  55. Returns:
  56. dict: the deep analysis results.
  57. """
  58. return deep_analyse(dataset_dir, self.output_dir)
  59. def get_show_type(self) -> str:
  60. """get the show type of dataset
  61. Returns:
  62. str: show type
  63. """
  64. return "image"
  65. def get_dataset_type(self) -> str:
  66. """return the dataset type
  67. Returns:
  68. str: dataset type
  69. """
  70. return "TextDetDataset"