Add tool unittests

own
Bobholamovic 3 years ago
parent 98e6aae5a3
commit 04f86364c9
  1. 13
      tests/deploy/test_export.py
  2. 13
      tests/deploy/test_predict.py
  3. 11
      tests/rs_models/test_model.py
  4. 0
      tests/tools/test_coco2mask.py
  5. 0
      tests/tools/test_geojson2mask.py
  6. 0
      tests/tools/test_match.py
  7. 0
      tests/tools/test_oif.py
  8. 0
      tests/tools/test_pca.py
  9. 0
      tests/tools/test_raster2vector.py
  10. 0
      tests/tools/test_split.py

@ -0,0 +1,13 @@
# Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

@ -0,0 +1,13 @@
# Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

@ -15,10 +15,11 @@
import paddle import paddle
import numpy as np import numpy as np
from test_utils import CommonTest from testing_utils import CommonTest
class TestModel(CommonTest): class _TestModelNamespace:
class TestModel(CommonTest):
MODEL_CLASS = None MODEL_CLASS = None
DEFAULT_HW = (256, 256) DEFAULT_HW = (256, 256)
DEFAULT_BATCH_SIZE = 2 DEFAULT_BATCH_SIZE = 2
@ -30,7 +31,8 @@ class TestModel(CommonTest):
self.set_models() self.set_models()
def test_forward(self): def test_forward(self):
for i, (input, model, target for i, (
input, model, target
) in enumerate(zip(self.inputs, self.models, self.targets)): ) in enumerate(zip(self.inputs, self.models, self.targets)):
with self.subTest(i=i): with self.subTest(i=i):
output = model(input) output = model(input)
@ -87,3 +89,6 @@ class TestModel(CommonTest):
def get_randn_tensor(self, c, b=None, h=None, w=None): def get_randn_tensor(self, c, b=None, h=None, w=None):
shape = self.get_shape(c, b, h, w) shape = self.get_shape(c, b, h, w)
return paddle.randn(shape) return paddle.randn(shape)
TestModel = _TestModelNamespace.TestModel

Loading…
Cancel
Save