QuophyDzifa commited on
Commit
fe518b8
1 Parent(s): 8d9e717
.gitattributes ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ *.7z filter=lfs diff=lfs merge=lfs -text
2
+ *.arrow filter=lfs diff=lfs merge=lfs -text
3
+ *.bin filter=lfs diff=lfs merge=lfs -text
4
+ *.bz2 filter=lfs diff=lfs merge=lfs -text
5
+ *.ckpt filter=lfs diff=lfs merge=lfs -text
6
+ *.ftz filter=lfs diff=lfs merge=lfs -text
7
+ *.gz filter=lfs diff=lfs merge=lfs -text
8
+ *.h5 filter=lfs diff=lfs merge=lfs -text
9
+ *.joblib filter=lfs diff=lfs merge=lfs -text
10
+ *.lfs.* filter=lfs diff=lfs merge=lfs -text
11
+ *.mlmodel filter=lfs diff=lfs merge=lfs -text
12
+ *.model filter=lfs diff=lfs merge=lfs -text
13
+ *.msgpack filter=lfs diff=lfs merge=lfs -text
14
+ *.npy filter=lfs diff=lfs merge=lfs -text
15
+ *.npz filter=lfs diff=lfs merge=lfs -text
16
+ *.onnx filter=lfs diff=lfs merge=lfs -text
17
+ *.ot filter=lfs diff=lfs merge=lfs -text
18
+ *.parquet filter=lfs diff=lfs merge=lfs -text
19
+ *.pb filter=lfs diff=lfs merge=lfs -text
20
+ *.pickle filter=lfs diff=lfs merge=lfs -text
21
+ *.pkl filter=lfs diff=lfs merge=lfs -text
22
+ *.pt filter=lfs diff=lfs merge=lfs -text
23
+ *.pth filter=lfs diff=lfs merge=lfs -text
24
+ *.rar filter=lfs diff=lfs merge=lfs -text
25
+ *.safetensors filter=lfs diff=lfs merge=lfs -text
26
+ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
27
+ *.tar.* filter=lfs diff=lfs merge=lfs -text
28
+ *.tar filter=lfs diff=lfs merge=lfs -text
29
+ *.tflite filter=lfs diff=lfs merge=lfs -text
30
+ *.tgz filter=lfs diff=lfs merge=lfs -text
31
+ *.wasm filter=lfs diff=lfs merge=lfs -text
32
+ *.xz filter=lfs diff=lfs merge=lfs -text
33
+ *.zip filter=lfs diff=lfs merge=lfs -text
34
+ *.zst filter=lfs diff=lfs merge=lfs -text
35
+ *tfevents* filter=lfs diff=lfs merge=lfs -text
Copy of Fine-tuning Hugging face text classification model - Distiled Bert cased.ipynb DELETED
The diff for this file is too large to render. See raw diff
 
Copy of Fine-tuning Hugging face text classification model.ipynb DELETED
The diff for this file is too large to render. See raw diff
 
Fine-tuning Hugging face text classification model.ipynb DELETED
The diff for this file is too large to render. See raw diff
 
README.md CHANGED
@@ -1,2 +1,13 @@
1
- # NLP-Sentiment-Analysis
2
- This is an analysis that took peoples sentiments and classified into 3 categories and modeled with a pretrained model
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ title: Sentiment Analysis NLP
3
+ emoji: 🔥
4
+ colorFrom: red
5
+ colorTo: indigo
6
+ sdk: gradio
7
+ sdk_version: 3.44.3
8
+ app_file: app.py
9
+ pinned: false
10
+ license: mit
11
+ ---
12
+
13
+ Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
notebook/Fine-tuning Hugging face text classification model - _distilbert-base-uncased_.ipynb ADDED
The diff for this file is too large to render. See raw diff
 
notebook/Fine-tuning Hugging face text classification model - roberta-base.ipynb ADDED
The diff for this file is too large to render. See raw diff
 
Copy of Fine-tuning Hugging face text classification model - xlnet-base-cased.ipynb → notebook/Fine-tuning Hugging face text classification model - xlnet-base-cased.ipynb RENAMED
File without changes
src/app.py ADDED
@@ -0,0 +1,69 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # -*- coding: utf-8 -*-
2
+ # """gradio_app.ipynb
3
+
4
+ # Automatically generated by Colaboratory.
5
+
6
+ # Original file is located at
7
+ # https://colab.research.google.com/drive/1u8oKw0KTptVWpY-cKFL87N2IDDrM4lTc
8
+ # """
9
+ ##
10
+
11
+ import gradio as gr
12
+ import pandas as pd
13
+ import numpy as np
14
+ import pickle
15
+ from scipy.special import softmax
16
+ from transformers import AutoModelForSequenceClassification, AutoTokenizer, AutoConfig
17
+
18
+
19
+ # Requirements
20
+ model_path = "QuophyDzifa/Sentiment-Analysis-Model"
21
+ tokenizer = AutoTokenizer.from_pretrained(model_path)
22
+ config = AutoConfig.from_pretrained(model_path)
23
+ model = AutoModelForSequenceClassification.from_pretrained(model_path)
24
+
25
+
26
+ # Preprocess text (username and link placeholders)
27
+ def preprocess(text):
28
+ new_text = []
29
+ for t in text.split(" "):
30
+ t = '@user' if t.startswith('@') and len(t) > 1 else t
31
+ t = 'http' if t.startswith('http') else t
32
+ new_text.append(t)
33
+ return " ".join(new_text)
34
+
35
+
36
+ def sent_analysis(text):
37
+ text = preprocess(text)
38
+
39
+ # PyTorch-based models
40
+ encoded_input = tokenizer(text, return_tensors='pt')
41
+ output = model(**encoded_input)
42
+ scores_ = output[0][0].detach().numpy()
43
+ scores_ = softmax(scores_)
44
+
45
+ # Format output dict of scores
46
+ labels = {0: 'NEGATIVE', 1: 'NEUTRAL', 2: 'POSITIVE'}
47
+ scores = {labels[i]: float(s) for i, s in enumerate(scores_)}
48
+ return scores
49
+
50
+
51
+ demo = gr.Interface(
52
+ fn=sent_analysis,
53
+ inputs=gr.Textbox(placeholder="Share your thoughts on COVID vaccines..."),
54
+ outputs="label",
55
+ interpretation="default",
56
+ examples=[
57
+ ["I feel confident about covid vaccines"],
58
+ ["I do not like the covid vaccine"],
59
+ ["I like the covid vaccines"],
60
+ ["The covid vaccines are effective"]
61
+ ],
62
+ title="COVID Vaccine Sentiment Analysis",
63
+ description="An AI model that predicts sentiment about COVID vaccines, providing labels and probabilities for 'NEGATIVE', 'NEUTRAL', and 'POSITIVE' sentiments.",
64
+ theme="default",
65
+ live=True
66
+ )
67
+
68
+ if __name__ == "__main__":
69
+ demo.launch("0.0.0.0:7860")
src/requirements.txt ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ gradio==3.28.0
2
+ transformers==4.28.1
3
+ numpy==1.23.5
4
+ scikit-learn==1.3.0
5
+ torch
6
+ scipy==1.10.1
7
+ black
8
+
9
+
10
+
11
+
12
+
13
+
14
+
15
+ # gradio
16
+ # pandas
17
+ # transformers
18
+ # numpy
19
+ # scikit-learn
20
+ # gdown
21
+ # torch
22
+ # scipy
23
+
24
+ # tabulate
25
+ # seaborn
26
+ # datasets>=2.14.5
27
+ # transformers>=4.11.2
28
+ # huggingface-hub>=0.0.17s
29
+ # wordcloud>=1.8.1
30
+ # matplotlib>=3.4.3
31
+ # google-colab>=1.0.0
32
+ # datasets
33
+ # transformers
34
+ # huggingface-hub
35
+ # wordcloud
36
+ # matplotlib
37
+ # google-colab