test_clas_models.py 1.3 KB

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