API for the Singapore Hansard NLP Model to perform NER and Sentiment Analysis. The model can be downloaded from the releases page. The backend was built using FastAPI and deployed with Docker on Google Cloud Platform cloud run.
- Clone Repo
git clone https://github.com/nus-cs3244-ml-singapore-7/sg-hansard-nlp-api.git
- Change directory
cd sg-hansard-nlp-api
- Download the models from releases and add it to the
finetuned_models
directory - Install virtual environment
virtualenv env
- Activate environment
env\Scripts\activate
- Install requirements
pip install -r requirements.txt
- Install pytorch cpu
pip install torch==1.7.1+cpu -f https://download.pytorch.org/whl/torch_stable.html
- Start the server
uvicorn main:app --host 0.0.0.0 --port 8080
- Create docker image
docker build -t <image_name>:<tag_name> .
- Login using gcloud CLI
gcloud auth login
- Tag the image in the correct format for deployment
docker tag <image_name>:<tag_name> gcr.io/<project_name>/<image_name>:<tag_name>
- Push to GCP container registry
docker push gcr.io/<project_name>/<image_name>:<tag_name>
- Go to GCP container registry and deploy using cloud run