asad231 commited on
Commit
520030f
Β·
verified Β·
1 Parent(s): 7cfe356

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -3
app.py CHANGED
@@ -172,21 +172,25 @@ def detect_deepfake_image(image_path):
172
  # st.error(f"⚠️ Result: This news is **FAKE**. (Confidence: {confidence:.2f})")
173
  # else:
174
  # st.success(f"βœ… Result: This news is **REAL**. (Confidence: {confidence:.2f})")
 
175
  import streamlit as st
176
 
 
 
 
177
  st.subheader("πŸ“ Fake News Detection")
178
  news_input = st.text_area("Enter News Text:", placeholder="Type here...")
179
 
180
  if st.button("Check News"):
181
  st.write("πŸ” Processing...")
182
 
183
- # Use AI model to classify the news
184
  prediction = fake_news_detector(news_input)
185
  label = prediction[0]['label'].lower()
186
  confidence = prediction[0]['score']
187
 
188
- # Ensure proper classification
189
- if label in ["fake", "false", "negative"] or confidence < 0.5:
190
  st.error(f"⚠️ Result: This news is **FAKE**. (Confidence: {confidence:.2f})")
191
  else:
192
  st.success(f"βœ… Result: This news is **REAL**. (Confidence: {confidence:.2f})")
 
172
  # st.error(f"⚠️ Result: This news is **FAKE**. (Confidence: {confidence:.2f})")
173
  # else:
174
  # st.success(f"βœ… Result: This news is **REAL**. (Confidence: {confidence:.2f})")
175
+ from transformers import pipeline
176
  import streamlit as st
177
 
178
+ # βœ… Load a Valid Fake News Detection Model
179
+ fake_news_detector = pipeline("text-classification", model="MoritzLaurer/deberta-v3-large-contrastive-fake-news")
180
+
181
  st.subheader("πŸ“ Fake News Detection")
182
  news_input = st.text_area("Enter News Text:", placeholder="Type here...")
183
 
184
  if st.button("Check News"):
185
  st.write("πŸ” Processing...")
186
 
187
+ # βœ… Get Model Prediction
188
  prediction = fake_news_detector(news_input)
189
  label = prediction[0]['label'].lower()
190
  confidence = prediction[0]['score']
191
 
192
+ # βœ… Ensure Correct Classification
193
+ if "fake" in label or confidence < 0.5:
194
  st.error(f"⚠️ Result: This news is **FAKE**. (Confidence: {confidence:.2f})")
195
  else:
196
  st.success(f"βœ… Result: This news is **REAL**. (Confidence: {confidence:.2f})")