Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -9,7 +9,7 @@ except ValueError as e:
|
|
| 9 |
st.error(f"Error loading summarization model: {e}")
|
| 10 |
summarizer_loaded = False
|
| 11 |
|
| 12 |
-
# Load the
|
| 13 |
model_name = "elozano/bert-base-cased-news-category"
|
| 14 |
try:
|
| 15 |
classifier = pipeline("text-classification", model=model_name, return_all_scores=True)
|
|
@@ -19,13 +19,13 @@ except ValueError as e:
|
|
| 19 |
classifier_loaded = False
|
| 20 |
|
| 21 |
# Streamlit app title
|
| 22 |
-
st.title("Summarization and
|
| 23 |
|
| 24 |
# Tab layout
|
| 25 |
-
tab1, tab2 = st.tabs(["
|
| 26 |
|
| 27 |
with tab1:
|
| 28 |
-
st.header("
|
| 29 |
# Input text for summarization
|
| 30 |
text_to_summarize = st.text_area("Enter text to summarize:", "")
|
| 31 |
if st.button("Summarize"):
|
|
@@ -41,13 +41,13 @@ with tab1:
|
|
| 41 |
st.warning("Please enter text to summarize and ensure the model is loaded.")
|
| 42 |
|
| 43 |
with tab2:
|
| 44 |
-
st.header("
|
| 45 |
-
# Input text for
|
| 46 |
text_to_classify = st.text_area("Enter text to classify:", "")
|
| 47 |
if st.button("Classify"):
|
| 48 |
if classifier_loaded and text_to_classify:
|
| 49 |
try:
|
| 50 |
-
# Perform
|
| 51 |
results = classifier(text_to_classify)[0]
|
| 52 |
# Find the category with the highest score
|
| 53 |
max_score = max(results, key=lambda x: x['score'])
|
|
|
|
| 9 |
st.error(f"Error loading summarization model: {e}")
|
| 10 |
summarizer_loaded = False
|
| 11 |
|
| 12 |
+
# Load the Question classification pipeline
|
| 13 |
model_name = "elozano/bert-base-cased-news-category"
|
| 14 |
try:
|
| 15 |
classifier = pipeline("text-classification", model=model_name, return_all_scores=True)
|
|
|
|
| 19 |
classifier_loaded = False
|
| 20 |
|
| 21 |
# Streamlit app title
|
| 22 |
+
st.title("Long Question Summarization and Classification")
|
| 23 |
|
| 24 |
# Tab layout
|
| 25 |
+
tab1, tab2 = st.tabs(["Question Summarization", "Question Classification"])
|
| 26 |
|
| 27 |
with tab1:
|
| 28 |
+
st.header("Question Summarization")
|
| 29 |
# Input text for summarization
|
| 30 |
text_to_summarize = st.text_area("Enter text to summarize:", "")
|
| 31 |
if st.button("Summarize"):
|
|
|
|
| 41 |
st.warning("Please enter text to summarize and ensure the model is loaded.")
|
| 42 |
|
| 43 |
with tab2:
|
| 44 |
+
st.header("Questions Classification")
|
| 45 |
+
# Input text for Question classification
|
| 46 |
text_to_classify = st.text_area("Enter text to classify:", "")
|
| 47 |
if st.button("Classify"):
|
| 48 |
if classifier_loaded and text_to_classify:
|
| 49 |
try:
|
| 50 |
+
# Perform uestion classification
|
| 51 |
results = classifier(text_to_classify)[0]
|
| 52 |
# Find the category with the highest score
|
| 53 |
max_score = max(results, key=lambda x: x['score'])
|