Browse Source

[to #42322933] relax un-determinsitic test validation constraints

放松了tests/pipelines/easycv_pipelines/test_segmentation_pipeline.py里面对于识别非determinsitic的校验条件,一方便后续模型更新
        Link: https://code.alibaba-inc.com/Ali-MaaS/MaaS-lib/codereview/10245940
master
pengyu.lpy yingda.chen 3 years ago
parent
commit
3ed0c9c8d8
1 changed files with 14 additions and 16 deletions
  1. +14
    -16
      tests/pipelines/easycv_pipelines/test_segmentation_pipeline.py

+ 14
- 16
tests/pipelines/easycv_pipelines/test_segmentation_pipeline.py View File

@@ -15,7 +15,7 @@ class EasyCVSegmentationPipelineTest(unittest.TestCase):


img_path = 'data/test/images/image_segmentation.jpg' img_path = 'data/test/images/image_segmentation.jpg'


def _internal_test__(self, model_id):
def _internal_test_(self, model_id):
img = np.asarray(Image.open(self.img_path)) img = np.asarray(Image.open(self.img_path))


semantic_seg = pipeline(task=Tasks.image_segmentation, model=model_id) semantic_seg = pipeline(task=Tasks.image_segmentation, model=model_id)
@@ -26,12 +26,8 @@ class EasyCVSegmentationPipelineTest(unittest.TestCase):
results = outputs[0] results = outputs[0]
self.assertListEqual( self.assertListEqual(
list(img.shape)[:2], list(results['seg_pred'].shape)) list(img.shape)[:2], list(results['seg_pred'].shape))
self.assertListEqual(results['seg_pred'][1, 4:10].tolist(),
[161 for i in range(6)])
self.assertListEqual(results['seg_pred'][-1, -10:].tolist(),
[133 for i in range(10)])


def _internal_test_batch(self, model_id, num_samples=2, batch_size=2):
def _internal_test_batch_(self, model_id, num_samples=2, batch_size=2):
# TODO: support in the future # TODO: support in the future
img = np.asarray(Image.open(self.img_path)) img = np.asarray(Image.open(self.img_path))
num_samples = num_samples num_samples = num_samples
@@ -48,40 +44,42 @@ class EasyCVSegmentationPipelineTest(unittest.TestCase):
for output in outputs: for output in outputs:
self.assertListEqual( self.assertListEqual(
list(img.shape)[:2], list(output['seg_pred'].shape)) list(img.shape)[:2], list(output['seg_pred'].shape))
self.assertListEqual(output['seg_pred'][1, 4:10].tolist(),
[161 for i in range(6)])
self.assertListEqual(output['seg_pred'][-1, -10:].tolist(),
[133 for i in range(10)])


@unittest.skipUnless(test_level() >= 0, 'skip test in current test level') @unittest.skipUnless(test_level() >= 0, 'skip test in current test level')
def test_segformer_b0(self): def test_segformer_b0(self):
model_id = 'damo/cv_segformer-b0_image_semantic-segmentation_coco-stuff164k' model_id = 'damo/cv_segformer-b0_image_semantic-segmentation_coco-stuff164k'
self._internal_test__(model_id)
self._internal_test_(model_id)
self._internal_test_batch_(model_id)


@unittest.skipUnless(test_level() >= 0, 'skip test in current test level') @unittest.skipUnless(test_level() >= 0, 'skip test in current test level')
def test_segformer_b1(self): def test_segformer_b1(self):
model_id = 'damo/cv_segformer-b1_image_semantic-segmentation_coco-stuff164k' model_id = 'damo/cv_segformer-b1_image_semantic-segmentation_coco-stuff164k'
self._internal_test__(model_id)
self._internal_test_(model_id)
self._internal_test_batch_(model_id)


@unittest.skipUnless(test_level() >= 0, 'skip test in current test level') @unittest.skipUnless(test_level() >= 0, 'skip test in current test level')
def test_segformer_b2(self): def test_segformer_b2(self):
model_id = 'damo/cv_segformer-b2_image_semantic-segmentation_coco-stuff164k' model_id = 'damo/cv_segformer-b2_image_semantic-segmentation_coco-stuff164k'
self._internal_test__(model_id)
self._internal_test_(model_id)
self._internal_test_batch_(model_id)


@unittest.skipUnless(test_level() >= 0, 'skip test in current test level') @unittest.skipUnless(test_level() >= 0, 'skip test in current test level')
def test_segformer_b3(self): def test_segformer_b3(self):
model_id = 'damo/cv_segformer-b3_image_semantic-segmentation_coco-stuff164k' model_id = 'damo/cv_segformer-b3_image_semantic-segmentation_coco-stuff164k'
self._internal_test__(model_id)
self._internal_test_(model_id)
self._internal_test_batch_(model_id)


@unittest.skipUnless(test_level() >= 0, 'skip test in current test level') @unittest.skipUnless(test_level() >= 0, 'skip test in current test level')
def test_segformer_b4(self): def test_segformer_b4(self):
model_id = 'damo/cv_segformer-b4_image_semantic-segmentation_coco-stuff164k' model_id = 'damo/cv_segformer-b4_image_semantic-segmentation_coco-stuff164k'
self._internal_test__(model_id)
self._internal_test_(model_id)
self._internal_test_batch_(model_id)


@unittest.skipUnless(test_level() >= 0, 'skip test in current test level') @unittest.skipUnless(test_level() >= 0, 'skip test in current test level')
def test_segformer_b5(self): def test_segformer_b5(self):
model_id = 'damo/cv_segformer-b5_image_semantic-segmentation_coco-stuff164k' model_id = 'damo/cv_segformer-b5_image_semantic-segmentation_coco-stuff164k'
self._internal_test__(model_id)
self._internal_test_(model_id)
self._internal_test_batch_(model_id)




if __name__ == '__main__': if __name__ == '__main__':


Loading…
Cancel
Save