Spaces:
Sleeping
Sleeping
File size: 3,434 Bytes
bc11ac9 ecfda77 8e69e12 9ce5163 aa7f2cd ecfda77 ba8eb6e e53453b 8d139a8 e53453b ecfda77 8eb29a0 bc11ac9 b290553 2a153f7 bc11ac9 c8f5bb9 bc11ac9 10f16b3 c8f5bb9 bc11ac9 eeb5002 bc11ac9 eeb5002 bc11ac9 c8f5bb9 bc11ac9 30fe201 c8f5bb9 bc11ac9 61ab7e7 eeb5002 bc11ac9 c8f5bb9 bc11ac9 30fe201 c8f5bb9 10f16b3 61ab7e7 eeb5002 bc11ac9 eeb5002 bc11ac9 c8f5bb9 8e69e12 bc11ac9 8e69e12 61ab7e7 8e69e12 bc11ac9 8e69e12 bc11ac9 2dae69c 8e69e12 bc11ac9 8e69e12 eeb5002 8e69e12 eeb5002 61ab7e7 2dae69c | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 | #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('<div class="main_title">News App — Created by Group 09</div>',
unsafe_allow_html=True)
#writing the description
st.write('''<div class="feature_text">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 </div> <br>''',unsafe_allow_html=True)
st.write('<div class="feature_text">The features of our webapp are shown below: </div>', 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('<div class="topic_header">📂 CSV Content Features</div>', unsafe_allow_html=True)
#writing the content inside the first feature
st.markdown("""
<div class="feature_box">
<div class="feature_text">
• <b>Classification:</b> Upload a CSV and label the data<br>
• <b>Analysis:</b> See explanatory data analysis here <br>
• <b>Q & A:</b> Ask the model questions from your data
</div>
</div>
""", unsafe_allow_html=True)
with col2:
#writing the topic fo the second feature of the app
st.markdown('<div class="topic_header">🎮 Interactive Mini-Game</div>', unsafe_allow_html=True)
#writing the content inside the second feature
st.markdown("""
<div class="feature_box">
<div class="feature_text">
• <b>Classification Test:</b> Play a game where you classify news snippets <br>
</div>
</div>
""", unsafe_allow_html=True)
#dividing the page
st.divider()
#creating the model used for quick classification
st.markdown('<div class="topic_header">🔍 Quick Model Test</div>', unsafe_allow_html=True)
st.write('<div class="feature_text">Type a sentence below to see how our fine-tuned model classifies news:</div>',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}%")
|