You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

test_datasets_voc.py 2.0 kB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. # Copyright 2019 Huawei Technologies Co., Ltd
  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. # ==============================================================================
  15. import mindspore.dataset.transforms.vision.c_transforms as vision
  16. import mindspore.dataset as ds
  17. from mindspore import log as logger
  18. DATA_DIR = "../data/dataset/testVOC2012"
  19. def test_voc_normal():
  20. data1 = ds.VOCDataset(DATA_DIR, decode=True)
  21. num = 0
  22. for item in data1.create_dict_iterator():
  23. logger.info("item[image] is {}".format(item["image"]))
  24. logger.info("item[image].shape is {}".format(item["image"].shape))
  25. logger.info("item[target] is {}".format(item["target"]))
  26. logger.info("item[target].shape is {}".format(item["target"].shape))
  27. num += 1
  28. logger.info("num is {}".format(str(num)))
  29. def test_case_0():
  30. data1 = ds.VOCDataset(DATA_DIR, decode=True)
  31. resize_op = vision.Resize((224, 224))
  32. data1 = data1.map(input_columns=["image"], operations=resize_op)
  33. data1 = data1.map(input_columns=["target"], operations=resize_op)
  34. repeat_num = 4
  35. data1 = data1.repeat(repeat_num)
  36. batch_size = 2
  37. data1 = data1.batch(batch_size, drop_remainder=True)
  38. num = 0
  39. for item in data1.create_dict_iterator():
  40. logger.info("item[image].shape is {}".format(item["image"].shape))
  41. logger.info("item[target].shape is {}".format(item["target"].shape))
  42. num += 1
  43. logger.info("num is {}".format(str(num)))