', unsafe_allow_html=True)
# Custom CSS with Poppins font
st.markdown("""
""", unsafe_allow_html=True)
# Header Section
st.markdown('', unsafe_allow_html=True)
# Main Content
st.markdown('
', unsafe_allow_html=True)
st.markdown('
This application uses a hybrid deep learning model (BERT + BiLSTM + Attention) to detect fake news articles. Enter a news article below to analyze it.
', unsafe_allow_html=True)
st.markdown('
', unsafe_allow_html=True)
st.markdown('
📋 News Analysis
', unsafe_allow_html=True)
# Input Section
st.markdown('
', unsafe_allow_html=True)
news_text = st.text_area(
"Enter the news article to analyze:",
height=200,
placeholder="Paste your news article here..."
)
st.markdown('
', unsafe_allow_html=True)
if st.button("Analyze"):
if news_text:
with st.spinner("Analyzing the news article..."):
# Get prediction
result = predict_news(news_text)
# Display result
col1, col2 = st.columns(2)
with col1:
st.markdown('
', unsafe_allow_html=True)
st.markdown('
🔍 Prediction
', unsafe_allow_html=True)
if result['label'] == 'FAKE':
st.markdown(f'
🚨 Fake News Detected {result["confidence"]:.2%}
', unsafe_allow_html=True)
else:
st.markdown(f'
✅ Authentic News {result["confidence"]:.2%}
', unsafe_allow_html=True)
st.markdown('
', unsafe_allow_html=True)
with col2:
st.markdown('
', unsafe_allow_html=True)
st.markdown('
📊 Confidence Scores
', unsafe_allow_html=True)
st.plotly_chart(plot_confidence(result['probabilities']), use_container_width=True)
st.markdown('', unsafe_allow_html=True)
# Show attention visualization
st.markdown('
', unsafe_allow_html=True)
st.markdown('
👁️ Attention Analysis
', unsafe_allow_html=True)
st.markdown('
The attention weights show which parts of the text the model focused on while making its prediction. Higher weights indicate more important tokens.
', unsafe_allow_html=True)
st.plotly_chart(plot_attention(news_text, result['attention_weights']), use_container_width=True)
st.markdown('
', unsafe_allow_html=True)
# Show model explanation
st.markdown('
', unsafe_allow_html=True)
st.markdown('
📝 Model Explanation
', unsafe_allow_html=True)
if result['label'] == 'FAKE':
st.markdown('
The model identified this as fake news based on:
- Linguistic patterns typical of fake news
- Inconsistencies in the content
- Attention weights on suspicious phrases
', unsafe_allow_html=True)
else:
st.markdown('
The model identified this as real news based on:
- Credible language patterns
- Consistent information
- Attention weights on factual statements
', unsafe_allow_html=True)
st.markdown('
', unsafe_allow_html=True)
else:
st.warning("Please enter a news article to analyze.")
# Footer
st.markdown("---")
st.markdown(
'',
unsafe_allow_html=True
)
st.markdown('
', unsafe_allow_html=True) # Close main-container
if __name__ == "__main__":
main()