asad231 commited on
Commit
10c4ed3
·
verified ·
1 Parent(s): e3b4fc1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -7
app.py CHANGED
@@ -144,16 +144,24 @@ news_input = st.text_area("Enter News Text:", placeholder="Type here...")
144
  if st.button("Check News"):
145
  st.write("🔍 Processing...")
146
  prediction = fake_news_detector(news_input)
147
- label = prediction[0]['label'].lower() # Convert label to lowercase for consistency
148
  confidence = prediction[0]['score']
149
 
150
- # Strict classification: FAKE news is always FAKE, and REAL news is always REAL
151
- if "fake" in label or "false" in label or "negative" in label:
152
- st.error(f"⚠️ Result: This news is **FAKE**. (Confidence: {confidence:.2f})")
153
- elif "real" in label or "true" in label or "positive" in label:
154
- st.success(f" Result: This news is **REAL**. (Confidence: {confidence:.2f})")
 
 
155
  else:
156
- st.warning("⚠️ Unable to classify the news with high confidence. Please verify manually.")
 
 
 
 
 
 
157
  # ---- Deepfake Image Detection Section ----
158
  st.subheader("📸 Deepfake Image Detection")
159
  uploaded_image = st.file_uploader("Upload an Image", type=["jpg", "png", "jpeg"])
 
144
  if st.button("Check News"):
145
  st.write("🔍 Processing...")
146
  prediction = fake_news_detector(news_input)
147
+ label = prediction[0]['label'].lower() # Convert label to lowercase
148
  confidence = prediction[0]['score']
149
 
150
+ # Force classification based on confidence threshold
151
+ threshold = 0.5 # Adjust if needed
152
+ if confidence >= threshold:
153
+ if "fake" in label or "false" in label or "negative" in label:
154
+ st.error(f"⚠️ Result: This news is **FAKE**. (Confidence: {confidence:.2f})")
155
+ else:
156
+ st.success(f"✅ Result: This news is **REAL**. (Confidence: {confidence:.2f})")
157
  else:
158
+ # If confidence is too low, classify based on probability
159
+ final_label = "FAKE" if confidence < 0.5 else "REAL"
160
+ if final_label == "FAKE":
161
+ st.error(f"⚠️ Result: This news is **FAKE**. (Confidence: {confidence:.2f})")
162
+ else:
163
+ st.success(f"✅ Result: This news is **REAL**. (Confidence: {confidence:.2f})")
164
+
165
  # ---- Deepfake Image Detection Section ----
166
  st.subheader("📸 Deepfake Image Detection")
167
  uploaded_image = st.file_uploader("Upload an Image", type=["jpg", "png", "jpeg"])