adjusted visuals of the app
Browse files- __pycache__/preprocessing.cpython-310.pyc +0 -0
- app.py +10 -10
- app_pages/page1_model_comparison.py +0 -43
- app_pages/page2_rubert_toxicity.py +0 -20
- app_pages/page3_gpt_model.py +0 -15
- models/__pycache__/bag_of_words_MODEL.cpython-310.pyc +0 -0
- models/__pycache__/gpt_MODEL.cpython-310.pyc +0 -0
- models/__pycache__/lstm_MODEL.cpython-310.pyc +0 -0
- models/__pycache__/rubert_MODEL.cpython-310.pyc +0 -0
- models/__pycache__/toxicity_MODEL.cpython-310.pyc +0 -0
- {app_models → models}/bag_of_words_MODEL.py +0 -0
- {app_models → models}/gpt_MODEL.py +0 -0
- {app_models → models}/lstm_MODEL.py +0 -0
- {app_models → models}/rubert_MODEL.py +0 -0
- {app_models → models}/toxicity_MODEL.py +0 -0
- pages/PalanikGPT.py +14 -0
- pages/ReviewClassification.py +43 -0
- pages/ToxicCommentDetector.py +19 -0
__pycache__/preprocessing.cpython-310.pyc
ADDED
Binary file (2.36 kB). View file
|
|
app.py
CHANGED
@@ -1,14 +1,14 @@
|
|
1 |
import streamlit as st
|
2 |
-
from transformers import AutoTokenizer, AutoModelForSequenceClassification
|
3 |
|
4 |
-
from app_pages import page1_model_comparison, page2_rubert_toxicity, page3_gpt_model
|
5 |
|
6 |
-
st.
|
7 |
-
selection = st.sidebar.radio("Go to", ["Model Comparison", "RuBERT Toxicity Detection", "GPT Model"])
|
8 |
|
9 |
-
if selection == "Model Comparison":
|
10 |
-
|
11 |
-
elif selection == "RuBERT Toxicity Detection":
|
12 |
-
|
13 |
-
elif selection == "GPT Model":
|
14 |
-
|
|
|
1 |
import streamlit as st
|
2 |
+
# from transformers import AutoTokenizer, AutoModelForSequenceClassification
|
3 |
|
4 |
+
# from app_pages import page1_model_comparison, page2_rubert_toxicity, page3_gpt_model
|
5 |
|
6 |
+
st.title('LSTM Team Natuaral Language Processing Project')
|
7 |
+
# selection = st.sidebar.radio("Go to", ["Model Comparison", "RuBERT Toxicity Detection", "GPT Model"])
|
8 |
|
9 |
+
# if selection == "Model Comparison":
|
10 |
+
# page1_model_comparison.run()
|
11 |
+
# elif selection == "RuBERT Toxicity Detection":
|
12 |
+
# page2_rubert_toxicity.run()
|
13 |
+
# elif selection == "GPT Model":
|
14 |
+
# page3_gpt_model.run()
|
app_pages/page1_model_comparison.py
DELETED
@@ -1,43 +0,0 @@
|
|
1 |
-
import streamlit as st
|
2 |
-
from app_models.rubert_MODEL import classify_text
|
3 |
-
from app_models.bag_of_words_MODEL import predict
|
4 |
-
from app_models.lstm_MODEL import predict_review
|
5 |
-
import time
|
6 |
-
|
7 |
-
class_prefix = 'This review is likely...'
|
8 |
-
|
9 |
-
def run():
|
10 |
-
st.title("Movie Review Classification")
|
11 |
-
st.write("This page will compare three models: Bag of Words/TF-IDF, LSTM, and BERT.")
|
12 |
-
|
13 |
-
# Example placeholder for user input
|
14 |
-
user_input = st.text_area("")
|
15 |
-
|
16 |
-
|
17 |
-
if st.button('Classify with All Models'):
|
18 |
-
# Measure and display Bag of Words/TF-IDF prediction time
|
19 |
-
start_time = time.time()
|
20 |
-
bow_tfidf_result = predict(user_input)
|
21 |
-
end_time = time.time()
|
22 |
-
st.write(f'{class_prefix} {bow_tfidf_result} according to Bag of Words/TF-IDF. Time taken: {end_time - start_time:.2f} seconds.')
|
23 |
-
|
24 |
-
# Measure and display LSTM prediction time
|
25 |
-
start_time = time.time()
|
26 |
-
lstm_result = predict_review(user_input)
|
27 |
-
end_time = time.time()
|
28 |
-
st.write(f'{class_prefix} {lstm_result} according to LSTM. Time taken: {end_time - start_time:.2f} seconds.')
|
29 |
-
|
30 |
-
# Measure and display ruBERT prediction time
|
31 |
-
start_time = time.time()
|
32 |
-
rubert_result = classify_text(user_input)
|
33 |
-
end_time = time.time()
|
34 |
-
st.write(f'{class_prefix} {rubert_result} according to ruBERT. Time taken: {end_time - start_time:.2f} seconds.')
|
35 |
-
|
36 |
-
|
37 |
-
# Placeholder buttons for model selection
|
38 |
-
# if st.button('Classify with BoW/TF-IDF'):
|
39 |
-
# st.write(f'{class_prefix}{predict(user_input)}')
|
40 |
-
# if st.button('Classify with LSTM'):
|
41 |
-
# st.write(f'{class_prefix}{predict_review(user_input)}')
|
42 |
-
# if st.button('Classify with ruBERT'):
|
43 |
-
# st.write(f'{class_prefix}{classify_text(user_input)}')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app_pages/page2_rubert_toxicity.py
DELETED
@@ -1,20 +0,0 @@
|
|
1 |
-
import streamlit as st
|
2 |
-
|
3 |
-
from app_models.toxicity_MODEL import text2toxicity
|
4 |
-
|
5 |
-
|
6 |
-
def run():
|
7 |
-
st.title('Toxicity Detection')
|
8 |
-
st.write('This tool classifies text as toxic or non-toxic using RuBERT.')
|
9 |
-
|
10 |
-
user_input = st.text_area("Enter text to classify", "Type your text here...")
|
11 |
-
|
12 |
-
if st.button('Classify'):
|
13 |
-
toxicity_score = text2toxicity(user_input)
|
14 |
-
st.write('Toxicity score:', toxicity_score)
|
15 |
-
|
16 |
-
# Optional: Interpret the score for the user
|
17 |
-
if toxicity_score > 0.5:
|
18 |
-
st.write("This text is likely to be considered toxic.")
|
19 |
-
else:
|
20 |
-
st.write("This text is likely to be considered non-toxic.")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app_pages/page3_gpt_model.py
DELETED
@@ -1,15 +0,0 @@
|
|
1 |
-
import streamlit as st
|
2 |
-
from app_models.gpt_MODEL import generate_text
|
3 |
-
|
4 |
-
|
5 |
-
def run():
|
6 |
-
st.title('GPT Text Generation')
|
7 |
-
prompt_text = st.text_area("Input Text", "Type here...")
|
8 |
-
length = st.slider("Length of Generated Text", min_value=50, max_value=500, value=200)
|
9 |
-
temperature = st.slider("Temperature", min_value=0.1, max_value=2.0, value=0.7, step=0.1)
|
10 |
-
beams = st.slider("Number of Generations", min_value=2, max_value=10, value=4, step=1)
|
11 |
-
|
12 |
-
if st.button('Generate Text'):
|
13 |
-
with st.spinner('Generating...'):
|
14 |
-
generated_text = generate_text(prompt_text, length, temperature, beams)
|
15 |
-
st.text_area("Generated Text", generated_text, height=250)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
models/__pycache__/bag_of_words_MODEL.cpython-310.pyc
ADDED
Binary file (626 Bytes). View file
|
|
models/__pycache__/gpt_MODEL.cpython-310.pyc
ADDED
Binary file (1.04 kB). View file
|
|
models/__pycache__/lstm_MODEL.cpython-310.pyc
ADDED
Binary file (3.49 kB). View file
|
|
models/__pycache__/rubert_MODEL.cpython-310.pyc
ADDED
Binary file (1.39 kB). View file
|
|
models/__pycache__/toxicity_MODEL.cpython-310.pyc
ADDED
Binary file (981 Bytes). View file
|
|
{app_models → models}/bag_of_words_MODEL.py
RENAMED
File without changes
|
{app_models → models}/gpt_MODEL.py
RENAMED
File without changes
|
{app_models → models}/lstm_MODEL.py
RENAMED
File without changes
|
{app_models → models}/rubert_MODEL.py
RENAMED
File without changes
|
{app_models → models}/toxicity_MODEL.py
RENAMED
File without changes
|
pages/PalanikGPT.py
ADDED
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
from models.gpt_MODEL import generate_text
|
3 |
+
|
4 |
+
|
5 |
+
st.title('GPT Text Generation')
|
6 |
+
prompt_text = st.text_area("Input Text", "Type here...")
|
7 |
+
length = st.slider("Length of Generated Text", min_value=50, max_value=500, value=200)
|
8 |
+
temperature = st.slider("Temperature", min_value=0.1, max_value=2.0, value=0.7, step=0.1)
|
9 |
+
beams = st.slider("Number of Generations", min_value=2, max_value=10, value=4, step=1)
|
10 |
+
|
11 |
+
if st.button('Generate Text'):
|
12 |
+
with st.spinner('Generating...'):
|
13 |
+
generated_text = generate_text(prompt_text, length, temperature, beams)
|
14 |
+
st.text_area("Generated Text", generated_text, height=250)
|
pages/ReviewClassification.py
ADDED
@@ -0,0 +1,43 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
from models.rubert_MODEL import classify_text
|
3 |
+
from models.bag_of_words_MODEL import predict
|
4 |
+
from models.lstm_MODEL import predict_review
|
5 |
+
import time
|
6 |
+
|
7 |
+
class_prefix = 'This review is likely...'
|
8 |
+
|
9 |
+
|
10 |
+
st.title("Movie Review Classification")
|
11 |
+
st.write("This page will compare three models: Bag of Words/TF-IDF, LSTM, and BERT.")
|
12 |
+
|
13 |
+
# Example placeholder for user input
|
14 |
+
user_input = st.text_area("")
|
15 |
+
|
16 |
+
|
17 |
+
if st.button('Classify with All Models'):
|
18 |
+
# Measure and display Bag of Words/TF-IDF prediction time
|
19 |
+
start_time = time.time()
|
20 |
+
bow_tfidf_result = predict(user_input)
|
21 |
+
end_time = time.time()
|
22 |
+
st.write(f'{class_prefix} {bow_tfidf_result} according to Bag of Words/TF-IDF. Time taken: {end_time - start_time:.2f} seconds.')
|
23 |
+
|
24 |
+
# Measure and display LSTM prediction time
|
25 |
+
start_time = time.time()
|
26 |
+
lstm_result = predict_review(user_input)
|
27 |
+
end_time = time.time()
|
28 |
+
st.write(f'{class_prefix} {lstm_result} according to LSTM. Time taken: {end_time - start_time:.2f} seconds.')
|
29 |
+
|
30 |
+
# Measure and display ruBERT prediction time
|
31 |
+
start_time = time.time()
|
32 |
+
rubert_result = classify_text(user_input)
|
33 |
+
end_time = time.time()
|
34 |
+
st.write(f'{class_prefix} {rubert_result} according to ruBERT. Time taken: {end_time - start_time:.2f} seconds.')
|
35 |
+
|
36 |
+
|
37 |
+
# Placeholder buttons for model selection
|
38 |
+
# if st.button('Classify with BoW/TF-IDF'):
|
39 |
+
# st.write(f'{class_prefix}{predict(user_input)}')
|
40 |
+
# if st.button('Classify with LSTM'):
|
41 |
+
# st.write(f'{class_prefix}{predict_review(user_input)}')
|
42 |
+
# if st.button('Classify with ruBERT'):
|
43 |
+
# st.write(f'{class_prefix}{classify_text(user_input)}')
|
pages/ToxicCommentDetector.py
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
|
3 |
+
from models.toxicity_MODEL import text2toxicity
|
4 |
+
|
5 |
+
|
6 |
+
st.title('Toxicity Detection')
|
7 |
+
st.write('This tool classifies text as toxic or non-toxic using RuBERT.')
|
8 |
+
|
9 |
+
user_input = st.text_area("Enter text to classify", "Type your text here...")
|
10 |
+
|
11 |
+
if st.button('Classify'):
|
12 |
+
toxicity_score = text2toxicity(user_input)
|
13 |
+
st.write('Toxicity score:', toxicity_score)
|
14 |
+
|
15 |
+
# Optional: Interpret the score for the user
|
16 |
+
if toxicity_score > 0.5:
|
17 |
+
st.write("This text is likely to be considered toxic.")
|
18 |
+
else:
|
19 |
+
st.write("This text is likely to be considered non-toxic.")
|