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_de.cc 1.7 kB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /**
  2. * Copyright 2020 Huawei Technologies Co., Ltd
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. #include <string>
  17. #include <vector>
  18. #include "common/common_test.h"
  19. #include "include/api/types.h"
  20. #include "minddata/dataset/include/minddata_eager.h"
  21. #include "minddata/dataset/include/vision.h"
  22. #include "minddata/dataset/kernels/tensor_op.h"
  23. using namespace mindspore::api;
  24. using namespace mindspore::dataset::vision;
  25. class TestDE : public ST::Common {
  26. public:
  27. TestDE() {}
  28. };
  29. TEST_F(TestDE, ResNetPreprocess) {
  30. std::vector<std::shared_ptr<Tensor>> images;
  31. MindDataEager::LoadImageFromDir("/home/workspace/mindspore_dataset/imagenet/imagenet_original/val/n01440764", &images);
  32. MindDataEager Compose({Decode(),
  33. Resize({224, 224}),
  34. Normalize({0.485 * 255, 0.456 * 255, 0.406 * 255}, {0.229 * 255, 0.224 * 255, 0.225 * 255}),
  35. HWC2CHW()});
  36. for (auto &img : images) {
  37. img = Compose(img);
  38. }
  39. ASSERT_EQ(images[0]->Shape().size(), 3);
  40. ASSERT_EQ(images[0]->Shape()[0], 3);
  41. ASSERT_EQ(images[0]->Shape()[1], 224);
  42. ASSERT_EQ(images[0]->Shape()[2], 224);
  43. }