智能文本分类系统安装部署手册
- 注意事项:
- 这个安装手册只适用于操作系统: centos7
- 安装部署步骤:
0, 拷贝必备文件:
1, 安装Anconda科学计算环境, 它包括python3, pip,pandas, numpy等科学计算包。
cd /root
curl -O https://repo.anaconda.com/archive/Anaconda3-5.2.0-Linux-x86_64.sh
sh Anaconda3-2019.07-Linux-x86_64.sh
# 配置~/.bashrc, 添加一行: export PATH=/root/anaconda/bin/:$PATH
2, 安装必备组件supervisor, nginx
yum install supervisor -y
yum install nginx -y
3, 安装项目需要的python工具包,uwsgi,tensorflow,keras,django等,我们使用requirements.txt一同安装。
cd /data/django-uwsgi/
pip install requirements.txt -r
4, 安装图数据库neo4j
# 生成yum镜像
rpm --import http://debian.neo4j.org/neotechnology.gpg.key
cat <<EOF> /etc/yum.repos.d/neo4j.repo
[neo4j]
name=Neo4j RPM Repository
baseurl=http://yum.neo4j.org/stable
enabled=1
gpgcheck=1
EOF
# 安装neo4j
yum install neo4j-3.3.5
`
# 使用自己的配置文件
cp /data/django-uwsgi/util/neo4j.conf /etc/neo4j/neo4j.conf
5, 启动图数据库并查看状态
# 启动
neo4j start
# 查看状态
neo4j status
6, 使用脚本生成图谱
python /data/django-uswgi/text_labeled/create_graph/build.py
7, 使用多进程脚本训练模型
cd /data/django-uwsgi/text_labeled/model_train/
python multiprocess_train.py
8, 安装docker并封装模型微服务
# 安装docker
yum install docker
# 使用docker拉取tensorflow-serving镜像。
docker pull tensorflow/serving
MODEL_PATH="/data/django-uwsgi/text_labeled/model_train"
# 使用docker run命令启动微服务
# 启动第一个模型
docker run -t --rm -p 8501:8501 \
-v "$MODEL_PATH/movie:/models/movie" \
-e MODEL_NAME=movie \
tensorflow/serving &
# 同理启动, 启动第二个模型
docker run -t --rm -p 8501:8502 \
-v "$MODEL_PATH/beauty:/models/beauty" \
-e MODEL_NAME=beauty \
tensorflow/serving &
# 更多模型以此类推
# 使用curl命令在终端进行测试。
curl -d '{"instances": [[1.0, 2.0, 5.0]]}' \
-X POST http://localhost:8501/v1/models/movie:predict
9, 使用supervisor启动nginx和uwsgi主服务
cd /data/django-uwsgi/text_labeled/
# 启动主服务
supervisord -c supervisor.conf
# 查看状态
supervisorctl status all
10, 使用脚本发送请求进行测试
python /data/django-uwsgi/test.py