There is a lack of simple documentation on to train a model for classification and save it using keras for Tensorflow Serving. Hopefully this example will lighten the way to productionize AI.
Clone Repo
git clone git clone https://github.com/brianalois/iris_keras_tensorflow_serving.git
cd iris_keras_tensorflow_serving
I am using pipenv in order to standardize environments, kind or like the famous NPM for node
pip install pipenv
or if you are using mac install with homebrew
brew install pipenv
run this in the repo directory, installs files from Pipfile
pipenv install
pipenv run python index.py
If you do not want to use pipenv then you must install these dependencies You must have tensorflow keras, and numpy installed(obviously)
pip install numpy
pip install tensorflow keras pandas sklearn
run the file to export the trained model
python index.py
There are 2 variables starting at line 18
model_version: change this to change the name of the folder of the specific model version
model_version = "1"
epoch: the higher this number is the more accurate the model, but the longer it will take to train. 5000 is good, but may take a while
epoch = 100