diff --git a/tests/pipelines/easycv_pipelines/test_segmentation_pipeline.py b/tests/pipelines/easycv_pipelines/test_segmentation_pipeline.py index 0eca2a7f..6cfdacc6 100644 --- a/tests/pipelines/easycv_pipelines/test_segmentation_pipeline.py +++ b/tests/pipelines/easycv_pipelines/test_segmentation_pipeline.py @@ -12,24 +12,54 @@ from modelscope.utils.test_utils import test_level class EasyCVSegmentationPipelineTest(unittest.TestCase): - @unittest.skipUnless(test_level() >= 1, 'skip test in current test level') - def test_segformer_b0(self): - img_path = 'data/test/images/image_segmentation.jpg' - model_id = 'EasyCV/EasyCV-Segformer-b0' - img = np.asarray(Image.open(img_path)) + img_path = 'data/test/images/image_segmentation.jpg' + + def _internal_test__(self, model_id): + img = np.asarray(Image.open(self.img_path)) + + semantic_seg = pipeline(task=Tasks.image_segmentation, model=model_id) + outputs = semantic_seg(self.img_path) - object_detect = pipeline(task=Tasks.image_segmentation, model=model_id) - outputs = object_detect(img_path) self.assertEqual(len(outputs), 1) results = outputs[0] self.assertListEqual( list(img.shape)[:2], list(results['seg_pred'][0].shape)) - self.assertListEqual(results['seg_pred'][0][1, :10].tolist(), - [161 for i in range(10)]) + self.assertListEqual(results['seg_pred'][0][1, 4:10].tolist(), + [161 for i in range(6)]) self.assertListEqual(results['seg_pred'][0][-1, -10:].tolist(), [133 for i in range(10)]) + @unittest.skipUnless(test_level() >= 1, 'skip test in current test level') + def test_segformer_b0(self): + model_id = 'damo/cv_segformer-b0_image_semantic-segmentation_coco-stuff164k' + self._internal_test__(model_id) + + @unittest.skipUnless(test_level() >= 1, 'skip test in current test level') + def test_segformer_b1(self): + model_id = 'damo/cv_segformer-b1_image_semantic-segmentation_coco-stuff164k' + self._internal_test__(model_id) + + @unittest.skipUnless(test_level() >= 1, 'skip test in current test level') + def test_segformer_b2(self): + model_id = 'damo/cv_segformer-b2_image_semantic-segmentation_coco-stuff164k' + self._internal_test__(model_id) + + @unittest.skipUnless(test_level() >= 1, 'skip test in current test level') + def test_segformer_b3(self): + model_id = 'damo/cv_segformer-b3_image_semantic-segmentation_coco-stuff164k' + self._internal_test__(model_id) + + @unittest.skipUnless(test_level() >= 1, 'skip test in current test level') + def test_segformer_b4(self): + model_id = 'damo/cv_segformer-b4_image_semantic-segmentation_coco-stuff164k' + self._internal_test__(model_id) + + @unittest.skipUnless(test_level() >= 1, 'skip test in current test level') + def test_segformer_b5(self): + model_id = 'damo/cv_segformer-b5_image_semantic-segmentation_coco-stuff164k' + self._internal_test__(model_id) + if __name__ == '__main__': unittest.main()