split.py 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. #!/usr/bin/env python
  2. # coding: utf-8
  3. # Copyright (c) 2020 PaddlePaddle Authors. All Rights Reserved.
  4. #
  5. # Licensed under the Apache License, Version 2.0 (the "License");
  6. # you may not use this file except in compliance with the License.
  7. # You may obtain a copy of the License at
  8. #
  9. # http://www.apache.org/licenses/LICENSE-2.0
  10. #
  11. # Unless required by applicable law or agreed to in writing, software
  12. # distributed under the License is distributed on an "AS IS" BASIS,
  13. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. # See the License for the specific language governing permissions and
  15. # limitations under the License.
  16. from .dataset_split.coco_split import split_coco_dataset
  17. from .dataset_split.voc_split import split_voc_dataset
  18. from .dataset_split.imagenet_split import split_imagenet_dataset
  19. from .dataset_split.seg_split import split_seg_dataset
  20. def dataset_split(dataset_dir, dataset_form, val_value, test_value, save_dir):
  21. if dataset_form == "coco":
  22. train_num, val_num, test_num = split_coco_dataset(
  23. dataset_dir, val_value, test_value, save_dir)
  24. elif dataset_form == "voc":
  25. train_num, val_num, test_num = split_voc_dataset(
  26. dataset_dir, val_value, test_value, save_dir)
  27. elif dataset_form == "seg":
  28. train_num, val_num, test_num = split_seg_dataset(
  29. dataset_dir, val_value, test_value, save_dir)
  30. elif dataset_form == "imagenet":
  31. train_num, val_num, test_num = split_imagenet_dataset(
  32. dataset_dir, val_value, test_value, save_dir)
  33. print("Dataset Split Done.")
  34. print("Train samples: {}".format(train_num))
  35. print("Eval samples: {}".format(val_num))
  36. print("Test samples: {}".format(test_num))
  37. print("Split file saved in {}".format(save_dir))