Skip to content

javeria743/MLOPS-Text-Classification-Hugging-Face-Docker-and-Fast-Api

Repository files navigation

Text Classification API with FastAPI, Docker, and Hugging Face Transformers

This repository provides a robust and scalable API for text classification tasks. It leverages FastAPI for building a user-friendly RESTful API, Docker for containerization, and Hugging Face Transformers for pre-trained NLP models.

Key Features:

Real-time Text Classification: Analyze sentiment, emotions, or other categories from text data. Pre-trained Model: Utilizes a fine-tuned Hugging Face Transformer model for efficient classification. RESTful API: Easy integration with other applications through well-defined endpoints. Dockerized: Ensures consistent and portable deployment across environments. Swagger UI: Interactive documentation for API exploration and testing. Getting Started

Prerequisites: Python 3.6+ Docker Installation: Bash git clone https://github.com//.git cd pip install -r requirements.txt Use code with caution. Run the API: Bash docker build -t text-classification-api . docker run -d -p 8000:8000 text-classification-api:latest Use code with caution. The API will be accessible at http://localhost:8000/docs (Swagger UI). API Endpoints

GET /: Redirects to the Swagger UI for API documentation. POST /analyze/: Accepts JSON data with a "text" field and returns the classification results. Code Structure

main.py: Core application logic, defines endpoints, models, and integrates the pre-trained model. test.py: Unit tests for the API endpoints. Dockerfile: Defines the Docker image build process. requirements.txt: Lists all project dependencies. Technical Details

FastAPI: Web framework for building high-performance APIs. Hugging Face Transformers: Provides access to pre-trained NLP models. Docker: Enables containerization for easy deployment. Pydantic: Data validation and modeling for API requests and responses. NLTK: Library for text processing tasks (optional). Customization

This project provides a starting point for building your text classification solution. You can customize it by:

Using a different pre-trained model from Hugging Face. Expanding the API to support additional text classification tasks. Integrating the API with your existing application or workflow. Further Resources

Hugging Face Transformers: https://huggingface.co/docs/transformers/en/index FastAPI: https://github.com/tiangolo/full-stack-fastapi-template Docker: https://www.docker.com/

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published