mohsinabbas1984 commited on
Commit
25b0a1e
1 Parent(s): a62190e

Upload README.Docker.md

Browse files
Files changed (1) hide show
  1. README.Docker.md +66 -0
README.Docker.md ADDED
@@ -0,0 +1,66 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Text Classification API
2
+ **FastAPI, Docker, and Hugging Face Transformers**\
3
+ This API provides text classification capabilities using a pre-trained model for sentiment analysis. It allows users to analyze the sentiment of text inputs and obtain the corresponding sentiment labels.
4
+ - The API has been built using the Hugging Face `transformers` library.
5
+ - It uses the following pre-trained transformer model from Hugging Face:
6
+ - `cardiffnlp/twitter-roberta-base-sentiment-latest`
7
+ - It classifies the text as `positive`, `negative`, or `neutral`.
8
+
9
+ ## Table of Contents
10
+ - [Text Classification API](#text-classification-api)
11
+ - [Table of Contents](#table-of-contents)
12
+ - [Introduction](#introduction)
13
+ - [Installation](#installation)
14
+ - [Usage](#usage)
15
+ - [Documentation](#documentation)
16
+ - [Building and Running the Docker Container](#building-and-running-the-docker-container)
17
+ - [Interacting with the API](#interacting-with-the-api)
18
+ - [Acknowledgments](#acknowledgments)
19
+ - [License](#license)
20
+
21
+ ## Introduction
22
+ This API is built using FastAPI and leverages a pre-trained sentiment analysis model from the Hugging Face model hub. It preprocesses the input text and passes it through the model to classify the sentiment as positive, negative, or neutral.
23
+
24
+ ## Installation
25
+ To install and run the API locally, follow these steps:
26
+
27
+ 1. Clone this repository to your local machine.
28
+ 2. Ensure you have Docker installed.
29
+ 3. Change the port to 8000 in the Dockerfile.
30
+ 4. Build the Docker container using the provided Dockerfile.
31
+ 5. Run the Docker container.
32
+
33
+ ## Usage
34
+ To use the API, send HTTP requests to the appropriate endpoints. The API provides the following endpoints:
35
+
36
+ - `GET /`: Welcome endpoint, returns a greeting message.
37
+ - `POST /analyze/{text}`: Analyze endpoint, classifies the sentiment of the provided text.
38
+
39
+ ## Documentation
40
+ The API is documented using FastAPI's automatic documentation features. You can access the API documentation using the Swagger UI or ReDoc interface. Simply navigate to the appropriate URL after starting the API server.
41
+
42
+ - **Swagger UI** `http://localhost:8000/docs`
43
+ - **ReDoc** `http://localhost:8000/redoc`
44
+
45
+ ## Building and Running the Docker Container
46
+ To build and run the Docker container, follow these steps:
47
+ 1. Navigate to the folder in which your FastAPI app resides.
48
+ 2. Build a Docker image using the following command
49
+ ```
50
+ docker build -t text-classification-api .
51
+ ```
52
+ 3. Containerize the application by creating a Docker container from the built image
53
+ ```
54
+ docker run -d -p 8000:8000 text-classification-api
55
+ ```
56
+ 4. The API will be available at `http://localhost:8000`
57
+ 5. The API documentaion will be avaialable at `http://localhost:8000/docs` or `http://localhost:8000/redoc`
58
+
59
+ ## Interacting with the API
60
+ Once the API is running, you can interact with it using HTTP requests.
61
+
62
+ ## Acknowledgments
63
+ This API was built with inspiration from various open-source projects and libraries. Special thanks to the developers and contributors of FastAPI, Hugging Face Transformers, and NLTK.
64
+
65
+ ## License
66
+ This project is licensed under the [Apache license version 2.0](LICENSE).