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 2.8 kB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. # 快速开始
  2. ## python环境配置
  3. 首先,参考[文档](https://docs.anaconda.com/anaconda/install/) 安装配置Anaconda环境
  4. 安装完成后,执行如下命令为maas library创建对应的python环境。
  5. ```shell
  6. conda create -n maas python=3.6
  7. conda activate maas
  8. ```
  9. 检查python和pip命令是否切换到conda环境下。
  10. ```shell
  11. which python
  12. # ~/workspace/anaconda3/envs/maas/bin/python
  13. which pip
  14. # ~/workspace/anaconda3/envs/maas/bin/pip
  15. ```
  16. 注: 本项目只支持`python3`环境,请勿使用python2环境。
  17. ## 第三方依赖安装
  18. MaaS 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. ## MaaS library 安装
  22. 注: 如果在安装过程中遇到错误,请前往[常见问题](faq.md)查找解决方案。
  23. ### pip安装
  24. ```shell
  25. pip install -r http://pai-vision-data-hz.oss-cn-zhangjiakou.aliyuncs.com/release/maas/maas.txt
  26. ```
  27. 安装成功后,可以执行如下命令进行验证安装是否正确
  28. ```shell
  29. python -c "from maas_lib.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'))"
  30. ```
  31. ### 使用源码
  32. 适合本地开发调试使用,修改源码后可以直接执行
  33. ```shell
  34. git clone git@gitlab.alibaba-inc.com:Ali-MaaS/MaaS-lib.git maaslib
  35. git fetch origin master
  36. git checkout master
  37. cd maaslib
  38. #安装依赖
  39. pip install -r requirements.txt
  40. # 设置PYTHONPATH
  41. export PYTHONPATH=`pwd`
  42. ```
  43. 安装成功后,可以执行如下命令进行验证安装是否正确
  44. ```shell
  45. python -c "from maas_lib.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'))"
  46. ```
  47. ## 训练
  48. to be done
  49. ## 评估
  50. to be done
  51. ## 推理
  52. pipeline函数提供了简洁的推理接口,示例如下, 更多pipeline介绍和示例请参考[pipeline使用教程](tutorials/pipeline.md)
  53. ```python
  54. import cv2
  55. import os.path as osp
  56. from maas_lib.pipelines import pipeline
  57. from maas_lib.utils.constant import Tasks
  58. # 根据任务名创建pipeline
  59. img_matting = pipeline(
  60. Tasks.image_matting, model='damo/image-matting-person')
  61. result = img_matting(
  62. 'http://pai-vision-data-hz.oss-cn-zhangjiakou.aliyuncs.com/data/test/maas/image_matting/test.png'
  63. )
  64. cv2.imwrite('result.png', result['output_png'])
  65. print(f'result file path is {osp.abspath("result.png")}')
  66. ```

致力于通过开放的社区合作,开源AI模型以及相关创新技术,推动基于模型即服务的生态繁荣发展