Update app.py
Browse files
app.py
CHANGED
@@ -141,23 +141,34 @@ def detect_deepfake_image(image_path):
|
|
141 |
st.subheader("π Fake News Detection")
|
142 |
news_input = st.text_area("Enter News Text:", placeholder="Type here...")
|
143 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
144 |
if st.button("Check News"):
|
145 |
st.write("π Processing...")
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
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
|
157 |
else:
|
158 |
-
#
|
159 |
-
|
160 |
-
|
|
|
|
|
|
|
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})")
|
|
|
141 |
st.subheader("π Fake News Detection")
|
142 |
news_input = st.text_area("Enter News Text:", placeholder="Type here...")
|
143 |
|
144 |
+
# Manually verified facts database (you can expand this)
|
145 |
+
fact_check_db = {
|
146 |
+
"elon musk was born in 1932": "FAKE",
|
147 |
+
"earth revolves around the sun": "REAL",
|
148 |
+
"the moon is made of cheese": "FAKE",
|
149 |
+
}
|
150 |
+
|
151 |
+
def check_manual_facts(text):
|
152 |
+
text_lower = text.lower().strip()
|
153 |
+
return fact_check_db.get(text_lower, None)
|
154 |
+
|
155 |
if st.button("Check News"):
|
156 |
st.write("π Processing...")
|
157 |
+
|
158 |
+
# Check if the news is in the fact-check database
|
159 |
+
manual_result = check_manual_facts(news_input)
|
160 |
+
if manual_result:
|
161 |
+
if manual_result == "FAKE":
|
162 |
+
st.error(f"β οΈ Result: This news is **FAKE** (Verified by Database).")
|
|
|
|
|
|
|
163 |
else:
|
164 |
+
st.success(f"β
Result: This news is **REAL** (Verified by Database).")
|
165 |
else:
|
166 |
+
# Use AI model if fact is not in the database
|
167 |
+
prediction = fake_news_detector(news_input)
|
168 |
+
label = prediction[0]['label'].lower()
|
169 |
+
confidence = prediction[0]['score']
|
170 |
+
|
171 |
+
if "fake" in label or confidence < 0.5:
|
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})")
|