asad231 commited on
Commit
6b123b3
·
verified ·
1 Parent(s): b386768

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -4
app.py CHANGED
@@ -172,7 +172,8 @@ 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
- # ---- Fake News Detection Section ----
 
176
  st.subheader("📝 Fake News Detection")
177
  news_input = st.text_area("Enter News Text:", placeholder="Type here...")
178
 
@@ -184,13 +185,14 @@ if st.button("Check News"):
184
  label = prediction[0]['label'].lower()
185
  confidence = prediction[0]['score']
186
 
187
- # Ensure correct classification
188
- if confidence > 0.75 and label in ["real", "true", "positive"]:
189
  st.success(f"✅ Result: This news is **REAL**. (Confidence: {confidence:.2f})")
190
- elif confidence < 0.5 or label in ["fake", "false", "negative"]:
191
  st.error(f"⚠️ Result: This news is **FAKE**. (Confidence: {confidence:.2f})")
192
  else:
193
  st.warning(f"⚠️ Unable to classify with high confidence. Please verify manually. (Confidence: {confidence:.2f})")
 
194
  # ---- Deepfake Image Detection Section ----
195
  st.subheader("📸 Deepfake Image Detection")
196
  uploaded_image = st.file_uploader("Upload an Image", type=["jpg", "png", "jpeg"])
 
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
 
 
185
  label = prediction[0]['label'].lower()
186
  confidence = prediction[0]['score']
187
 
188
+ # Fix classification issue
189
+ if confidence > 0.6 and label in ["real", "true", "positive"]:
190
  st.success(f"✅ Result: This news is **REAL**. (Confidence: {confidence:.2f})")
191
+ elif confidence < 0.4 or label in ["fake", "false", "negative"]:
192
  st.error(f"⚠️ Result: This news is **FAKE**. (Confidence: {confidence:.2f})")
193
  else:
194
  st.warning(f"⚠️ Unable to classify with high confidence. Please verify manually. (Confidence: {confidence:.2f})")
195
+
196
  # ---- Deepfake Image Detection Section ----
197
  st.subheader("📸 Deepfake Image Detection")
198
  uploaded_image = st.file_uploader("Upload an Image", type=["jpg", "png", "jpeg"])