Lauraayu commited on
Commit
d12f627
·
verified ·
1 Parent(s): ac68288

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +30 -0
app.py ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from transformers import pipeline
3
+
4
+ # Load the summariztion model pipeline
5
+ summarizer_ntg = pipeline("text2text-generation", model="mrm8488/t5-base-finetuned-summarize-news")
6
+ classifier = pipeline("text-classification", model='Lauraayu/News_Classi_Model', return_all_scores=True)
7
+
8
+ # Streamlit application title
9
+ st.title("News Classification")
10
+ st.write("Classification for different News types")
11
+
12
+ # Text input for user to enter the text to classify
13
+ text = st.text_area("Enter the News to classify","")
14
+
15
+ # Perform text classification when the user clicks the "Classify" button
16
+ if st.button("Classify"):
17
+
18
+ # Perform text classification on the input text
19
+ result0 = summarizer_ntg(text)
20
+ result = classifier(result0)
21
+ # Display the classification result
22
+ max_score = float('-inf')
23
+ max_label = ''
24
+ for result in results:
25
+ if result['score'] > max_score:
26
+ max_score = result['score']
27
+ max_label = result['label']
28
+ st.write("Text:", text)
29
+ st.write("Label:", max_label)
30
+ st.write("Score:", max_score)