Spaces:
Sleeping
Sleeping
sachiniyer
commited on
Commit
•
2829bae
0
Parent(s):
commit again
Browse files- .gitattributes +34 -0
- .python-version +1 -0
- README.md +12 -0
- app.py +67 -0
- requirements.txt +78 -0
- speech.txt +8 -0
- tweet.txt +1 -0
.gitattributes
ADDED
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
*.tflite filter=lfs diff=lfs merge=lfs -text
|
29 |
+
*.tgz filter=lfs diff=lfs merge=lfs -text
|
30 |
+
*.wasm filter=lfs diff=lfs merge=lfs -text
|
31 |
+
*.xz filter=lfs diff=lfs merge=lfs -text
|
32 |
+
*.zip filter=lfs diff=lfs merge=lfs -text
|
33 |
+
*.zst filter=lfs diff=lfs merge=lfs -text
|
34 |
+
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
.python-version
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
3.8
|
README.md
ADDED
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
title: Toxic Tweets
|
3 |
+
emoji: 🌍
|
4 |
+
colorFrom: gray
|
5 |
+
colorTo: green
|
6 |
+
sdk: streamlit
|
7 |
+
sdk_version: 1.17.0
|
8 |
+
app_file: app.py
|
9 |
+
pinned: false
|
10 |
+
---
|
11 |
+
|
12 |
+
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
app.py
ADDED
@@ -0,0 +1,67 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
import torch
|
3 |
+
import pandas as pd
|
4 |
+
import numpy as np
|
5 |
+
from transformers import pipeline, AutoModelForSequenceClassification, AutoTokenizer
|
6 |
+
|
7 |
+
st.title('Sentiment Analysis with Streamlit')
|
8 |
+
|
9 |
+
speech = ""
|
10 |
+
with open("tweet.txt") as file:
|
11 |
+
speech = "".join(line.rstrip() for line in file)
|
12 |
+
|
13 |
+
data = st.text_area(label="Text for Sentiment Analysis", value=speech)
|
14 |
+
|
15 |
+
models = ["sachiniyer/tweet_toxicity",
|
16 |
+
"distilbert-base-uncased-finetuned-sst-2-english",
|
17 |
+
"Ghost1/bert-base-uncased-finetuned_for_sentiment_analysis1-sst2",
|
18 |
+
"Seethal/sentiment_analysis_generic_dataset",
|
19 |
+
"sbcBI/sentiment_analysis_model",
|
20 |
+
"juliensimon/reviews-sentiment-analysis"]
|
21 |
+
|
22 |
+
model_name = st.selectbox(
|
23 |
+
'Which model do you want to use',
|
24 |
+
models)
|
25 |
+
|
26 |
+
|
27 |
+
labels = ["toxic", "severe toxic", "obscene", "threat", "insult", "identity hate"]
|
28 |
+
|
29 |
+
def score(item):
|
30 |
+
return item['score']
|
31 |
+
|
32 |
+
def get_tokens(data, model):
|
33 |
+
tokenizer = AutoTokenizer.from_pretrained("sachiniyer/tweet_toxicity")
|
34 |
+
tokens = tokenizer(data, return_tensors="pt")
|
35 |
+
return tokens
|
36 |
+
|
37 |
+
def get_out(tokens, model):
|
38 |
+
output = model(**tokens)
|
39 |
+
return output
|
40 |
+
|
41 |
+
def get_perc(output):
|
42 |
+
return torch.sigmoid(output.logits).detach().numpy()[0]
|
43 |
+
|
44 |
+
def get_dict(percs, data):
|
45 |
+
sorted_indices = np.argsort(percs)[-2:]
|
46 |
+
row = {"text": data,
|
47 |
+
"label 1": labels[sorted_indices[1]],
|
48 |
+
"perc 1": str(round(percs[sorted_indices[1]], 3)),
|
49 |
+
"label 2": labels[sorted_indices[0]],
|
50 |
+
"perc 2": str(round(percs[sorted_indices[0]], 3))}
|
51 |
+
return row
|
52 |
+
|
53 |
+
def get(data, model):
|
54 |
+
tokens = get_tokens(data, model)
|
55 |
+
output = get_out(tokens, model)
|
56 |
+
percs = get_perc(output)
|
57 |
+
d = get_dict(percs, data)
|
58 |
+
return pd.DataFrame([d])
|
59 |
+
|
60 |
+
if st.button('Run model'):
|
61 |
+
if model_name == "sachiniyer/tweet_toxicity":
|
62 |
+
model = AutoModelForSequenceClassification.from_pretrained("sachiniyer/tweet_toxicity")
|
63 |
+
d = get(data, model)
|
64 |
+
st.table(d)
|
65 |
+
else:
|
66 |
+
generator = pipeline(model=model_name)
|
67 |
+
st.markdown(generator(model_name))
|
requirements.txt
ADDED
@@ -0,0 +1,78 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
altair==4.2.2 ; python_version >= "3.8" and python_full_version < "3.9.7"
|
2 |
+
attrs==22.2.0 ; python_version >= "3.8" and python_full_version < "3.9.7"
|
3 |
+
backports-zoneinfo==0.2.1 ; python_version >= "3.8" and python_version < "3.9"
|
4 |
+
blinker==1.6 ; python_version >= "3.8" and python_full_version < "3.9.7"
|
5 |
+
cachetools==5.3.0 ; python_version >= "3.8" and python_full_version < "3.9.7"
|
6 |
+
certifi==2022.12.7 ; python_version >= "3.8" and python_full_version < "3.9.7"
|
7 |
+
charset-normalizer==3.1.0 ; python_version >= "3.8" and python_full_version < "3.9.7"
|
8 |
+
click==8.1.3 ; python_version >= "3.8" and python_full_version < "3.9.7"
|
9 |
+
cmake==3.26.1 ; platform_system == "Linux" and platform_machine == "x86_64" and python_version >= "3.8" and python_full_version < "3.9.7"
|
10 |
+
colorama==0.4.6 ; python_version >= "3.8" and python_full_version < "3.9.7" and platform_system == "Windows"
|
11 |
+
decorator==5.1.1 ; python_version >= "3.8" and python_full_version < "3.9.7"
|
12 |
+
entrypoints==0.4 ; python_version >= "3.8" and python_full_version < "3.9.7"
|
13 |
+
filelock==3.10.7 ; python_version >= "3.8" and python_full_version < "3.9.7"
|
14 |
+
gitdb==4.0.10 ; python_version >= "3.8" and python_full_version < "3.9.7"
|
15 |
+
gitpython==3.1.31 ; python_version >= "3.8" and python_full_version < "3.9.7"
|
16 |
+
huggingface-hub==0.13.3 ; python_version >= "3.8" and python_full_version < "3.9.7"
|
17 |
+
idna==3.4 ; python_version >= "3.8" and python_full_version < "3.9.7"
|
18 |
+
importlib-metadata==6.1.0 ; python_version >= "3.8" and python_full_version < "3.9.7"
|
19 |
+
importlib-resources==5.12.0 ; python_version >= "3.8" and python_version < "3.9"
|
20 |
+
jinja2==3.1.2 ; python_version >= "3.8" and python_full_version < "3.9.7"
|
21 |
+
jsonschema==4.17.3 ; python_version >= "3.8" and python_full_version < "3.9.7"
|
22 |
+
lit==16.0.0 ; platform_system == "Linux" and platform_machine == "x86_64" and python_version >= "3.8" and python_full_version < "3.9.7"
|
23 |
+
markdown-it-py==2.2.0 ; python_version >= "3.8" and python_full_version < "3.9.7"
|
24 |
+
markupsafe==2.1.2 ; python_version >= "3.8" and python_full_version < "3.9.7"
|
25 |
+
mdurl==0.1.2 ; python_version >= "3.8" and python_full_version < "3.9.7"
|
26 |
+
mpmath==1.3.0 ; python_version >= "3.8" and python_full_version < "3.9.7"
|
27 |
+
networkx==3.1 ; python_version >= "3.8" and python_full_version < "3.9.7"
|
28 |
+
numpy==1.24.2 ; python_version >= "3.8" and python_full_version < "3.9.7"
|
29 |
+
nvidia-cublas-cu11==11.10.3.66 ; platform_system == "Linux" and platform_machine == "x86_64" and python_version >= "3.8" and python_full_version < "3.9.7"
|
30 |
+
nvidia-cuda-cupti-cu11==11.7.101 ; platform_system == "Linux" and platform_machine == "x86_64" and python_version >= "3.8" and python_full_version < "3.9.7"
|
31 |
+
nvidia-cuda-nvrtc-cu11==11.7.99 ; platform_system == "Linux" and platform_machine == "x86_64" and python_version >= "3.8" and python_full_version < "3.9.7"
|
32 |
+
nvidia-cuda-runtime-cu11==11.7.99 ; platform_system == "Linux" and platform_machine == "x86_64" and python_version >= "3.8" and python_full_version < "3.9.7"
|
33 |
+
nvidia-cudnn-cu11==8.5.0.96 ; platform_system == "Linux" and platform_machine == "x86_64" and python_version >= "3.8" and python_full_version < "3.9.7"
|
34 |
+
nvidia-cufft-cu11==10.9.0.58 ; platform_system == "Linux" and platform_machine == "x86_64" and python_version >= "3.8" and python_full_version < "3.9.7"
|
35 |
+
nvidia-curand-cu11==10.2.10.91 ; platform_system == "Linux" and platform_machine == "x86_64" and python_version >= "3.8" and python_full_version < "3.9.7"
|
36 |
+
nvidia-cusolver-cu11==11.4.0.1 ; platform_system == "Linux" and platform_machine == "x86_64" and python_version >= "3.8" and python_full_version < "3.9.7"
|
37 |
+
nvidia-cusparse-cu11==11.7.4.91 ; platform_system == "Linux" and platform_machine == "x86_64" and python_version >= "3.8" and python_full_version < "3.9.7"
|
38 |
+
nvidia-nccl-cu11==2.14.3 ; platform_system == "Linux" and platform_machine == "x86_64" and python_version >= "3.8" and python_full_version < "3.9.7"
|
39 |
+
nvidia-nvtx-cu11==11.7.91 ; platform_system == "Linux" and platform_machine == "x86_64" and python_version >= "3.8" and python_full_version < "3.9.7"
|
40 |
+
packaging==23.0 ; python_version >= "3.8" and python_full_version < "3.9.7"
|
41 |
+
pandas==1.5.3 ; python_version >= "3.8" and python_full_version < "3.9.7"
|
42 |
+
pillow==9.5.0 ; python_version >= "3.8" and python_full_version < "3.9.7"
|
43 |
+
pkgutil-resolve-name==1.3.10 ; python_version >= "3.8" and python_version < "3.9"
|
44 |
+
protobuf==3.20.3 ; python_version >= "3.8" and python_full_version < "3.9.7"
|
45 |
+
pyarrow==11.0.0 ; python_version >= "3.8" and python_full_version < "3.9.7"
|
46 |
+
pydeck==0.8.0 ; python_version >= "3.8" and python_full_version < "3.9.7"
|
47 |
+
pygments==2.14.0 ; python_version >= "3.8" and python_full_version < "3.9.7"
|
48 |
+
pympler==1.0.1 ; python_version >= "3.8" and python_full_version < "3.9.7"
|
49 |
+
pyrsistent==0.19.3 ; python_version >= "3.8" and python_full_version < "3.9.7"
|
50 |
+
python-dateutil==2.8.2 ; python_version >= "3.8" and python_full_version < "3.9.7"
|
51 |
+
pytz-deprecation-shim==0.1.0.post0 ; python_version >= "3.8" and python_full_version < "3.9.7"
|
52 |
+
pytz==2023.3 ; python_version >= "3.8" and python_full_version < "3.9.7"
|
53 |
+
pyyaml==6.0 ; python_version >= "3.8" and python_full_version < "3.9.7"
|
54 |
+
regex==2023.3.23 ; python_version >= "3.8" and python_full_version < "3.9.7"
|
55 |
+
requests==2.28.2 ; python_version >= "3.8" and python_full_version < "3.9.7"
|
56 |
+
rich==13.3.3 ; python_version >= "3.8" and python_full_version < "3.9.7"
|
57 |
+
semver==3.0.0 ; python_version >= "3.8" and python_full_version < "3.9.7"
|
58 |
+
setuptools==67.6.1 ; platform_system == "Linux" and platform_machine == "x86_64" and python_version >= "3.8" and python_full_version < "3.9.7"
|
59 |
+
six==1.16.0 ; python_version >= "3.8" and python_full_version < "3.9.7"
|
60 |
+
smmap==5.0.0 ; python_version >= "3.8" and python_full_version < "3.9.7"
|
61 |
+
streamlit==1.20.0 ; python_version >= "3.8" and python_full_version < "3.9.7"
|
62 |
+
sympy==1.11.1 ; python_version >= "3.8" and python_full_version < "3.9.7"
|
63 |
+
tokenizers==0.13.3 ; python_version >= "3.8" and python_full_version < "3.9.7"
|
64 |
+
toml==0.10.2 ; python_version >= "3.8" and python_full_version < "3.9.7"
|
65 |
+
toolz==0.12.0 ; python_version >= "3.8" and python_full_version < "3.9.7"
|
66 |
+
torch==2.0.0 ; python_version >= "3.8" and python_full_version < "3.9.7"
|
67 |
+
tornado==6.2 ; python_version >= "3.8" and python_full_version < "3.9.7"
|
68 |
+
tqdm==4.65.0 ; python_version >= "3.8" and python_full_version < "3.9.7"
|
69 |
+
transformers==4.27.4 ; python_version >= "3.8" and python_full_version < "3.9.7"
|
70 |
+
triton==2.0.0 ; platform_system == "Linux" and platform_machine == "x86_64" and python_version >= "3.8" and python_full_version < "3.9.7"
|
71 |
+
typing-extensions==4.5.0 ; python_version >= "3.8" and python_full_version < "3.9.7"
|
72 |
+
tzdata==2023.3 ; python_version >= "3.8" and python_full_version < "3.9.7"
|
73 |
+
tzlocal==4.3 ; python_version >= "3.8" and python_full_version < "3.9.7"
|
74 |
+
urllib3==1.26.15 ; python_version >= "3.8" and python_full_version < "3.9.7"
|
75 |
+
validators==0.20.0 ; python_version >= "3.8" and python_full_version < "3.9.7"
|
76 |
+
watchdog==3.0.0 ; python_version >= "3.8" and python_full_version < "3.9.7" and platform_system != "Darwin"
|
77 |
+
wheel==0.40.0 ; platform_system == "Linux" and platform_machine == "x86_64" and python_version >= "3.8" and python_full_version < "3.9.7"
|
78 |
+
zipp==3.15.0 ; python_version >= "3.8" and python_full_version < "3.9.7"
|
speech.txt
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
Former President Donald Trump's remarks on the Ellipse on Jan. 6, urging his supporters to march on the Capitol as Congress was certifying the results of November's presidential election, are a key part of the case against Trump being made by House impeachment managers and are also being used by the lawyers who are defending him.
|
2 |
+
|
3 |
+
The House managers in Trump's Senate impeachment trial have already shown clips from the speech, in which Trump outlined a long list of grievances against the news media and against Republicans he deemed were insufficiently supportive, as well as a litany of false claims about how the election had been stolen from him.
|
4 |
+
Watch Live: Senate Votes To Acquit Trump In Historic 2nd Impeachment Trial
|
5 |
+
|
6 |
+
Democrats have pointed to one phrase in particular as they argue that Trump incited those present to march down Pennsylvania Avenue toward the Capitol.
|
7 |
+
|
8 |
+
"We fight like hell. And if you don't fight like hell, you're not going to have a country anymore," he said.
|
tweet.txt
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
Yo bitch Ja Rule is more succesful then you'll ever be whats up with you and hating you sad mofuckas...i should bitch slap ur pethedic white faces and get you to kiss my ass you guys sicken me. Ja rule is about pride in da music man. dont diss that shit on him. and nothin is wrong bein like tupac he was a brother too...fuckin white boys get things right next time.,
|