Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,32 +1,26 @@
|
|
1 |
import streamlit as st
|
2 |
from transformers import pipeline
|
3 |
-
import torch
|
4 |
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
# Streamlit application title
|
10 |
-
st.title("News Article Summarizer and Classifier")
|
11 |
-
st.write("Enter a news article text to get its summary and category.")
|
12 |
-
|
13 |
-
# Text input for user to enter the news article text
|
14 |
-
text = st.text_area("Enter the news article text here:")
|
15 |
-
|
16 |
-
# Perform summarization and classification when the user clicks the "Classify" button
|
17 |
-
if st.button("Classify"):
|
18 |
-
# Perform text summarization
|
19 |
-
summary = summarizer_ntg(text)[0]['summary_text']
|
20 |
|
21 |
-
#
|
22 |
-
|
23 |
-
|
24 |
|
25 |
-
#
|
26 |
-
|
27 |
-
label_mapping = model_bb.config.id2label
|
28 |
-
predicted_label = label_mapping[predicted_label_id]
|
29 |
|
30 |
-
#
|
31 |
-
st.
|
32 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import streamlit as st
|
2 |
from transformers import pipeline
|
|
|
3 |
|
4 |
+
def main():
|
5 |
+
# Define pipelines
|
6 |
+
summarizer_ntg = pipeline(model="mrm8488/t5-base-finetuned-summarize-news")
|
7 |
+
model = pipeline(model="Lauraayu/News_Classi_Model")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
8 |
|
9 |
+
# Streamlit application title
|
10 |
+
st.title("News Article Classifier")
|
11 |
+
st.write("Enter a news article text to get its category:")
|
12 |
|
13 |
+
# Text input for user to enter the news article text
|
14 |
+
text = st.text_area("Enter the news article text here:")
|
|
|
|
|
15 |
|
16 |
+
# Perform summarization and classification when the user clicks the "Classify" button
|
17 |
+
if st.button("Classify"):
|
18 |
+
# Perform text summarization
|
19 |
+
summary = summarizer_ntg(text)[0]
|
20 |
+
|
21 |
+
# Perform classification
|
22 |
+
output = model(summary)
|
23 |
+
category = output[0]["label"]
|
24 |
+
|
25 |
+
# Display the summary and classification result
|
26 |
+
st.write("Category:", category)
|