{"id":15982232,"url":"https://github.com/xingchensong/modulespack2","last_synced_at":"2026-06-10T06:34:17.852Z","repository":{"id":170567376,"uuid":"171832566","full_name":"xingchensong/ModulesPack2","owner":"xingchensong","description":"ModulesPack version2","archived":false,"fork":false,"pushed_at":"2019-03-20T07:11:36.000Z","size":74,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-01-10T10:22:54.395Z","etag":null,"topics":["api-wrapper","module-system","session-manager","web"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/xingchensong.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-02-21T08:36:47.000Z","updated_at":"2020-10-20T07:33:29.000Z","dependencies_parsed_at":null,"dependency_job_id":"a13c8f91-e627-4b71-9b0e-5368e0d3b52e","html_url":"https://github.com/xingchensong/ModulesPack2","commit_stats":{"total_commits":22,"total_committers":1,"mean_commits":22.0,"dds":0.0,"last_synced_commit":"cd128d4d2187f8e55cb04b7d0723b9274d9e83b2"},"previous_names":["xingchensong/modulespack2"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xingchensong%2FModulesPack2","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xingchensong%2FModulesPack2/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xingchensong%2FModulesPack2/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xingchensong%2FModulesPack2/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/xingchensong","download_url":"https://codeload.github.com/xingchensong/ModulesPack2/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241008969,"owners_count":19893259,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api-wrapper","module-system","session-manager","web"],"created_at":"2024-10-08T01:01:50.442Z","updated_at":"2026-06-10T06:34:12.832Z","avatar_url":"https://github.com/xingchensong.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# modulespack2\nmodulespack version2 (AKA mp2)\n\nThis is a Framework-Plugin that helps your Web API implement modular calls.\n\n这是一个可以实现**子功能模块化**的 Web API框架插件\n\nmodulespack的设计来源于这样的需求：\n很多语音模型并不是端到端进行的，比如传统的ASR就需要先经过声学模型，然后通过语言模型才能得到最终的识别结果，再比如一个训练好的Voice Conversion模型只负责把源语谱图转换为目标说话人语谱图，而前期处理过程(将音频转换为spec)和后期处理过程(将spec转换为音频，也就是Vocoder)是独立于VC的模型进行的，此时如果想要对外提供完整的VC服务，就必须经过这三个子过程，而modulespack要做的就是对这三个子功能进行**封装**\n\n一个典型的使用modulespack2的程序如下所示：\n\n\tfrom session import Session\n\tfrom graph import ModuleGraph\n\n\tgraph = ModuleGraph(JsonFile='module\\GraphLib\\RMSE_graph.json')\n\tsess = Session(ModuleLibPath='module\\ModuleLib')\n\tfeed_dic = {'firstadd':{'x1':1,'x2':2}}\n\n\tModuleTable,toposort = sess.build_graph(graph)\n\tresult = sess.run(fetches=toposort,ModuleTable=ModuleTable\n                                ,graph=graph,feed_dict=feed_dic)\n\n\nmodulespack2借鉴了tensorflow静态图的设计思想，子功能的**模块化**相当于在计算图中**节点化**，为此，mp2定义了 [ModuleGraph类](https://github.com/stephen-song/modulespack2/blob/master/graph/base.py#L7) 来描述节点的集合，同时定义了一种json文件来格式化描述节点与节点之间的数据流动关系。除此之外，mp2还定义了 [Session类](https://github.com/stephen-song/modulespack2/blob/master/session/base.py#L34) 来掌控静态图运行的全过程。\n\n以下面这张静态图为例：\n\n![静态图](https://img-blog.csdnimg.cn/20190315221020303.png)\n\n其对应的json文件定义在 [module/GraphLib/RMSE_graph.json](https://github.com/stephen-song/modulespack2/blob/master/module/GraphLib/RMSE_graph.json) 文件中\n\n![静态图与对应的json描述](https://wx2.sinaimg.cn/large/007Dlym2gy1g199ydsbttj30zk0k0afa.jpg)\n\n\u003e 在modulespack2例程里静态图的执行经历了四个过程：\n\u003e \n\u003e  1. 首先读取json文件创建graph\n\u003e  2. 创建session并构建初始节点(节点1 Firstadd)的feeddict\n\u003e  3. 调用session.build_graph构建运行所需要的资源\n\u003e  4. 调用session.run执行静态图并返回计算结果\n\n其中session通过调用 [build_graph](https://github.com/stephen-song/modulespack2/blob/master/session/base.py#L61) 函数得到该图的拓扑排序和每个节点的module实例：\n\n![拓扑排序](https://wx2.sinaimg.cn/large/007Dlym2gy1g199ydamqkj30zk0k00va.jpg)\n\n之后session调用 [run](https://github.com/stephen-song/modulespack2/blob/master/session/base.py#L130) 函数根据拓扑排序结果顺序执行每个module：\n\n![结果](https://wx3.sinaimg.cn/large/007Dlym2gy1g199ydjt7kj30zk0k0ah4.jpg)\n\n实例展示：\n使用django + modulespack2 搭建的Voice Conversion服务平台\n\nhttps://github.com/stephen-song/django_with_modulespack2\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxingchensong%2Fmodulespack2","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fxingchensong%2Fmodulespack2","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxingchensong%2Fmodulespack2/lists"}