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.

README.md 8.2 kB

5 years ago
5 years ago
5 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315
  1. # 之江天枢-算法端
  2. **之江天枢一站式人工智能开源平台**(简称:**之江天枢**),包括海量数据处理、交互式模型构建(包含Notebook和模型可视化)、AI模型高效训练。多维度产品形态满足从开发者到大型企业的不同需求,将提升人工智能技术的研发效率、扩大算法模型的应用范围,进一步构建人工智能生态“朋友圈”。
  3. ## 算法部署
  4. 源码部署
  5. 准备环境
  6. ubuntu系统 版本18.04及以上
  7. python 3.7+
  8. redis 5.0+
  9. oneflow 框架
  10. ## 下载源码
  11. ```shell
  12. $ git clone https://gitee.com/zhijiangtianshu/Dubhe.git
  13. ```
  14. ## 进入项目根目录
  15. ```shell
  16. $ cd dubhe_data_process
  17. ```
  18. ## 启动算法 (参数指定需要启动的算法)
  19. ```shell
  20. $ python main.py imgprocess False 127.0.0.1,6379,0,1234
  21. ```
  22. > 参数说明
  23. * imgprocess 表示启动的算法
  24. * False 表示是否需要GPU
  25. * 127.0.0.1,6379,0,1234分别表示redis的ip、端口、database、密码
  26. 具体部署流程请参考 http://tianshu.org.cn/?/course 中文档**部署数据处理算法**
  27. ## 快速上手:
  28. ### 代码结构:
  29. ```
  30. .
  31. ├── README.md
  32. ├── algorithm 预置算法程序目录
  33. │ ├── image-classification 图像分类
  34. │ ├── imgprocess 数据增强
  35. │ ├── lung-segmentation 医学分割
  36. │ ├── object-detection 目标检测
  37. │ ├── ofrecord ofrecord转换
  38. │ ├── text-classification 文本分类
  39. │ ├── track 目标跟踪
  40. │ └── videosample 采样
  41. ├── common 基础工具
  42. │ ├── __init__.py
  43. │ └── util
  44. │ ├── __init__.py
  45. │ └── public
  46. │ ├── RedisUtil.py redis链接操作工具类
  47. │ ├── __init__.py
  48. │ ├── json_util.py json处理工具类
  49. │ ├── logger_util.py 日志打印工具类
  50. │ └── select_gpu.py gpu工具类(主要用于需要gpu的算法启动时切换gpu卡槽所用)
  51. ├── execute
  52. │ ├── execute.py 具体任务处理类
  53. │ └── lua_script.py 操作任务操作脚本
  54. ├── docker-image 预置算法镜像
  55. │ ├── image-classification
  56. │ │ ├── Dockerfile
  57. │ │ ├── Python-3.7.4.tgz
  58. │ │ ├── README.md
  59. │ │ └── sources.list
  60. │ ├── imgprocess
  61. │ │ ├── Dockerfile
  62. │ │ ├── README.md
  63. │ │ ├── imgprocess-hpa.yaml
  64. │ │ ├── imgprocess.yaml
  65. │ │ └── sources.list
  66. │ ├── lung-segmentation
  67. │ ├── object-detection
  68. │ ├── ofrecord
  69. │ ├── text-classification
  70. │ ├── truck
  71. │ └── videosample
  72. ├── log
  73. │ └── log_2022-05-26.txt
  74. └── main.py 算法启动主入口
  75. ```
  76. ### 程序执行流程说明
  77. ![任务流程说明](image/%E7%AE%97%E6%B3%95%E7%A8%8B%E5%BA%8F%E6%89%A7%E8%A1%8C%E6%B5%81%E7%A8%8B.drawio.png)
  78. > 其中初始化模型和调用推理接口两个方法需要满足系统要求
  79. * 文件要在算法根目录下且名称要固定为inference.py
  80. * 方法名称要固定为load(记载模型方法)及inference(推理方法)
  81. 如下案例:
  82. ```python
  83. import annotation as ann
  84. def load():
  85. """
  86. 加载
  87. """
  88. print("加载")
  89. ann._init()
  90. def inference(task):
  91. """
  92. 推理
  93. """
  94. return ann.execute(task)
  95. ```
  96. ### 算法接入:
  97. ![算法接入流程](image/access-process.drawio.png)
  98. #### 编写算法程序
  99. 编写算法程序需要注意:
  100. * 需要在算法推理接口前增加inference.py文件来实现模型的加载以及对外推理服务的入口
  101. * 如果算法需要加载模型权重,则需要把模型权重放到根目录下的model目录中
  102. * 算法程序推理接口入参以及推理结果需要满足系统要求
  103. > 目标检测
  104. 推理参数
  105. ```json
  106. {
  107. "files": [
  108. {
  109. "datasetId": 1,
  110. "id": 1,
  111. "name": "000000034139_ts48PFzrS0bz",
  112. "url": "/nfs/dubhe-prod/dataset/1/origin/000000034139_ts48PFzrS0bz.jpg"
  113. }
  114. ],
  115. "labels": [
  116. "person",
  117. "bicycle",
  118. "car"
  119. ],
  120. "taskId": 1
  121. }
  122. ```
  123. 推理结果
  124. ```json
  125. {
  126. 'reTaskId': 'e3cd424c-5a7a-4278-9636-6d0d5f16b713',
  127. 'annotations': [
  128. {
  129. 'id': 1,
  130. 'annotation': '[{"area": 36354.28243389582, "score": 0.9814451932907104, "iscrowd": 0, "category_id": "keyboard", "bbox": [74.66009259223938, 372.6794943213463, 272.36245572566986, 133.477583527565], "segmentation": [[74.66009259223938, 372.6794943213463, 347.02254831790924, 372.6794943213463, 347.02254831790924, 506.1570778489113, 74.66009259223938, 506.1570778489113]]}]'
  131. }
  132. ]
  133. }
  134. ```
  135. > 图像分类
  136. 推理参数
  137. ```json
  138. {
  139. "files": [
  140. {
  141. "datasetId": 2,
  142. "id": 2,
  143. "name": "000000001584_tslXA6yhxzEW",
  144. "url": "/nfs/dubhe-prod/dataset/2/origin/000000001584_tslXA6yhxzEW.jpg"
  145. }
  146. ],
  147. "labels": [
  148. "tench, Tinca tinca",
  149. "goldfish, Carassius auratus",
  150. "great white shark, white shark, man-eater, man-eating shark, Carcharodon carcharias",
  151. "tiger shark, Galeocerdo cuvieri"
  152. ],
  153. "taskId": 2
  154. }
  155. ```
  156. 推理结果
  157. ```json
  158. {
  159. 'annotations': [{
  160. 'id': 2,
  161. 'annotation': '[{"category_id": "meat loaf, meatloaf", "score": 0.8088632822036743}]'
  162. }]
  163. }
  164. ```
  165. > 文本分类
  166. 推理参数
  167. ```json
  168. {
  169. "files": [
  170. {
  171. "datasetId": 1,
  172. "id": 1,
  173. "name": "000000034139_ts48PFzrS0bz",
  174. "url": "/nfs/dubhe-prod/dataset/1/origin/000000034139_ts48PFzrS0bz.jpg"
  175. }
  176. ],
  177. "labels": [
  178. "person",
  179. "bicycle",
  180. "car"
  181. ],
  182. "taskId": 1
  183. }
  184. ```
  185. 推理结果
  186. ```json
  187. {
  188. "classifications": [{"annotation": "[{"category_id": "negative", "score": 0.7944}]", "id": 24340856}]
  189. }
  190. ```
  191. > 器官分割
  192. 推理参数
  193. ```json
  194. {
  195. "annotationPath": "/nfs/dubhe-open-dev/dataset/dcm/346/annotation",
  196. "dcms":
  197. [
  198. "/nfs/dubhe-open-dev/dataset/dcm/346/origin/000144.dcm",
  199. "/nfs/dubhe-open-dev/dataset/dcm/346/origin/000145.dcm",
  200. "/nfs/dubhe-open-dev/dataset/dcm/346/origin/000146.dcm",
  201. "/nfs/dubhe-open-dev/dataset/dcm/346/origin/000147.dcm"
  202. ],
  203. "medicineFileIds":
  204. [
  205. "29756",
  206. "29757",
  207. "29758",
  208. "29759"
  209. ],
  210. "taskId": "5130"
  211. }
  212. ```
  213. 推理结果
  214. ```json
  215. [
  216. {
  217. "id": "29256",
  218. "annotations": [{"type": 0, "annotation": []}]
  219. }
  220. ]
  221. ```
  222. > 目标跟踪
  223. 推理参数
  224. ```json
  225. {
  226. "path": "/nfs/dubhe-open-dev/dataset/5359/versionFile/V0001",
  227. "images":
  228. [
  229. "GE44-S-w5m_ts2UPN6pQv2__1.jpg",
  230. "GE44-S-w5m_ts2UPN6pQv2__101.jpg"
  231. ],
  232. "labels":
  233. [
  234. "81",
  235. "82"
  236. ]
  237. }
  238. ```
  239. 推理结果
  240. 无。目标跟踪算法会直接修改标注文件写入实体ID。
  241. #### 算法程序上传
  242. 登录天枢平台,在算法管理和模型管理中上传开发的算法程序(需要把算法和模型分开打包为压缩包,并且压缩包解压后文件结构和原始一样不能存在增加多余层级)。
  243. #### 镜像上传
  244. 用户需要根据自己的算法环境编写Dockfile并制作镜像(如果上传系统提供算法对应镜像,则可以在docker-image中找到对应Dockerfile),完成后把镜像保存为压缩文件并通过天枢平台镜像管理进行上传即可。
  245. #### 算法部署
  246. 登录天枢平台打开`数据管理`->`标注服务管理`页面,点击`创建服务`按钮,在弹窗中根据需要填写以及选择对应算法、模型、镜像等,选择完成后点击`确定`即可,此时刷新列表页面,便可以看到刚才创建的服务,可以根据需要点击对应按钮
  247. <center>
  248. <div style="display: inline-block"> 1- 创建模型服务</div>
  249. <img src="image/create.png"/>
  250. </center>
  251. <center>
  252. <div style="display: inline-block"> 1- 查看服务日志</div>
  253. <img src="image/check_log.png"/>
  254. </center>

一站式算法开发平台、高性能分布式深度学习框架、先进算法模型库、视觉模型炼知平台、数据可视化分析平台等一系列平台及工具,在模型高效分布式训练、数据处理和可视分析、模型炼知和轻量化等技术上形成独特优势,目前已在产学研等各领域近千家单位及个人提供AI应用赋能