richardorama
commited on
Commit
β’
889b7a0
1
Parent(s):
fe40899
Update app.py
Browse files
app.py
CHANGED
@@ -12,7 +12,7 @@ st.title("Assorted Language Tools - AI Craze")
|
|
12 |
|
13 |
|
14 |
|
15 |
-
|
16 |
|
17 |
|
18 |
import streamlit as st
|
@@ -47,6 +47,14 @@ if st.button("Summarize"):
|
|
47 |
else:
|
48 |
st.warning("Please enter some text to summarize!")
|
49 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
50 |
DEFAULT_STATEMENT = ""
|
51 |
# Create a text area for user input
|
52 |
STATEMENT = st.sidebar.text_area('Enter Statement (String1)', DEFAULT_STATEMENT, height=150)
|
@@ -74,19 +82,19 @@ else:
|
|
74 |
st.warning('π Please enter Statement!')
|
75 |
|
76 |
|
77 |
-
################ STATEMENT SUMMARIZATION #################
|
78 |
|
79 |
# Load the summarization model
|
80 |
#summarizer = pipeline("summarization", model="sshleifer/distilbart-cnn-12-6") # smaller version of the model
|
81 |
summarizer = pipeline("summarization", model="facebook/bart-large-cnn")
|
82 |
|
83 |
-
# Define the summarization function
|
84 |
-
def summarize_statement(txt):
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
|
91 |
DEFAULT_STATEMENT = ""
|
92 |
# Create a text area for user input
|
@@ -96,13 +104,16 @@ STATEMENT = st.sidebar.text_area('Enter Statement (String)', DEFAULT_STATEMENT,
|
|
96 |
if STATEMENT:
|
97 |
if st.sidebar.button('Summarize Statement'):
|
98 |
# Call your Summarize function here
|
99 |
-
|
|
|
|
|
|
|
100 |
else:
|
101 |
st.sidebar.button('Summarize Statement', disabled=True)
|
102 |
st.warning('π Please enter Statement!')
|
103 |
|
104 |
|
105 |
-
################ SENTIMENT ANALYSIS #################
|
106 |
|
107 |
# Initialize the sentiment analysis pipeline
|
108 |
# No model was supplied, defaulted to distilbert-base-uncased-finetuned-sst-2-english
|
@@ -150,7 +161,7 @@ else:
|
|
150 |
st.warning('π Please enter Sentiment!')
|
151 |
|
152 |
|
153 |
-
# ################ CHAT BOT #################
|
154 |
|
155 |
# # Load the GPT model
|
156 |
# generator = pipeline("text-generation", model="EleutherAI/gpt-neo-2.7B")
|
|
|
12 |
|
13 |
|
14 |
|
15 |
+
################ STATEMENT SUMMARIZATION - main area #################
|
16 |
|
17 |
|
18 |
import streamlit as st
|
|
|
47 |
else:
|
48 |
st.warning("Please enter some text to summarize!")
|
49 |
|
50 |
+
|
51 |
+
################ STATEMENT SUMMARIZATION1 - side bar #################
|
52 |
+
|
53 |
+
# Load the summarization model and tokenizer
|
54 |
+
MODEL_NAME = "facebook/bart-large-cnn" # A commonly used summarization model
|
55 |
+
tokenizer = AutoTokenizer.from_pretrained(MODEL_NAME)
|
56 |
+
model = AutoModelForSeq2SeqLM.from_pretrained(MODEL_NAME)
|
57 |
+
|
58 |
DEFAULT_STATEMENT = ""
|
59 |
# Create a text area for user input
|
60 |
STATEMENT = st.sidebar.text_area('Enter Statement (String1)', DEFAULT_STATEMENT, height=150)
|
|
|
82 |
st.warning('π Please enter Statement!')
|
83 |
|
84 |
|
85 |
+
################ STATEMENT SUMMARIZATION - side bar #################
|
86 |
|
87 |
# Load the summarization model
|
88 |
#summarizer = pipeline("summarization", model="sshleifer/distilbart-cnn-12-6") # smaller version of the model
|
89 |
summarizer = pipeline("summarization", model="facebook/bart-large-cnn")
|
90 |
|
91 |
+
# # Define the summarization function
|
92 |
+
# def summarize_statement(txt):
|
93 |
+
# st.write('\n\n')
|
94 |
+
# #st.write(txt[:100]) # Display the first 100 characters of the article
|
95 |
+
# #st.write('--------------------------------------------------------------')
|
96 |
+
# summary = summarizer(txt, max_length=500, min_length=30, do_sample=False)
|
97 |
+
# st.write(summary[0]['summary_text'])
|
98 |
|
99 |
DEFAULT_STATEMENT = ""
|
100 |
# Create a text area for user input
|
|
|
104 |
if STATEMENT:
|
105 |
if st.sidebar.button('Summarize Statement'):
|
106 |
# Call your Summarize function here
|
107 |
+
st.write('\n\n')
|
108 |
+
summary = summarizer(STATEMENT, max_length=500, min_length=30, do_sample=False)
|
109 |
+
st.write(summary[0]['summary_text'])
|
110 |
+
#summarize_statement(STATEMENT) # Directly pass the STATEMENT
|
111 |
else:
|
112 |
st.sidebar.button('Summarize Statement', disabled=True)
|
113 |
st.warning('π Please enter Statement!')
|
114 |
|
115 |
|
116 |
+
################ SENTIMENT ANALYSIS - side bar #################
|
117 |
|
118 |
# Initialize the sentiment analysis pipeline
|
119 |
# No model was supplied, defaulted to distilbert-base-uncased-finetuned-sst-2-english
|
|
|
161 |
st.warning('π Please enter Sentiment!')
|
162 |
|
163 |
|
164 |
+
# ################ CHAT BOT - main area #################
|
165 |
|
166 |
# # Load the GPT model
|
167 |
# generator = pipeline("text-generation", model="EleutherAI/gpt-neo-2.7B")
|