将训练好的t2t模型加载到内存并开启api服务
- python2, tensorflow, tensor2tensor, flask-cors
- 安装配置tensorflow-serving
- 将t2t模型导出,与训练目录下的
/self_script
和/self_data
上传服务器指定目录t2t-exporter \ --t2t_usr_dir=self_script \ --problems=my_problem --data_dir=./self_data \ --model=lstm_seq2seq_attention \ --hparams_set=lstm_attention \ --output_dir=./train
- 开启tensorflow-server
OR
tensorflow_model_server \ --port=9000 \ --model_name=yourname \ --model_base_path=~/self_t2t/train/export/Servo
tensorflow_model_server –model_config_file=models.json –port=9000
- 安装tensorflow-serving-api
install tensorflow-serving-api
-
下载flask_tensor_api到指定目录
-
编辑conf.py文件
-
启动服务
gunicorn -c run.py app:app -p ./log/web.pid -D
-
查看服务
cat ./log/web.pid
https://spacewander.github.io/explore-flask-zh/5-configuration.html