Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -28,56 +28,39 @@ def verify_news(news_text):
|
|
28 |
st.set_page_config(page_title="Fake News Detector", layout="wide")
|
29 |
st.title("📰 Fake News Detector")
|
30 |
|
31 |
-
# Sidebar for Input Selection
|
32 |
-
st.sidebar.title("Select Input Type")
|
33 |
-
option = st.sidebar.radio("Choose an option", ["Text", "Image", "Video Link"])
|
34 |
-
|
35 |
# Ensure session state variables are initialized before modifying them
|
36 |
-
|
37 |
-
st.session_state
|
38 |
-
|
39 |
-
st.session_state["result_text"] = None
|
40 |
-
if "accuracy_text" not in st.session_state:
|
41 |
-
st.session_state["accuracy_text"] = None
|
42 |
-
if "analyze_image" not in st.session_state:
|
43 |
-
st.session_state["analyze_image"] = False
|
44 |
-
if "analyze_video" not in st.session_state:
|
45 |
-
st.session_state["analyze_video"] = False
|
46 |
|
47 |
# Input Section
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
if analyze_text_clicked:
|
53 |
-
if not news_text.strip():
|
54 |
-
st.warning("Please enter some text.")
|
55 |
-
else:
|
56 |
-
result, accuracy = classify_text(news_text)
|
57 |
-
st.session_state["news_text"] = news_text
|
58 |
-
st.session_state["analyze_text"] = True
|
59 |
-
st.session_state["result_text"] = result
|
60 |
-
st.session_state["accuracy_text"] = accuracy
|
61 |
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
st.session_state["news_image"] = image
|
69 |
-
st.session_state["analyze_image"] = True
|
70 |
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
81 |
|
82 |
# Results Section
|
83 |
st.subheader("📊 Analysis Results")
|
|
|
28 |
st.set_page_config(page_title="Fake News Detector", layout="wide")
|
29 |
st.title("📰 Fake News Detector")
|
30 |
|
|
|
|
|
|
|
|
|
31 |
# Ensure session state variables are initialized before modifying them
|
32 |
+
for key in ["analyze_text", "result_text", "accuracy_text", "analyze_image", "analyze_video", "news_text", "news_image", "video_url"]:
|
33 |
+
if key not in st.session_state:
|
34 |
+
st.session_state[key] = None
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
35 |
|
36 |
# Input Section
|
37 |
+
st.header("1️⃣ Text Input")
|
38 |
+
news_text = st.text_area("Enter the news content to check:", height=200)
|
39 |
+
analyze_text_clicked = st.button("Analyze Text")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
40 |
|
41 |
+
if analyze_text_clicked and news_text.strip():
|
42 |
+
result, accuracy = classify_text(news_text)
|
43 |
+
st.session_state["news_text"] = news_text
|
44 |
+
st.session_state["analyze_text"] = True
|
45 |
+
st.session_state["result_text"] = result
|
46 |
+
st.session_state["accuracy_text"] = accuracy
|
|
|
|
|
47 |
|
48 |
+
st.header("2️⃣ Image Upload")
|
49 |
+
uploaded_image = st.file_uploader("Upload a news image", type=["jpg", "png", "jpeg"])
|
50 |
+
analyze_image_clicked = st.button("Analyze Image")
|
51 |
+
|
52 |
+
if uploaded_image and analyze_image_clicked:
|
53 |
+
image = Image.open(uploaded_image)
|
54 |
+
st.session_state["news_image"] = image
|
55 |
+
st.session_state["analyze_image"] = True
|
56 |
+
|
57 |
+
st.header("3️⃣ Video Link Input")
|
58 |
+
video_url = st.text_input("Enter the video link:")
|
59 |
+
analyze_video_clicked = st.button("Analyze Video")
|
60 |
+
|
61 |
+
if analyze_video_clicked and video_url.strip():
|
62 |
+
st.session_state["video_url"] = video_url
|
63 |
+
st.session_state["analyze_video"] = True
|
64 |
|
65 |
# Results Section
|
66 |
st.subheader("📊 Analysis Results")
|