#importing all the libraries needed for basic classification and presentation of cover page import streamlit as st from transformers import pipeline #adding the css presentation from the styles file in utils from utils.styles import load_css #configure the page to display the intended title st.set_page_config( page_title="Daily Mirror News Analyzer", layout="wide" ) #calling the css changes load_css() #writing the title st.markdown('
News App — Created by Group 09
', unsafe_allow_html=True) #writing the description st.write('''
Welcome! In this app users can freely carry out classification of news content, ask our model questions and play our mini-game to see your classification skills

''',unsafe_allow_html=True) st.write('
The features of our webapp are shown below:
', unsafe_allow_html=True) #dividing the page st.divider() #creating the features col1, col2 = st.columns(2) with col1: #writing the topic fo the first feature of the app st.markdown('
📂 CSV Content Features
', unsafe_allow_html=True) #writing the content inside the first feature st.markdown("""
• Classification: Upload a CSV and label the data
• Analysis: See explanatory data analysis here
• Q & A: Ask the model questions from your data
""", unsafe_allow_html=True) with col2: #writing the topic fo the second feature of the app st.markdown('
🎮 Interactive Mini-Game
', unsafe_allow_html=True) #writing the content inside the second feature st.markdown("""
• Classification Test: Play a game where you classify news snippets
""", unsafe_allow_html=True) #dividing the page st.divider() #creating the model used for quick classification st.markdown('
🔍 Quick Model Test
', unsafe_allow_html=True) st.write('
Type a sentence below to see how our fine-tuned model classifies news:
',unsafe_allow_html=True) #calling and loading the fine tuned model which is uploaded to the hugging face @st.cache_resource def load_classifier(): return pipeline("text-classification", model="SuchithTissera/text_analytics_model", truncation=True) #calling the model which is now loaded into a simple variable classifier = load_classifier() #getting the user text user_text = st.text_area(" ", placeholder="Enter news content here...", height=100) #carrying out the classification if st.button("Classify Text"): if not user_text.strip(): st.warning("Please enter some text.") else: with st.spinner("Analyzing..."): result = classifier(user_text) st.success("Analysis Complete") res_col1, res_col2 = st.columns(2) with res_col1: st.metric(label="Predicted Category", value=result[0]["label"]) with res_col2: confidence = round(result[0]["score"] * 100, 2) st.metric(label="Confidence Score", value=f"{confidence}%")