https://github.com/thomd/spam-detection-with-fastapi-on-azure
Train a spam-detection model with SciKit-Learn and deploy as FastAPI app on Azure Container Instance
https://github.com/thomd/spam-detection-with-fastapi-on-azure
azure docker machine-learning python
Last synced: 26 days ago
JSON representation
Train a spam-detection model with SciKit-Learn and deploy as FastAPI app on Azure Container Instance
- Host: GitHub
- URL: https://github.com/thomd/spam-detection-with-fastapi-on-azure
- Owner: thomd
- Created: 2021-11-21T16:08:34.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2021-11-24T09:09:28.000Z (over 4 years ago)
- Last Synced: 2025-02-05T21:42:34.754Z (over 1 year ago)
- Topics: azure, docker, machine-learning, python
- Language: Python
- Homepage:
- Size: 213 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Spam Detection with SciKit-Learn, FastAPI on Azure Container Instance
## Dataset
The UCI [SMS Spam Collection](https://data.world/uci/sms-spam-collection) is a public
set of SMS labeled messages that have been collected for mobile phone spam research.
## Setup
Create environment:
conda create --name spam
conda activate spam
conda install --yes --file requirements.txt
Train spam classifier model:
python train.py
For local testing, start server and open SwaggerUI
uvicorn app:app --reload
open http://localhost:8000/docs
Test local endpoint:
curl http://localhost:8000/predict?message=I want your Money
## Build Docker Image
Build docker image and run docker container:
docker build -t spam .
docker run -d --rm --name spam -p 80:80 spam
## Deploy as Azure Container Instance
Use Azure Container Instances (ACI) to run serverless Docker containers in Azure.
Create Azure Container Registry (ACR):
az login
az group create -n -l
az acr create -g -n --sku Basic --admin-enabled true
az acr list -g -o table
Upload docker image to ACR
docker tag spam .azurecr.io/spam:v1
az acr login -n
docker push .azurecr.io/spam:v1
Create container (find username and password here: Portal > Container Registry > Access Keys)
az container create -g -n --image .azurecr.io/spam:v1 --dns-name-label --ports 80
az container show -g -n --query "{FQDN:ipAddress.fqdn,ProvisioningState:provisioningState}"
az container logs -g -n
Open SwaggerUI
open http://..azurecontainer.io
Delete resource group
az group delete -n