| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091 |
- # !/usr/bin/env python3
- # -*- coding: UTF-8 -*-
- ################################################################################
- #
- # Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved
- #
- ################################################################################
- """
- Author: PaddlePaddle Authors
- """
- import os
- import os.path as osp
- from collections import defaultdict, Counter
- from PIL import Image
- import json
- from ...base import BaseDatasetChecker
- from .dataset_src import check, convert, split_dataset, deep_analyse
- from ..model_list import MODELS
- class TSADDatasetChecker(BaseDatasetChecker):
- """Dataset Checker for TS Anomaly Detection Model
- """
- entities = MODELS
- sample_num = 10
- def convert_dataset(self, src_dataset_dir: str) -> str:
- """convert the dataset from other type to specified type
- Args:
- src_dataset_dir (str): the root directory of dataset.
- Returns:
- str: the root directory of converted dataset.
- """
- return convert(src_dataset_dir)
- def split_dataset(self, src_dataset_dir: str) -> str:
- """repartition the train and validation dataset
- Args:
- src_dataset_dir (str): the root directory of dataset.
- Returns:
- str: the root directory of splited dataset.
- """
- return split_dataset(src_dataset_dir,
- self.check_dataset_config.split.train_percent,
- self.check_dataset_config.split.val_percent)
- def check_dataset(self, dataset_dir: str,
- sample_num: int=sample_num) -> dict:
- """check if the dataset meets the specifications and get dataset summary
- Args:
- dataset_dir (str): the root directory of dataset.
- sample_num (int): the number to be sampled.
- Returns:
- dict: dataset summary.
- """
- return check(dataset_dir, self.output)
- def analyse(self, dataset_dir: str) -> dict:
- """deep analyse dataset
- Args:
- dataset_dir (str): the root directory of dataset.
- Returns:
- dict: the deep analysis results.
- """
- return deep_analyse(dataset_dir, self.output)
- def get_show_type(self) -> str:
- """get the show type of dataset
- Returns:
- str: show type
- """
- return "csv"
- def get_dataset_type(self) -> str:
- """return the dataset type
- Returns:
- str: dataset type
- """
- return "TSADDataset"
|