Update app.py
Browse files
app.py
CHANGED
|
@@ -30,19 +30,19 @@ if st.button("Process"):
|
|
| 30 |
# Perform text summarization
|
| 31 |
summary = summarizer(text_input, max_length=130, min_length=30, do_sample=False)
|
| 32 |
summarized_text = summary[0]['summary_text']
|
| 33 |
-
# Display the summary result
|
| 34 |
-
st.write("Summarized Text:", summarized_text)
|
| 35 |
except Exception as e:
|
| 36 |
st.error(f"Error during summarization: {e}")
|
| 37 |
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
|
|
|
|
|
|
| 47 |
else:
|
| 48 |
st.warning("Please enter text to process and ensure both models are loaded.")
|
|
|
|
| 30 |
# Perform text summarization
|
| 31 |
summary = summarizer(text_input, max_length=130, min_length=30, do_sample=False)
|
| 32 |
summarized_text = summary[0]['summary_text']
|
|
|
|
|
|
|
| 33 |
except Exception as e:
|
| 34 |
st.error(f"Error during summarization: {e}")
|
| 35 |
|
| 36 |
+
if summarized_text:
|
| 37 |
+
try:
|
| 38 |
+
# Perform question classification on the summarized text
|
| 39 |
+
results = classifier(summarized_text)[0]
|
| 40 |
+
# Find the category with the highest score
|
| 41 |
+
max_score = max(results, key=lambda x: x['score'])
|
| 42 |
+
st.write("Summarized Text:", summarized_text)
|
| 43 |
+
st.write("Category:", max_score['label'])
|
| 44 |
+
st.write("Score:", max_score['score'])
|
| 45 |
+
except Exception as e:
|
| 46 |
+
st.error(f"Error during classification: {e}")
|
| 47 |
else:
|
| 48 |
st.warning("Please enter text to process and ensure both models are loaded.")
|