Link: https://code.alibaba-inc.com/Ali-MaaS/MaaS-lib/codereview/9597835master
| @@ -15,7 +15,8 @@ from .mmdet_ms.roi_heads import FCNMaskNHead, Shared4Conv1FCBBoxNHead | |||||
| @MODELS.register_module(Tasks.human_detection, module_name=Models.detection) | @MODELS.register_module(Tasks.human_detection, module_name=Models.detection) | ||||
| @MODELS.register_module(Tasks.object_detection, module_name=Models.detection) | |||||
| @MODELS.register_module( | |||||
| Tasks.image_object_detection, module_name=Models.detection) | |||||
| class DetectionModel(TorchModel): | class DetectionModel(TorchModel): | ||||
| def __init__(self, model_dir: str, *args, **kwargs): | def __init__(self, model_dir: str, *args, **kwargs): | ||||
| @@ -37,8 +37,8 @@ DEFAULT_MODEL_FOR_PIPELINE = { | |||||
| 'damo/cv_unet_image-matting'), | 'damo/cv_unet_image-matting'), | ||||
| Tasks.human_detection: (Pipelines.human_detection, | Tasks.human_detection: (Pipelines.human_detection, | ||||
| 'damo/cv_resnet18_human-detection'), | 'damo/cv_resnet18_human-detection'), | ||||
| Tasks.object_detection: (Pipelines.object_detection, | |||||
| 'damo/cv_vit_object-detection_coco'), | |||||
| Tasks.image_object_detection: (Pipelines.object_detection, | |||||
| 'damo/cv_vit_object-detection_coco'), | |||||
| Tasks.image_denoise: (Pipelines.image_denoise, | Tasks.image_denoise: (Pipelines.image_denoise, | ||||
| 'damo/cv_nafnet_image-denoise_sidd'), | 'damo/cv_nafnet_image-denoise_sidd'), | ||||
| Tasks.text_classification: (Pipelines.sentiment_analysis, | Tasks.text_classification: (Pipelines.sentiment_analysis, | ||||
| @@ -7,7 +7,7 @@ if TYPE_CHECKING: | |||||
| from .action_recognition_pipeline import ActionRecognitionPipeline | from .action_recognition_pipeline import ActionRecognitionPipeline | ||||
| from .animal_recognition_pipeline import AnimalRecognitionPipeline | from .animal_recognition_pipeline import AnimalRecognitionPipeline | ||||
| from .cmdssl_video_embedding_pipeline import CMDSSLVideoEmbeddingPipeline | from .cmdssl_video_embedding_pipeline import CMDSSLVideoEmbeddingPipeline | ||||
| from .object_detection_pipeline import ObjectDetectionPipeline | |||||
| from .image_detection_pipeline import ImageDetectionPipeline | |||||
| from .face_detection_pipeline import FaceDetectionPipeline | from .face_detection_pipeline import FaceDetectionPipeline | ||||
| from .face_recognition_pipeline import FaceRecognitionPipeline | from .face_recognition_pipeline import FaceRecognitionPipeline | ||||
| from .face_image_generation_pipeline import FaceImageGenerationPipeline | from .face_image_generation_pipeline import FaceImageGenerationPipeline | ||||
| @@ -33,7 +33,7 @@ else: | |||||
| 'action_recognition_pipeline': ['ActionRecognitionPipeline'], | 'action_recognition_pipeline': ['ActionRecognitionPipeline'], | ||||
| 'animal_recognition_pipeline': ['AnimalRecognitionPipeline'], | 'animal_recognition_pipeline': ['AnimalRecognitionPipeline'], | ||||
| 'cmdssl_video_embedding_pipeline': ['CMDSSLVideoEmbeddingPipeline'], | 'cmdssl_video_embedding_pipeline': ['CMDSSLVideoEmbeddingPipeline'], | ||||
| 'object_detection_pipeline': ['ObjectDetectionPipeline'], | |||||
| 'image_detection_pipeline': ['ImageDetectionPipeline'], | |||||
| 'face_detection_pipeline': ['FaceDetectionPipeline'], | 'face_detection_pipeline': ['FaceDetectionPipeline'], | ||||
| 'face_image_generation_pipeline': ['FaceImageGenerationPipeline'], | 'face_image_generation_pipeline': ['FaceImageGenerationPipeline'], | ||||
| 'face_recognition_pipeline': ['FaceRecognitionPipeline'], | 'face_recognition_pipeline': ['FaceRecognitionPipeline'], | ||||
| @@ -14,8 +14,8 @@ from modelscope.utils.logger import get_logger | |||||
| @PIPELINES.register_module( | @PIPELINES.register_module( | ||||
| Tasks.human_detection, module_name=Pipelines.human_detection) | Tasks.human_detection, module_name=Pipelines.human_detection) | ||||
| @PIPELINES.register_module( | @PIPELINES.register_module( | ||||
| Tasks.object_detection, module_name=Pipelines.object_detection) | |||||
| class ObjectDetectionPipeline(Pipeline): | |||||
| Tasks.image_object_detection, module_name=Pipelines.object_detection) | |||||
| class ImageDetectionPipeline(Pipeline): | |||||
| def __init__(self, model: str, **kwargs): | def __init__(self, model: str, **kwargs): | ||||
| """ | """ | ||||
| @@ -20,6 +20,7 @@ class CVTasks(object): | |||||
| image_classification = 'image-classification' | image_classification = 'image-classification' | ||||
| image_tagging = 'image-tagging' | image_tagging = 'image-tagging' | ||||
| object_detection = 'object-detection' | object_detection = 'object-detection' | ||||
| image_object_detection = 'image-object-detection' | |||||
| human_detection = 'human-detection' | human_detection = 'human-detection' | ||||
| image_segmentation = 'image-segmentation' | image_segmentation = 'image-segmentation' | ||||
| image_editing = 'image-editing' | image_editing = 'image-editing' | ||||
| @@ -13,7 +13,7 @@ class ObjectDetectionTest(unittest.TestCase): | |||||
| def test_object_detection(self): | def test_object_detection(self): | ||||
| input_location = 'data/test/images/image_detection.jpg' | input_location = 'data/test/images/image_detection.jpg' | ||||
| model_id = 'damo/cv_vit_object-detection_coco' | model_id = 'damo/cv_vit_object-detection_coco' | ||||
| object_detect = pipeline(Tasks.object_detection, model=model_id) | |||||
| object_detect = pipeline(Tasks.image_object_detection, model=model_id) | |||||
| result = object_detect(input_location) | result = object_detect(input_location) | ||||
| if result: | if result: | ||||
| print(result) | print(result) | ||||
| @@ -23,7 +23,7 @@ class ObjectDetectionTest(unittest.TestCase): | |||||
| @unittest.skipUnless(test_level() >= 2, 'skip test in current test level') | @unittest.skipUnless(test_level() >= 2, 'skip test in current test level') | ||||
| def test_object_detection_with_default_task(self): | def test_object_detection_with_default_task(self): | ||||
| input_location = 'data/test/images/image_detection.jpg' | input_location = 'data/test/images/image_detection.jpg' | ||||
| object_detect = pipeline(Tasks.object_detection) | |||||
| object_detect = pipeline(Tasks.image_object_detection) | |||||
| result = object_detect(input_location) | result = object_detect(input_location) | ||||
| if result: | if result: | ||||
| print(result) | print(result) | ||||