Browse Source

fix several small problems for v0.2

* rename name of whl to modelscope
* auto install all requirements when running citest
* auto download dynamic lib for aec pipeline
* fix setup.py  audio extras not set
Link: https://code.alibaba-inc.com/Ali-MaaS/MaaS-lib/codereview/9297825
master
wenmeng.zwm 3 years ago
parent
commit
9f1ad5da80
7 changed files with 31 additions and 14 deletions
  1. +6
    -1
      .dev_scripts/citest.sh
  2. +2
    -2
      docs/source/faq.md
  3. +2
    -2
      docs/source/quick_start.md
  4. +14
    -0
      modelscope/pipelines/audio/linear_aec_pipeline.py
  5. +1
    -1
      requirements/multi-modal.txt
  6. +6
    -6
      setup.py
  7. +0
    -2
      tests/pipelines/test_speech_signal_process.py

+ 6
- 1
.dev_scripts/citest.sh View File

@@ -1,4 +1,9 @@
pip install -r requirements.txt
pip install -r requirements.txt -f https://modelscope.oss-cn-beijing.aliyuncs.com/releases/repo.html
pip install -r requirements/audio.txt -f https://modelscope.oss-cn-beijing.aliyuncs.com/releases/repo.html
pip install -r requirements/cv.txt -f https://modelscope.oss-cn-beijing.aliyuncs.com/releases/repo.html
pip install -r requirements/multi-modal.txt -f https://modelscope.oss-cn-beijing.aliyuncs.com/releases/repo.html
pip install -r requirements/nlp.txt -f https://modelscope.oss-cn-beijing.aliyuncs.com/releases/repo.html

pip install -r requirements/tests.txt




+ 2
- 2
docs/source/faq.md View File

@@ -41,8 +41,8 @@ reference: [https://huggingface.co/docs/tokenizers/installation#installation-fro
```shell
pip install -f https://download.pytorch.org/whl/torch_stable.html -i https://pypi.tuna.tsinghua.edu.cn/simple -r requirements.txt
```
### 4. zsh: no matches found: model_scope-0.2.2-py3-none-any.whl[all]
### 4. zsh: no matches found: modelscope-0.2.2-py3-none-any.whl[all]
mac终端的zsh 对于[]需要做转义,执行如下命令
```shell
pip install model_scope\[all\] -f https://modelscope.oss-cn-beijing.aliyuncs.com/releases/repo.html
pip install modelscope\[all\] -f https://modelscope.oss-cn-beijing.aliyuncs.com/releases/repo.html
```

+ 2
- 2
docs/source/quick_start.md View File

@@ -27,12 +27,12 @@ pip install --upgrade tensorflow
### pip安装
执行如下命令:
```shell
pip install "model_scope[all]" -f https://modelscope.oss-cn-beijing.aliyuncs.com/releases/repo.html
pip install "modelscope[all]" -f https://modelscope.oss-cn-beijing.aliyuncs.com/releases/repo.html
```

如需体验`语音功能`,请`额外`执行如下命令:
```shell
pip install "model_scope[audio]" -f https://modelscope.oss-cn-beijing.aliyuncs.com/releases/repo.html
pip install "modelscope[audio]" -f https://modelscope.oss-cn-beijing.aliyuncs.com/releases/repo.html
```
### 使用源码安装
适合本地开发调试使用,修改源码后可以直接执行


+ 14
- 0
modelscope/pipelines/audio/linear_aec_pipeline.py View File

@@ -7,17 +7,24 @@ import scipy.io.wavfile as wav
import torch
import yaml

from modelscope.fileio import File
from modelscope.metainfo import Pipelines
from modelscope.preprocessors.audio import LinearAECAndFbank
from modelscope.utils.constant import ModelFile, Tasks
from modelscope.utils.logger import get_logger
from ..base import Pipeline
from ..builder import PIPELINES
from ..outputs import OutputKeys

logger = get_logger()

FEATURE_MVN = 'feature.DEY.mvn.txt'

CONFIG_YAML = 'dey_mini.yaml'

AEC_LIB_URL = 'https://modelscope.oss-cn-beijing.aliyuncs.com/dependencies/ics_MaaS_AEC_lib_libmitaec_pyio.so'
AEC_LIB_FILE = 'libmitaec_pyio.so'


def initialize_config(module_cfg):
r"""According to config items, load specific module dynamically with params.
@@ -61,6 +68,13 @@ class LinearAECPipeline(Pipeline):
model: model id on modelscope hub.
"""
super().__init__(model=model)

# auto download so for linux inference before light-weight docker got ready
if not os.path.exists(AEC_LIB_FILE):
logger.info(f'downloading {AEC_LIB_URL} to {AEC_LIB_FILE}')
with open(AEC_LIB_FILE, 'wb') as ofile:
ofile.write(File.read(AEC_LIB_URL))

self.use_cuda = torch.cuda.is_available()
with open(
os.path.join(self.model, CONFIG_YAML), encoding='utf-8') as f:


+ 1
- 1
requirements/multi-modal.txt View File

@@ -1,6 +1,6 @@
fairseq==maas
ftfy>=6.0.3
ofa==0.0.2
ofa==0.0.2-3.6
pycocoevalcap>=1.2
pycocotools>=2.0.4
rouge_score


+ 6
- 6
setup.py View File

@@ -176,17 +176,17 @@ if __name__ == '__main__':
for field in dir(Fields):
if field.startswith('_'):
continue
# skip audio requirements due to its hard dependency which
# result in mac/windows compatibility problems
if field == Fields.audio:
continue
extra_requires[field], _ = parse_requirements(
f'requirements/{field}.txt')
all_requires.append(extra_requires[field])

# skip audio requirements due to its hard dependency which
# result in mac/windows compatibility problems
if field != Fields.audio:
all_requires.append(extra_requires[field])
extra_requires['all'] = all_requires

setup(
name='model-scope',
name='modelscope',
version=get_version(),
description='',
long_description=readme(),


+ 0
- 2
tests/pipelines/test_speech_signal_process.py View File

@@ -36,8 +36,6 @@ class SpeechSignalProcessTest(unittest.TestCase):

@unittest.skipUnless(test_level() >= 1, 'skip test in current test level')
def test_aec(self):
# A temporary hack to provide c++ lib. Download it first.
download(AEC_LIB_URL, AEC_LIB_FILE)
# Download audio files
download(NEAREND_MIC_URL, NEAREND_MIC_FILE)
download(FAREND_SPEECH_URL, FAREND_SPEECH_FILE)


Loading…
Cancel
Save