A simple Flask server for a fast.ai text classifier model. Included is the SMS classifier notebook which I used to train the model. I'll be adding details to the deploy steps.
Example:
0.0.0.0:8080/predict?sms=this%20is%20a%20text
{
"accuracy": 0.9927310347557068,
"prediction": "good"
}
- Setup a jupyter notebook project with the
sms-classifier.ipynbnotebook. - Change the
husheddirectory name to something that suits your application. - Download the Kaggle sms spam dataset: https://www.kaggle.com/uciml/sms-spam-collection-dataset
- (Optional) Add your own SMS collections and labels.
- Train your text classifier, at the end of the notebook the model will be exported as
export.pkl. - Copy the
export.pklfile into the data directory of the flask app.
You'll need to have docker installed on your machine to get through this part.
- Build the docker image:
docker build -t TextClassifier:latest - Run the docker image and make sure it works:
docker run -d -p 80:80 TextClassifier:latest, it'll be running on0.0.0.0.
You'll need an AWS account to get through this part.
- Search for ECR on the AWS web console, and then create a repository which will hold your docker image.
- Click on
view push commandsand follow the instructions to upload your image. - Follow Amazon's directions for deploying a docker container: https://aws.amazon.com/getting-started/tutorials/deploy-docker-containers/ . When you create the task definition paste in the image URI of the docker image you uploaded to ECR.