Update app.py
Browse files
app.py
CHANGED
@@ -172,21 +172,25 @@ 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 |
import streamlit as st
|
176 |
|
|
|
|
|
|
|
177 |
st.subheader("π Fake News Detection")
|
178 |
news_input = st.text_area("Enter News Text:", placeholder="Type here...")
|
179 |
|
180 |
if st.button("Check News"):
|
181 |
st.write("π Processing...")
|
182 |
|
183 |
-
#
|
184 |
prediction = fake_news_detector(news_input)
|
185 |
label = prediction[0]['label'].lower()
|
186 |
confidence = prediction[0]['score']
|
187 |
|
188 |
-
# Ensure
|
189 |
-
if
|
190 |
st.error(f"β οΈ Result: This news is **FAKE**. (Confidence: {confidence:.2f})")
|
191 |
else:
|
192 |
st.success(f"β
Result: This news is **REAL**. (Confidence: {confidence:.2f})")
|
|
|
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 |
+
from transformers import pipeline
|
176 |
import streamlit as st
|
177 |
|
178 |
+
# β
Load a Valid Fake News Detection Model
|
179 |
+
fake_news_detector = pipeline("text-classification", model="MoritzLaurer/deberta-v3-large-contrastive-fake-news")
|
180 |
+
|
181 |
st.subheader("π Fake News Detection")
|
182 |
news_input = st.text_area("Enter News Text:", placeholder="Type here...")
|
183 |
|
184 |
if st.button("Check News"):
|
185 |
st.write("π Processing...")
|
186 |
|
187 |
+
# β
Get Model Prediction
|
188 |
prediction = fake_news_detector(news_input)
|
189 |
label = prediction[0]['label'].lower()
|
190 |
confidence = prediction[0]['score']
|
191 |
|
192 |
+
# β
Ensure Correct Classification
|
193 |
+
if "fake" in label or confidence < 0.5:
|
194 |
st.error(f"β οΈ Result: This news is **FAKE**. (Confidence: {confidence:.2f})")
|
195 |
else:
|
196 |
st.success(f"β
Result: This news is **REAL**. (Confidence: {confidence:.2f})")
|