You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

quick_start.md 3.9 kB

[to #9061073] feat: merge tts to master Link: https://code.alibaba-inc.com/Ali-MaaS/MaaS-lib/codereview/9061073 Link: https://code.alibaba-inc.com/Ali-MaaS/MaaS-lib/codereview/9061073 * [to #41669377] docs and tools refinement and release 1. add build_doc linter script 2. add sphinx-docs support 3. add development doc and api doc 4. change version to 0.1.0 for the first internal release version Link: https://code.aone.alibaba-inc.com/Ali-MaaS/MaaS-lib/codereview/8775307 * [to #41669377] add pipeline tutorial and fix bugs 1. add pipleine tutorial 2. fix bugs when using pipeline with certain model and preprocessor Link: https://code.alibaba-inc.com/Ali-MaaS/MaaS-lib/codereview/8814301 * refine doc * refine doc * merge remote release/0.1 and fix conflict * Merge branch 'release/0.1' into 'nls/tts' Release/0.1 See merge request !1700968 * [Add] add tts preprocessor without requirements. finish requirements build later * [Add] add requirements and frd submodule * [Fix] remove models submodule * [Add] add am module * [Update] update am and vocoder * [Update] remove submodule * [Update] add models * [Fix] fix init error * [Fix] fix bugs with tts pipeline * merge master * [Update] merge from master * remove frd subdmoule and using wheel from oss * change scripts * [Fix] fix bugs in am and vocoder * [Merge] merge from master * Merge branch 'master' into nls/tts * [Fix] fix bugs * [Fix] fix pep8 * Merge branch 'master' into nls/tts * [Update] remove hparams and import configuration from kwargs * Merge branch 'master' into nls/tts * upgrade tf113 to tf115 * Merge branch 'nls/tts' of gitlab.alibaba-inc.com:Ali-MaaS/MaaS-lib into nls/tts * add multiple versions of ttsfrd * merge master * [Fix] fix cr comments * Merge branch 'master' into nls/tts * [Fix] fix cr comments 0617 * Merge branch 'master' into nls/tts * [Fix] remove comment out codes * [Merge] merge from master * [Fix] fix crash for incompatible tf and pytorch version, and frd using zip file resource * Merge branch 'master' into nls/tts * [Add] add cuda support
3 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. # 快速开始
  2. ## python环境配置
  3. 首先,参考[文档](https://docs.anaconda.com/anaconda/install/) 安装配置Anaconda环境
  4. 安装完成后,执行如下命令为modelscope library创建对应的python环境。
  5. ```shell
  6. conda create -n modelscope python=3.6
  7. conda activate modelscope
  8. ```
  9. 检查python和pip命令是否切换到conda环境下。
  10. ```shell
  11. which python
  12. # ~/workspace/anaconda3/envs/modelscope/bin/python
  13. which pip
  14. # ~/workspace/anaconda3/envs/modelscope/bin/pip
  15. ```
  16. 注: 本项目只支持`python3`环境,请勿使用python2环境。
  17. ## 第三方依赖安装
  18. ModelScope Library目前支持tensorflow,pytorch两大深度学习框架进行模型训练、推理, 在Python 3.6+, Pytorch 1.8+, Tensorflow 2.6上测试可运行,用户可以根据所选模型对应的计算框架进行安装,可以参考如下链接进行安装所需框架:
  19. * [Pytorch安装指导](https://pytorch.org/get-started/locally/)
  20. * [Tensorflow安装指导](https://www.tensorflow.org/install/pip)
  21. 部分第三方依赖库需要提前安装numpy
  22. ```
  23. pip install numpy
  24. ```
  25. ## ModelScope library 安装
  26. 注: 如果在安装过程中遇到错误,请前往[常见问题](faq.md)查找解决方案。
  27. ### pip安装
  28. ```shell
  29. pip install -r http://pai-vision-data-hz.oss-cn-zhangjiakou.aliyuncs.com/release/maas/modelscope.txt
  30. ```
  31. 安装成功后,可以执行如下命令进行验证安装是否正确
  32. ```shell
  33. python -c "from modelscope.pipelines import pipeline;print(pipeline('image-matting',model='damo/image-matting-person')('http://pai-vision-data-hz.oss-cn-zhangjiakou.aliyuncs.com/data/test/maas/image_matting/test.png'))"
  34. ```
  35. ### 使用源码安装
  36. 适合本地开发调试使用,修改源码后可以直接执行
  37. ```shell
  38. git clone git@gitlab.alibaba-inc.com:Ali-MaaS/MaaS-lib.git modelscope
  39. git fetch origin master
  40. git checkout master
  41. cd modelscope
  42. #安装依赖
  43. pip install -r requirements.txt
  44. # 设置PYTHONPATH
  45. export PYTHONPATH=`pwd`
  46. ```
  47. 安装成功后,可以执行如下命令进行验证安装是否正确
  48. ```shell
  49. python -c "from modelscope.pipelines import pipeline;print(pipeline('image-matting',model='damo/image-matting-person')('http://pai-vision-data-hz.oss-cn-zhangjiakou.aliyuncs.com/data/test/maas/image_matting/test.png'))"
  50. ```
  51. ## 训练
  52. to be done
  53. ## 评估
  54. to be done
  55. ## 推理
  56. pipeline函数提供了简洁的推理接口,示例如下, 更多pipeline介绍和示例请参考[pipeline使用教程](tutorials/pipeline.md)
  57. ```python
  58. import cv2
  59. import os.path as osp
  60. from modelscope.pipelines import pipeline
  61. from modelscope.utils.constant import Tasks
  62. # 根据任务名创建pipeline
  63. img_matting = pipeline(Tasks.image_matting, model='damo/image-matting-person')
  64. # 直接提供图像文件的url作为pipeline推理的输入
  65. result = img_matting(
  66. 'http://pai-vision-data-hz.oss-cn-zhangjiakou.aliyuncs.com/data/test/maas/image_matting/test.png'
  67. )
  68. cv2.imwrite('result.png', result['output_png'])
  69. print(f'Output written to {osp.abspath("result.png")}')
  70. ```
  71. 此外,pipeline接口也能接收Dataset作为输入,上面的代码同样可以实现为
  72. ```python
  73. import cv2
  74. import os.path as osp
  75. from modelscope.pipelines import pipeline
  76. from modelscope.utils.constant import Tasks
  77. from modelscope.datasets import MsDataset
  78. # 使用图像url构建MsDataset,此处也可通过 input_location = '/dir/to/images' 来使用本地文件夹
  79. input_location = [
  80. 'http://pai-vision-data-hz.oss-cn-zhangjiakou.aliyuncs.com/data/test/maas/image_matting/test.png'
  81. ]
  82. dataset = MsDataset.load(input_location, target='image')
  83. img_matting = pipeline(Tasks.image_matting, model='damo/image-matting-person')
  84. # 输入为MsDataset时,输出的结果为迭代器
  85. result = img_matting(dataset)
  86. cv2.imwrite('result.png', next(result)['output_png'])
  87. print(f'Output written to {osp.abspath("result.png")}')
  88. ```