test_clas_models.py 1.2 KB

1234567891011121314151617181920212223242526272829303132333435
  1. # Copyright (c) 2022 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. import paddlers
  15. from rs_models.test_model import TestModel
  16. class TestCDModel(TestModel):
  17. DEFAULT_HW = (224, 224)
  18. def check_output(self, output, target):
  19. # target is the expected shape of the output
  20. self.check_output_equal(output.numpy().shape, target)
  21. def set_inputs(self):
  22. def _gen_data(specs):
  23. for spec in specs:
  24. c = spec.get('in_channels', 3)
  25. yield [self.get_randn_tensor(c)]
  26. self.inputs = _gen_data(self.specs)
  27. def set_targets(self):
  28. self.targets = [[2, spec.get('num_classes', 2)] for spec in self.specs]