Dockerized WebAPI using model RUSpam/spam_deberta_v4
Live URL: https://spamai.splidex.com/predict
curl -X POST https://spamai.splidex.com/predict -H "Content-Type: application/json" -d '{ "text": "Привет! Ищешь заработок в интернете?" }'
Create container in one row:
docker run -d -p 8080:8080 --name spamai ghcr.io/bvdcode/spamai
Send test request:
curl -X POST http://localhost:8080/predict -H "Content-Type: application/json" -d '{ "text": "Привет! Ищешь заработок в интернете?" }'
Response:
{
"isSpam": true
}This project is a simple web API for spam detection using a pre-trained model. It is built with Flask and utilizes the Hugging Face Transformers library for text classification.
Sources
├── app.py # Main entry point of the application
├── model_utils.py # Model loading and prediction logic
├── Dockerfile # Dockerfile for containerization
└── .dockerignore # Files to ignore in Docker build
To run this project locally, you need to have Python installed. You can install the required dependencies using pip:
pip install -r requirements.txt
You can run the application using the following command:
python app.py
The API will be available at http://127.0.0.1:5000/predict.
This endpoint accepts a JSON body with the following structure:
{
"text": "Your text here"
}It returns a JSON response indicating whether the text is classified as spam:
{
"isSpam": true
}If you want to download the model, you can run the application with the argument download-model:
python app.py download-model
This will download the necessary model files to your local environment.
To build and run the application in a Docker container, use the following commands:
- Build the Docker image:
docker build -t spam-detection-api .
- Run the Docker container:
docker run -p 5000:5000 spam-detection-api
The API will be accessible at http://localhost:5000/predict.
This project is licensed under the MIT License.