convert.py 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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 .x2imagenet import EasyData2ImageNet
  17. from .x2imagenet import JingLing2ImageNet
  18. from .x2coco import LabelMe2COCO
  19. from .x2coco import EasyData2COCO
  20. from .x2coco import JingLing2COCO
  21. from .x2voc import LabelMe2VOC
  22. from .x2voc import EasyData2VOC
  23. from .x2seg import JingLing2Seg
  24. from .x2seg import LabelMe2Seg
  25. from .x2seg import EasyData2Seg
  26. easydata2imagenet = EasyData2ImageNet().convert
  27. jingling2imagenet = JingLing2ImageNet().convert
  28. labelme2coco = LabelMe2COCO().convert
  29. easydata2coco = EasyData2COCO().convert
  30. jingling2coco = JingLing2COCO().convert
  31. labelme2voc = LabelMe2VOC().convert
  32. easydata2voc = EasyData2VOC().convert
  33. jingling2seg = JingLing2Seg().convert
  34. labelme2seg = LabelMe2Seg().convert
  35. easydata2seg = EasyData2Seg().convert
  36. def dataset_conversion(source, to, pics, anns, save_dir):
  37. if source == 'labelme' and to == 'PascalVOC':
  38. labelme2voc(pics, anns, save_dir)
  39. elif source == 'labelme' and to == 'MSCOCO':
  40. labelme2coco(pics, anns, save_dir)
  41. elif source == 'labelme' and to == 'SEG':
  42. labelme2seg(pics, anns, save_dir)
  43. elif source == 'jingling' and to == 'ImageNet':
  44. jingling2imagenet(pics, anns, save_dir)
  45. elif source == 'jingling' and to == 'MSCOCO':
  46. jingling2coco(pics, anns, save_dir)
  47. elif source == 'jingling' and to == 'SEG':
  48. jingling2seg(pics, anns, save_dir)
  49. elif source == 'easydata' and to == 'ImageNet':
  50. easydata2imagenet(pics, anns, save_dir)
  51. elif source == 'easydata' and to == 'PascalVOC':
  52. easydata2voc(pics, anns, save_dir)
  53. elif source == 'easydata' and to == 'MSCOCO':
  54. easydata2coco(pics, anns, save_dir)
  55. elif source == 'easydata' and to == 'SEG':
  56. easydata2seg(pics, anns, save_dir)