Update app.py
Browse files
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
|
148 |
confidence = prediction[0]['score']
|
149 |
|
150 |
-
#
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
|
|
|
|
155 |
else:
|
156 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
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"])
|