convert.py 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. # Copyright (c) 2021 PaddlePaddle Authors. All Rights Reserved.
  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. from .dataset_conversion import *
  15. easydata2imagenet = EasyData2ImageNet().convert
  16. jingling2imagenet = JingLing2ImageNet().convert
  17. jingling2seg = JingLing2Seg().convert
  18. labelme2seg = LabelMe2Seg().convert
  19. easydata2seg = EasyData2Seg().convert
  20. labelme2voc = LabelMe2VOC().convert
  21. easydata2voc = EasyData2VOC().convert
  22. labelme2coco = LabelMe2COCO().convert
  23. easydata2coco = EasyData2COCO().convert
  24. jingling2coco = JingLing2COCO().convert
  25. def dataset_conversion(source, to, pics, anns, save_dir):
  26. if source.lower() == 'easydata' and to.lower() == 'imagenet':
  27. easydata2imagenet(pics, anns, save_dir)
  28. elif source.lower() == 'jingling' and to.lower() == 'imagenet':
  29. jingling2imagenet(pics, anns, save_dir)
  30. elif source.lower() == 'jingling' and to.lower() == 'seg':
  31. jingling2seg(pics, anns, save_dir)
  32. elif source.lower() == 'labelme' and to.lower() == 'seg':
  33. labelme2seg(pics, anns, save_dir)
  34. elif source.lower() == 'easydata' and to.lower() == 'seg':
  35. easydata2seg(pics, anns, save_dir)
  36. elif source.lower() == 'labelme' and to.lower() == 'pascalvoc':
  37. labelme2voc(pics, anns, save_dir)
  38. elif source.lower() == 'easydata' and to.lower() == 'pascalvoc':
  39. easydata2voc(pics, anns, save_dir)
  40. elif source.lower() == 'labelme' and to.lower() == 'mscoco':
  41. labelme2coco(pics, anns, save_dir)
  42. elif source.lower() == 'easydata' and to.lower() == 'mscoco':
  43. easydata2coco(pics, anns, save_dir)
  44. elif source.lower() == 'jingling' and to.lower() == 'mscoco':
  45. jingling2coco(pics, anns, save_dir)
  46. else:
  47. raise Exception("Converting from {} to {} is not supported.".format(
  48. source, to))