Sentiment Analysis based on Tensorflow2.0 Kears with deploy
python3
tensorflow >= 2.0
The data provided in the data/
directory is a csv file
In data_util.py
I provide some funtions to process the csv file.
This contains several steps:
- Before you can get started on training the model, you mast run
python data_util.py
- After the dirty preprpcessing jobs, you can try running an training experiment with some configurations by:
python train.py
- After that, you get a fold named "my_cls_model", you can copy the fold to the deploy machine. And run:
# install docker
sudo apt-get install docker # ignore if you have already install docker
# deploy serveing
docker pull tensorflow/serving
# ignore steps above if you have already installed docker
docker run -it --rm -p 8500:8500 -p 8501:8501 -v "/my_cls_model:/models/my_cls_model" -e MODEL_NAME=my_cls_model tensorflow/serving
- After the server is done, the you can run:
python server_test.py
to test the server connection is good.
- Then you need start the Flask by:
python app.py
- Finally you can send the request to serving by:
python simple_request.py
Follow the instruction. Hope you enjoy it.
Using Tensorflow2.0 Keras to deply sentiment analysis model from scratch .
├── data - this fold contains all the data
│ ├── train
│ ├── dev
│ ├── test
│ ├── vocab
| ├── vec
├── my_cls_model - this fold contains the pb file to restore
├── train.py - main entrance of the project
├── data_util.py - preprocess the data
├── load_data.py - data generator
├── server_test.py - test if net works after deploy
├── app.py - use flask
├── simple_request.py - use rest to send query
- Still need parameters searching.
- Need structure changing to satisfy parameters chosing.
- Make codes nicer.