devanshsrivastav commited on
Commit
c499248
β€’
1 Parent(s): 852f0c9

Updated README.md

Browse files
Files changed (2) hide show
  1. .gitignore +2 -1
  2. README.md +87 -14
.gitignore CHANGED
@@ -1,3 +1,4 @@
1
  .env
2
  .DS_Store
3
- tumai
 
 
1
  .env
2
  .DS_Store
3
+ tumai
4
+ venv
README.md CHANGED
@@ -5,36 +5,109 @@ sdk: streamlit
5
  sdk_version: "1.22.0"
6
  app_file: app.py
7
  ---
 
8
  # GoEmotions Dashboard - Analyzing Emotions in Text
9
 
10
- This is a Python script that uses Streamlit, Plotly, and the Hugging Face API to create a web-based dashboard for analyzing emotions in text.
 
 
11
 
12
- ## Requirements:
13
 
14
- Python 3.7 or higher
15
- Hugging Face API
 
 
 
 
 
 
 
 
16
 
17
- ## Installation
18
 
19
- - Clone this repository to your local machine.
20
- - Install the required packages using pip:
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
21
 
22
  ```bash
23
  pip install -r requirements.txt
24
  ```
25
 
26
- - Create a free account on the Hugging Face website to get an API key.
 
 
 
 
 
 
 
 
27
 
28
  - Create a `.env` file in the root directory of the project and add your
29
  - Hugging Face API key like this: `HF_API_KEY=<your_api_key_here>`
30
 
31
- ## Usage
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
32
 
33
- - Navigate to the root directory of the project.
34
- - Run the Streamlit app by typing `streamlit run app.py` or `python -m streamlit run app.py` in the command line.
35
- - For GitHub Codespaces, Run: `python -m streamlit run app.py --server.enableCORS false --server.enableXsrfProtection false`
36
 
37
  - A web-based dashboard will open in your default browser.
38
  - Type or paste a text input in the text box provided.
39
- - The dashboard will display the detected emotions in a set of gauges, with each gauge representing the intensity of a specific emotion category.
40
- - The gauge colors are based on a predefined color map for each emotion category.
 
5
  sdk_version: "1.22.0"
6
  app_file: app.py
7
  ---
8
+
9
  # GoEmotions Dashboard - Analyzing Emotions in Text
10
 
11
+ This is a Python script that uses Streamlit, Plotly, and the Hugging Face Inference API to create a web-based dashboard for analyzing emotions in text. Finally this dashboard is deployed on Hugging Face Spaces using GitHub Actions.
12
+
13
+ ## Pre-requisites:
14
 
15
+ - Python 3.7 or higher
16
 
17
+ ## Project Structure:
18
+ ```dir
19
+ GoEmotions/
20
+ β”œβ”€β”€ app.py
21
+ β”œβ”€β”€ requirements.txt
22
+ β”œβ”€β”€ .env
23
+ β”œβ”€β”€ README.md
24
+ β”œβ”€β”€ assets/
25
+ └── .github/workflows
26
+ ```
27
 
28
+ ## Setup
29
 
30
+ `Step 1` - Clone this repository to your local machine using the following command, or open the repository in GitHub Codespaces.
31
+
32
+ ```bash
33
+ git clone https://github.com/devansh-srivastav/GoEmotions.git
34
+ ```
35
+
36
+ `Step 2` - Create and activate a new python virtual environment: (This step can be skipped if working on GitHub Codespaces!)
37
+
38
+ ```bash
39
+ python -m venv venv
40
+ ```
41
+
42
+ ```bash
43
+ venv\Scripts\activate
44
+ ```
45
+
46
+ `Step 3` - Install the required packages using pip: (This step can be skipped if working on GitHub Codespaces as it automatically installs the requirements!)
47
 
48
  ```bash
49
  pip install -r requirements.txt
50
  ```
51
 
52
+ `Step 4`- Create a free account on the [Hugging Face website](https://huggingface.co/) and generate an API key (read).
53
+
54
+ `Step 5` - Navigate to the root directory of the project.
55
+
56
+ ```bash
57
+ cd GoEmotions
58
+ ```
59
+
60
+ `Step 6`
61
 
62
  - Create a `.env` file in the root directory of the project and add your
63
  - Hugging Face API key like this: `HF_API_KEY=<your_api_key_here>`
64
 
65
+ `Step 7` - Run the Streamlit app.
66
+
67
+ ```bash
68
+ streamlit run app.py
69
+ ```
70
+
71
+ or
72
+
73
+ ```bash
74
+ python -m streamlit run app.py
75
+ ```
76
+
77
+ - If you want to run this application on GitHub Codespaces, you will need to add the following flags to the `streamlit run` command:
78
+
79
+ ```bash
80
+ python -m streamlit run app.py --server.enableCORS false --server.enableXsrfProtection false
81
+ ```
82
+
83
+ ## Deployment to Spaces (CI/CD)
84
+
85
+ `Step 1`
86
+ Commit your code and push it to your GitHub repository
87
+
88
+ `Step 2`
89
+ Create a new Space on Hugging Face, add it as an additional remote to git and force push your code on Spaces:
90
+
91
+ ```bash
92
+ git remote add space https://huggingface.co/spaces/HF_USERNAME/SPACE_NAME
93
+ ```
94
+
95
+ ```bash
96
+ git push --force space main
97
+ ```
98
+
99
+ `Step 3`
100
+ In the main.yml, add your Hugging Face username and Space name to the variables 'HF_username' and 'HF_space_name'
101
+
102
+ `Step 4`
103
+ Create a new API key on Hugging Face (write) and add it as a secret to your GitHub Repository naming it as 'HF_TOKEN'.
104
+
105
+ `Step 5`
106
+ Trigger the CI/CD pipeline by a push or a pull request to your main branch.
107
 
108
+ ## Usage:
 
 
109
 
110
  - A web-based dashboard will open in your default browser.
111
  - Type or paste a text input in the text box provided.
112
+ - The dashboard will visualise the detected emotions in a set of gauges, with each gauge representing the intensity of a specific emotion category. The gauge colors are based on a predefined color map for each emotion category.
113
+ - Moreover, the dashboard will display the results from Hate Speech Analysis and Sexism Detection models.