* 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/9297825master
@@ -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 | pip install -r requirements/tests.txt | ||||
@@ -41,8 +41,8 @@ reference: [https://huggingface.co/docs/tokenizers/installation#installation-fro | |||||
```shell | ```shell | ||||
pip install -f https://download.pytorch.org/whl/torch_stable.html -i https://pypi.tuna.tsinghua.edu.cn/simple -r requirements.txt | 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 对于[]需要做转义,执行如下命令 | mac终端的zsh 对于[]需要做转义,执行如下命令 | ||||
```shell | ```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 | |||||
``` | ``` |
@@ -27,12 +27,12 @@ pip install --upgrade tensorflow | |||||
### pip安装 | ### pip安装 | ||||
执行如下命令: | 执行如下命令: | ||||
```shell | ```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 | ```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 | |||||
``` | ``` | ||||
### 使用源码安装 | ### 使用源码安装 | ||||
适合本地开发调试使用,修改源码后可以直接执行 | 适合本地开发调试使用,修改源码后可以直接执行 | ||||
@@ -7,17 +7,24 @@ import scipy.io.wavfile as wav | |||||
import torch | import torch | ||||
import yaml | import yaml | ||||
from modelscope.fileio import File | |||||
from modelscope.metainfo import Pipelines | from modelscope.metainfo import Pipelines | ||||
from modelscope.preprocessors.audio import LinearAECAndFbank | from modelscope.preprocessors.audio import LinearAECAndFbank | ||||
from modelscope.utils.constant import ModelFile, Tasks | from modelscope.utils.constant import ModelFile, Tasks | ||||
from modelscope.utils.logger import get_logger | |||||
from ..base import Pipeline | from ..base import Pipeline | ||||
from ..builder import PIPELINES | from ..builder import PIPELINES | ||||
from ..outputs import OutputKeys | from ..outputs import OutputKeys | ||||
logger = get_logger() | |||||
FEATURE_MVN = 'feature.DEY.mvn.txt' | FEATURE_MVN = 'feature.DEY.mvn.txt' | ||||
CONFIG_YAML = 'dey_mini.yaml' | 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): | def initialize_config(module_cfg): | ||||
r"""According to config items, load specific module dynamically with params. | r"""According to config items, load specific module dynamically with params. | ||||
@@ -61,6 +68,13 @@ class LinearAECPipeline(Pipeline): | |||||
model: model id on modelscope hub. | model: model id on modelscope hub. | ||||
""" | """ | ||||
super().__init__(model=model) | 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() | self.use_cuda = torch.cuda.is_available() | ||||
with open( | with open( | ||||
os.path.join(self.model, CONFIG_YAML), encoding='utf-8') as f: | os.path.join(self.model, CONFIG_YAML), encoding='utf-8') as f: | ||||
@@ -1,6 +1,6 @@ | |||||
fairseq==maas | fairseq==maas | ||||
ftfy>=6.0.3 | ftfy>=6.0.3 | ||||
ofa==0.0.2 | |||||
ofa==0.0.2-3.6 | |||||
pycocoevalcap>=1.2 | pycocoevalcap>=1.2 | ||||
pycocotools>=2.0.4 | pycocotools>=2.0.4 | ||||
rouge_score | rouge_score | ||||
@@ -176,17 +176,17 @@ if __name__ == '__main__': | |||||
for field in dir(Fields): | for field in dir(Fields): | ||||
if field.startswith('_'): | if field.startswith('_'): | ||||
continue | 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( | extra_requires[field], _ = parse_requirements( | ||||
f'requirements/{field}.txt') | 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 | extra_requires['all'] = all_requires | ||||
setup( | setup( | ||||
name='model-scope', | |||||
name='modelscope', | |||||
version=get_version(), | version=get_version(), | ||||
description='', | description='', | ||||
long_description=readme(), | long_description=readme(), | ||||
@@ -36,8 +36,6 @@ class SpeechSignalProcessTest(unittest.TestCase): | |||||
@unittest.skipUnless(test_level() >= 1, 'skip test in current test level') | @unittest.skipUnless(test_level() >= 1, 'skip test in current test level') | ||||
def test_aec(self): | 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 audio files | ||||
download(NEAREND_MIC_URL, NEAREND_MIC_FILE) | download(NEAREND_MIC_URL, NEAREND_MIC_FILE) | ||||
download(FAREND_SPEECH_URL, FAREND_SPEECH_FILE) | download(FAREND_SPEECH_URL, FAREND_SPEECH_FILE) | ||||