# model_server **Repository Path**: fubo_linux/model_server ## Basic Information - **Project Name**: model_server - **Description**: 模型服务 - **Primary Language**: Python - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2021-09-11 - **Last Updated**: 2021-09-11 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # model_server #### 介绍 模型服务 #### 软件架构 软件架构说明 #### 安装教程 1. xxxx 2. xxxx 3. xxxx #### 使用说明 1. 安装model_server库 pip install model_server-0.0.0.1-py3-none-any.whl 2. 快速体验 python -m model_server.demo INFO: Started server process [29723] 2021-09-11 17:18:04,021 server.py[line:84] INFO Started server process [29723] INFO: Waiting for application startup. 2021-09-11 17:18:04,021 on.py[line:45] INFO Waiting for application startup. INFO: Application startup complete. 2021-09-11 17:18:04,021 on.py[line:59] INFO Application startup complete. INFO: Uvicorn running on http://0.0.0.0:8908 (Press CTRL+C to quit) 2021-09-11 17:18:04,022 server.py[line:217] INFO Uvicorn running on http://0.0.0.0:8908 (Press CTRL+C to quit) #### 开发过程 1. 创建自己需要服务的模型目录 推荐的目录结构 ├── app.py └── models ├── dict │   └── labels.dic └── model_file.pt app.py是模型服务入口 models文件夹包含了模型需要的文件 2. 在app.py中开发模型服务需要的操作,具体内容可以参考demo.py文件中的注释 2.1 import Request, Response, Application from model_server.model_server import Request, Response, Application 2.2 定义请求参数 class EchoRequest(Request): # 输入的参数 text: str 2.3 定义返回值 class EchoResponse(Response): # 返回的数据 data: str 2.4 定义应用 class EchoApp(Application): def __init__(self, host: str = "0.0.0.0", port: int = 8908): super().__init__(host, port) 2.4.1、重写初始化操作 def resource_init(self) -> bool: """ 资源初始化 :return: """ return True 2.4.2、定义API接口和对应的处理函数 @staticmethod @Application.application.post("/echo", tags=["Echo"]) async def echo(request: EchoRequest) -> EchoResponse: if request.text is None or request.text == "": return EchoResponse(code=-1, message="No input", data="") return EchoResponse(code=0, message="success", data="[ECHO] %s" % request.text) 2.5 创建app对象并且.run()运行 if __name__ == '__main__': app = EchoApp() app.run() 2.6 使用python app.py启动服务 #### 参与贡献 1. Fork 本仓库 2. 新建 Feat_xxx 分支 3. 提交代码 4. 新建 Pull Request #### 特技 1. 使用 Readme\_XXX.md 来支持不同的语言,例如 Readme\_en.md, Readme\_zh.md 2. Gitee 官方博客 [blog.gitee.com](https://blog.gitee.com) 3. 你可以 [https://gitee.com/explore](https://gitee.com/explore) 这个地址来了解 Gitee 上的优秀开源项目 4. [GVP](https://gitee.com/gvp) 全称是 Gitee 最有价值开源项目,是综合评定出的优秀开源项目 5. Gitee 官方提供的使用手册 [https://gitee.com/help](https://gitee.com/help) 6. Gitee 封面人物是一档用来展示 Gitee 会员风采的栏目 [https://gitee.com/gitee-stars/](https://gitee.com/gitee-stars/)