Teslim Olunlade commited on
Commit
1797f88
·
1 Parent(s): c893290

Created streamlit app

Browse files
Files changed (3) hide show
  1. README.md +8 -1
  2. app/main.py +33 -3
  3. app/requirements.txt +88 -0
README.md CHANGED
@@ -1,6 +1,13 @@
1
  # Datamining Project
2
 
3
- Milestone 1
 
 
 
 
 
 
 
4
 
5
  ## Requirements
6
 
 
1
  # Datamining Project
2
 
3
+ Milestone 2
4
+
5
+ ```yaml
6
+ title: Toxic Tweets
7
+ sdk: streamlit
8
+ app_file: app/main.py
9
+ pinned: false
10
+ ```
11
 
12
  ## Requirements
13
 
app/main.py CHANGED
@@ -1,4 +1,34 @@
1
- print("Hello, world!")
 
 
 
 
 
2
 
3
- while 1:
4
- continue
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from transformers import AutoTokenizer
3
+ from transformers import (
4
+ TFAutoModelForSequenceClassification as AutoModelForSequenceClassification,
5
+ )
6
+ from transformers import pipeline
7
 
8
+ st.title("Toxic Tweets")
9
+
10
+ text = st.text_area("Input text", "", height=275)
11
+
12
+ model_name = st.selectbox(
13
+ "Select the model you want to use below.",
14
+ (
15
+ "distilbert-base-uncased-finetuned-sst-2-english",
16
+ "cardiffnlp/twitter-roberta-base-sentiment",
17
+ "finiteautomata/bertweet-base-sentiment-analysis",
18
+ "ProsusAI/finbert",
19
+ ),
20
+ )
21
+
22
+ tokenizer = AutoTokenizer.from_pretrained(model_name)
23
+ model = AutoModelForSequenceClassification.from_pretrained(model_name)
24
+ clf = pipeline(
25
+ "sentiment-analysis", model=model, tokenizer=tokenizer, return_all_scores=True
26
+ )
27
+
28
+ input = tokenizer(text, return_tensors="tf")
29
+
30
+ if st.button("Submit", type="primary"):
31
+ results = clf(text)[0]
32
+ classes = dict(d.values() for d in results)
33
+ # st.write(f"The sentiment is {results}.")
34
+ st.bar_chart(classes)
app/requirements.txt CHANGED
@@ -0,0 +1,88 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ absl-py==1.4.0
2
+ altair==4.2.2
3
+ astunparse==1.6.3
4
+ attrs==22.2.0
5
+ blinker==1.6
6
+ cachetools==5.3.0
7
+ certifi==2022.12.7
8
+ charset-normalizer==3.1.0
9
+ click==8.1.3
10
+ decorator==5.1.1
11
+ entrypoints==0.4
12
+ filelock==3.10.7
13
+ flatbuffers==2.0.7
14
+ gast==0.4.0
15
+ gitdb==4.0.10
16
+ GitPython==3.1.31
17
+ google-auth==2.17.2
18
+ google-auth-oauthlib==0.4.6
19
+ google-pasta==0.2.0
20
+ grpcio==1.53.0
21
+ h5py==3.8.0
22
+ huggingface-hub==0.13.3
23
+ idna==3.4
24
+ importlib-metadata==6.1.0
25
+ Jinja2==3.1.2
26
+ jsonschema==4.17.3
27
+ keras==2.11.0
28
+ keras-nlp==0.4.1
29
+ libclang==16.0.0
30
+ Markdown==3.4.3
31
+ markdown-it-py==2.2.0
32
+ MarkupSafe==2.1.2
33
+ mdurl==0.1.2
34
+ numpy==1.24.2
35
+ oauthlib==3.2.2
36
+ onnx==1.12.0
37
+ onnxconverter-common==1.13.0
38
+ opt-einsum==3.3.0
39
+ packaging==23.0
40
+ pandas==1.5.3
41
+ Pillow==9.5.0
42
+ protobuf==3.19.6
43
+ pyarrow==11.0.0
44
+ pyasn1==0.4.8
45
+ pyasn1-modules==0.2.8
46
+ pydeck==0.8.0
47
+ Pygments==2.14.0
48
+ Pympler==1.0.1
49
+ pyrsistent==0.19.3
50
+ python-dateutil==2.8.2
51
+ pytz==2023.3
52
+ pytz-deprecation-shim==0.1.0.post0
53
+ PyYAML==6.0
54
+ regex==2023.3.23
55
+ requests==2.28.2
56
+ requests-oauthlib==1.3.1
57
+ rich==13.3.3
58
+ rsa==4.9
59
+ semver==3.0.0
60
+ six==1.16.0
61
+ smmap==5.0.0
62
+ streamlit==1.20.0
63
+ tensorboard==2.11.2
64
+ tensorboard-data-server==0.6.1
65
+ tensorboard-plugin-wit==1.8.1
66
+ tensorflow==2.11.1
67
+ tensorflow-cpu==2.11.1
68
+ tensorflow-estimator==2.11.0
69
+ tensorflow-hub==0.13.0
70
+ tensorflow-io-gcs-filesystem==0.32.0
71
+ tensorflow-text==2.11.0
72
+ termcolor==2.2.0
73
+ tf2onnx==1.14.0
74
+ tokenizers==0.13.3
75
+ toml==0.10.2
76
+ toolz==0.12.0
77
+ tornado==6.2
78
+ tqdm==4.65.0
79
+ transformers==4.27.4
80
+ typing_extensions==4.5.0
81
+ tzdata==2023.3
82
+ tzlocal==4.3
83
+ urllib3==1.26.15
84
+ validators==0.20.0
85
+ watchdog==3.0.0
86
+ Werkzeug==2.2.3
87
+ wrapt==1.15.0
88
+ zipp==3.15.0