# pytorchService **Repository Path**: gitDux/pytorch-service ## Basic Information - **Project Name**: pytorchService - **Description**: 将Pytorch服务安装在服务器上,并用Flask实现http服务 - **Primary Language**: Python - **License**: Apache-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 2 - **Forks**: 0 - **Created**: 2021-12-30 - **Last Updated**: 2023-01-29 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README ## pytorchService ### 介绍 将Pytorch服务安装在服务器上,并用Flask实现http服务 主要参考链接: [**flask+pytorch**](https://www.jianshu.com/p/a4c4a89a771d) ### 软件架构 分两个文件夹 `./server` 和 `./client` 两个文件夹 - `./server` - `./temp` 文件夹用来存储临时图片二进制文件 - `./imagenet_class_index.json` 包含了ImageNet 中的key : value 对应值 - `./keys.py` 通过调用 `json` 来实现对上述文件的解码 - `main.py` 通过 `flask` 来实现一个简单的服务,处理客户端上传的图片,并通过 `pytorch` 来实现推理,最后通过 `keys.py` 来映射 。 - `requirements.txt` 列举了依赖 - `./client` - `./img` 包含待测试的图片 - `posttest.py` 服务端上产图片 ### 安装教程 1.安装 python 依赖 ```shell >>> sudo pip install -r ./server/requirements.txt #服务端 >>> sudo pip install -r ./client/requirements.txt #客户端 ``` 2.安装 Gunicorn 多进程工具 ```shell >>> sudo apt-get install gunicron ``` 3.安装 nginx 来实现代理 ```shell >>> sudo apt-get install nginx ``` #### 使用说明 1.单进程开启服务 ```shell >>> python ./server/main.py ``` 2.多进程开启服务 ```shell >>> gunicorn -c ./server/gunicorn.conf ./server/main:app ``` 3.客户端上传图片 ```shell # python posttest.py URL ImagePath >>> python ./client/main.py http://localhost:5555/run ./client/img/cat.jpg ``` ### 参与贡献 1.[flask+pytorch](https://www.jianshu.com/p/a4c4a89a771d) 2.`nginx -h`