Skip to content

Flask API for sentiment classification using Hugging Face's fine-tuned model.

Notifications You must be signed in to change notification settings

pachecowillians/Finetuned-Model-API

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Finetuned Model API

Flask API for sentiment classification using Hugging Face's fine-tuned model.

Getting Started

Prerequisites

  • Docker
  • Python 3.8 or higher

Installing

  1. Clone the repository:

    git clone https://github.com/pachecowillians/Finetuned-Model-API.git
    cd Finetuned-Model-API
  2. Run the API:

    docker-compose up --build

    The API will be available at http://localhost:5000/api/classify.

  3. Train the Model:

    python training/finetune_model.py

Running Tests with pytest

Using Docker

To run tests with Docker, make sure the Docker container is running. Then, execute the following command:

docker exec -it finetuned-model-api pytest app/tests

Local Testing

To run tests locally without Docker, follow these steps:

  1. Install the required dependencies:

    pip install -r requirements.txt
  2. Make sure the API is not running locally on port 5000.

  3. Execute the following command to run the tests:

    pytest app/tests

This will run the tests using pytest locally.

API Endpoints

Classify Text

Endpoint:

POST /api/classify

Request:

{
  "text": "This is a positive example."
}

Response:

{
  "text": "This is a positive example.",
  "predicted_class": "positive",
  "class_probabilities": [0.013937118053436756, 0.9860628843307495]
}

Built With

  • Flask - Web framework
  • Hugging Face Transformers - Natural language processing library

About

Flask API for sentiment classification using Hugging Face's fine-tuned model.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published