asad231 commited on
Commit
ca98ddd
Β·
verified Β·
1 Parent(s): eb40269

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -4
app.py CHANGED
@@ -173,22 +173,27 @@ def detect_deepfake_image(image_path):
173
  # else:
174
  # st.success(f"βœ… Result: This news is **REAL**. (Confidence: {confidence:.2f})")
175
  # ---- Fake News Detection Section ----
 
 
176
  st.subheader("πŸ“ Fake News Detection")
177
  news_input = st.text_area("Enter News Text:", placeholder="Type here...")
178
 
179
  if st.button("Check News"):
180
  st.write("πŸ” Processing...")
181
 
182
- # Use AI model to classify the news
183
  prediction = fake_news_detector(news_input)
184
  label = prediction[0]['label'].lower()
185
  confidence = prediction[0]['score']
186
 
187
- # Ensure correct classification
188
- if label in ["fake", "false", "negative"] or confidence < 0.5:
189
  st.error(f"⚠️ Result: This news is **FAKE**. (Confidence: {confidence:.2f})")
190
- else:
191
  st.success(f"βœ… Result: This news is **REAL**. (Confidence: {confidence:.2f})")
 
 
 
192
  # ---- Deepfake Image Detection Section ----
193
  st.subheader("πŸ“Έ Deepfake Image Detection")
194
  uploaded_image = st.file_uploader("Upload an Image", type=["jpg", "png", "jpeg"])
 
173
  # else:
174
  # st.success(f"βœ… Result: This news is **REAL**. (Confidence: {confidence:.2f})")
175
  # ---- Fake News Detection Section ----
176
+ import streamlit as st
177
+
178
  st.subheader("πŸ“ Fake News Detection")
179
  news_input = st.text_area("Enter News Text:", placeholder="Type here...")
180
 
181
  if st.button("Check News"):
182
  st.write("πŸ” Processing...")
183
 
184
+ # Get AI model prediction
185
  prediction = fake_news_detector(news_input)
186
  label = prediction[0]['label'].lower()
187
  confidence = prediction[0]['score']
188
 
189
+ # Correct classification logic
190
+ if label == "fake" or confidence > 0.6: # Adjusted confidence threshold
191
  st.error(f"⚠️ Result: This news is **FAKE**. (Confidence: {confidence:.2f})")
192
+ elif label == "real" and confidence > 0.6:
193
  st.success(f"βœ… Result: This news is **REAL**. (Confidence: {confidence:.2f})")
194
+ else:
195
+ st.warning(f"⚠️ Unable to classify with high confidence. Please verify manually. (Confidence: {confidence:.2f})")
196
+
197
  # ---- Deepfake Image Detection Section ----
198
  st.subheader("πŸ“Έ Deepfake Image Detection")
199
  uploaded_image = st.file_uploader("Upload an Image", type=["jpg", "png", "jpeg"])