Lauraayu's picture
Create app.py
d12f627 verified
raw
history blame
1.07 kB
import streamlit as st
from transformers import pipeline
# Load the summariztion model pipeline
summarizer_ntg = pipeline("text2text-generation", model="mrm8488/t5-base-finetuned-summarize-news")
classifier = pipeline("text-classification", model='Lauraayu/News_Classi_Model', return_all_scores=True)
# Streamlit application title
st.title("News Classification")
st.write("Classification for different News types")
# Text input for user to enter the text to classify
text = st.text_area("Enter the News to classify","")
# Perform text classification when the user clicks the "Classify" button
if st.button("Classify"):
# Perform text classification on the input text
result0 = summarizer_ntg(text)
result = classifier(result0)
# Display the classification result
max_score = float('-inf')
max_label = ''
for result in results:
if result['score'] > max_score:
max_score = result['score']
max_label = result['label']
st.write("Text:", text)
st.write("Label:", max_label)
st.write("Score:", max_score)