Browse Source

refactor space

master
智丞 3 years ago
parent
commit
a1af728079
12 changed files with 26 additions and 26 deletions
  1. +6
    -4
      modelscope/metainfo.py
  2. +2
    -4
      modelscope/models/nlp/space/dialog_intent_prediction_model.py
  3. +2
    -3
      modelscope/models/nlp/space/dialog_modeling_model.py
  4. +0
    -1
      modelscope/pipelines/__init__.py
  5. +2
    -3
      modelscope/pipelines/builder.py
  6. +2
    -2
      modelscope/pipelines/nlp/__init__.py
  7. +8
    -6
      modelscope/pipelines/nlp/dialog_intent_prediction_pipeline.py
  8. +4
    -3
      modelscope/pipelines/nlp/dialog_modeling_pipeline.py
  9. +0
    -0
      modelscope/pipelines/nlp/space/__init__.py
  10. +0
    -0
      tests/pipelines/nlp/__init__.py
  11. +0
    -0
      tests/pipelines/test_dialog_intent_prediction.py
  12. +0
    -0
      tests/pipelines/test_dialog_modeling.py

+ 6
- 4
modelscope/metainfo.py View File

@@ -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'


+ 2
- 4
modelscope/models/nlp/space/dialog_intent_prediction_model.py View File

@@ -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):


+ 2
- 3
modelscope/models/nlp/space/dialog_modeling_model.py View File

@@ -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):


+ 0
- 1
modelscope/pipelines/__init__.py View File

@@ -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

+ 2
- 3
modelscope/pipelines/builder.py View File

@@ -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'),
}


+ 2
- 2
modelscope/pipelines/nlp/__init__.py View File

@@ -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

modelscope/pipelines/nlp/space/dialog_intent_prediction_pipeline.py → modelscope/pipelines/nlp/dialog_intent_prediction_pipeline.py View File

@@ -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,

modelscope/pipelines/nlp/space/dialog_modeling_pipeline.py → modelscope/pipelines/nlp/dialog_modeling_pipeline.py View File

@@ -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,

+ 0
- 0
modelscope/pipelines/nlp/space/__init__.py View File


+ 0
- 0
tests/pipelines/nlp/__init__.py View File


tests/pipelines/nlp/test_dialog_intent_prediction.py → tests/pipelines/test_dialog_intent_prediction.py View File


tests/pipelines/nlp/test_dialog_modeling.py → tests/pipelines/test_dialog_modeling.py View File


Loading…
Cancel
Save