diff --git a/modelscope/metainfo.py b/modelscope/metainfo.py index 3f9cc64e..03426045 100644 --- a/modelscope/metainfo.py +++ b/modelscope/metainfo.py @@ -47,10 +47,12 @@ class Pipelines(object): word_segmentation = 'word-segmentation' text_generation = 'text-generation' sentiment_analysis = 'sentiment-analysis' - sentiment_classification = "sentiment-classification" - zero_shot_classification = "zero-shot-classification" - fill_mask = "fill-mask" - nli = "nli" + sentiment_classification = 'sentiment-classification' + zero_shot_classification = 'zero-shot-classification' + fill_mask = 'fill-mask' + nli = 'nli' + dialog_intent_prediction = 'dialog-intent-prediction' + dialog_modeling = 'dialog-modeling' # audio tasks sambert_hifigan_16k_tts = 'sambert-hifigan-16k-tts' diff --git a/modelscope/models/nlp/space/dialog_intent_prediction_model.py b/modelscope/models/nlp/space/dialog_intent_prediction_model.py index b25be19f..a5d94376 100644 --- a/modelscope/models/nlp/space/dialog_intent_prediction_model.py +++ b/modelscope/models/nlp/space/dialog_intent_prediction_model.py @@ -1,8 +1,7 @@ import os from typing import Any, Dict -from ....preprocessors.space.fields.intent_field import \ - IntentBPETextField +from ....preprocessors.space.fields.intent_field import IntentBPETextField from ....trainers.nlp.space.trainers.intent_trainer import IntentTrainer from ....utils.config import Config from ....utils.constant import Tasks @@ -14,8 +13,7 @@ from .model.model_base import ModelBase __all__ = ['DialogIntentModel'] -@MODELS.register_module( - Tasks.dialog_intent_prediction, module_name=r'space-intent') +@MODELS.register_module(Tasks.dialog_intent_prediction, module_name=r'space') class DialogIntentModel(Model): def __init__(self, model_dir: str, *args, **kwargs): diff --git a/modelscope/models/nlp/space/dialog_modeling_model.py b/modelscope/models/nlp/space/dialog_modeling_model.py index 9c972d19..4a34f132 100644 --- a/modelscope/models/nlp/space/dialog_modeling_model.py +++ b/modelscope/models/nlp/space/dialog_modeling_model.py @@ -1,8 +1,7 @@ import os from typing import Any, Dict, Optional -from ....preprocessors.space.fields.gen_field import \ - MultiWOZBPETextField +from ....preprocessors.space.fields.gen_field import MultiWOZBPETextField from ....trainers.nlp.space.trainers.gen_trainer import MultiWOZTrainer from ....utils.config import Config from ....utils.constant import Tasks @@ -14,7 +13,7 @@ from .model.model_base import ModelBase __all__ = ['DialogModelingModel'] -@MODELS.register_module(Tasks.dialog_modeling, module_name=r'space-modeling') +@MODELS.register_module(Tasks.dialog_modeling, module_name=r'space') class DialogModelingModel(Model): def __init__(self, model_dir: str, *args, **kwargs): diff --git a/modelscope/pipelines/__init__.py b/modelscope/pipelines/__init__.py index 6e2645de..14865872 100644 --- a/modelscope/pipelines/__init__.py +++ b/modelscope/pipelines/__init__.py @@ -4,4 +4,3 @@ from .builder import pipeline from .cv import * # noqa F403 from .multi_modal import * # noqa F403 from .nlp import * # noqa F403 -from .nlp.space import * # noqa F403 diff --git a/modelscope/pipelines/builder.py b/modelscope/pipelines/builder.py index 22274b55..b0f2955c 100644 --- a/modelscope/pipelines/builder.py +++ b/modelscope/pipelines/builder.py @@ -25,8 +25,7 @@ DEFAULT_MODEL_FOR_PIPELINE = { (Pipelines.sentence_similarity, 'damo/nlp_structbert_sentence-similarity_chinese-base'), Tasks.image_matting: ('image-matting', 'damo/cv_unet_image-matting'), - Tasks.nli: (Pipelines.nli, - 'damo/nlp_structbert_nli_chinese-base'), + Tasks.nli: (Pipelines.nli, 'damo/nlp_structbert_nli_chinese-base'), Tasks.sentiment_classification: (Pipelines.sentiment_classification, 'damo/nlp_structbert_sentiment-classification_chinese-base'), @@ -48,7 +47,7 @@ DEFAULT_MODEL_FOR_PIPELINE = { 'damo/cv_unet_person-image-cartoon_compound-models'), Tasks.ocr_detection: (Pipelines.ocr_detection, 'damo/cv_resnet18_ocr-detection-line-level_damo'), - Tasks.fill_mask: (Pipelines.fill_mask, 'damo/nlp_veco_fill-mask_large') + Tasks.fill_mask: (Pipelines.fill_mask, 'damo/nlp_veco_fill-mask_large'), Tasks.action_recognition: (Pipelines.action_recognition, 'damo/cv_TAdaConv_action-recognition'), } diff --git a/modelscope/pipelines/nlp/__init__.py b/modelscope/pipelines/nlp/__init__.py index dc99a157..7aebf3e8 100644 --- a/modelscope/pipelines/nlp/__init__.py +++ b/modelscope/pipelines/nlp/__init__.py @@ -1,10 +1,10 @@ +from .dialog_intent_prediction_pipeline import * # noqa F403 +from .dialog_modeling_pipeline import * # noqa F403 from .fill_mask_pipeline import * # noqa F403 from .nli_pipeline import * # noqa F403 from .sentence_similarity_pipeline import * # noqa F403 from .sentiment_classification_pipeline import * # noqa F403 from .sequence_classification_pipeline import * # noqa F403 -from .space.dialog_intent_prediction_pipeline import * # noqa F403 -from .space.dialog_modeling_pipeline import * # noqa F403 from .text_generation_pipeline import * # noqa F403 from .word_segmentation_pipeline import * # noqa F403 from .zero_shot_classification_pipeline import * # noqa F403 diff --git a/modelscope/pipelines/nlp/space/dialog_intent_prediction_pipeline.py b/modelscope/pipelines/nlp/dialog_intent_prediction_pipeline.py similarity index 77% rename from modelscope/pipelines/nlp/space/dialog_intent_prediction_pipeline.py rename to modelscope/pipelines/nlp/dialog_intent_prediction_pipeline.py index dfe885c5..3fd38641 100644 --- a/modelscope/pipelines/nlp/space/dialog_intent_prediction_pipeline.py +++ b/modelscope/pipelines/nlp/dialog_intent_prediction_pipeline.py @@ -1,16 +1,18 @@ from typing import Any, Dict -from ...base import Pipeline -from ...builder import PIPELINES -from ....models.nlp import DialogIntentModel -from ....preprocessors import DialogIntentPredictionPreprocessor -from ....utils.constant import Tasks +from ...metainfo import Pipelines +from ...models.nlp import DialogIntentModel +from ...preprocessors import DialogIntentPredictionPreprocessor +from ...utils.constant import Tasks +from ..base import Pipeline +from ..builder import PIPELINES __all__ = ['DialogIntentPredictionPipeline'] @PIPELINES.register_module( - Tasks.dialog_intent_prediction, module_name=r'space-intent') + Tasks.dialog_intent_prediction, + module_name=Pipelines.dialog_intent_prediction) class DialogIntentPredictionPipeline(Pipeline): def __init__(self, model: DialogIntentModel, diff --git a/modelscope/pipelines/nlp/space/dialog_modeling_pipeline.py b/modelscope/pipelines/nlp/dialog_modeling_pipeline.py similarity index 89% rename from modelscope/pipelines/nlp/space/dialog_modeling_pipeline.py rename to modelscope/pipelines/nlp/dialog_modeling_pipeline.py index afa352b6..778284de 100644 --- a/modelscope/pipelines/nlp/space/dialog_modeling_pipeline.py +++ b/modelscope/pipelines/nlp/dialog_modeling_pipeline.py @@ -3,14 +3,15 @@ from typing import Any, Dict, Optional from modelscope.models.nlp import DialogModelingModel from modelscope.preprocessors import DialogModelingPreprocessor from modelscope.utils.constant import Tasks -from ...base import Pipeline, Tensor -from ...builder import PIPELINES +from ...metainfo import Pipelines +from ..base import Pipeline, Tensor +from ..builder import PIPELINES __all__ = ['DialogModelingPipeline'] @PIPELINES.register_module( - Tasks.dialog_modeling, module_name=r'space-modeling') + Tasks.dialog_modeling, module_name=Pipelines.dialog_modeling) class DialogModelingPipeline(Pipeline): def __init__(self, model: DialogModelingModel, diff --git a/modelscope/pipelines/nlp/space/__init__.py b/modelscope/pipelines/nlp/space/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/tests/pipelines/nlp/__init__.py b/tests/pipelines/nlp/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/tests/pipelines/nlp/test_dialog_intent_prediction.py b/tests/pipelines/test_dialog_intent_prediction.py similarity index 100% rename from tests/pipelines/nlp/test_dialog_intent_prediction.py rename to tests/pipelines/test_dialog_intent_prediction.py diff --git a/tests/pipelines/nlp/test_dialog_modeling.py b/tests/pipelines/test_dialog_modeling.py similarity index 100% rename from tests/pipelines/nlp/test_dialog_modeling.py rename to tests/pipelines/test_dialog_modeling.py