Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -32,10 +32,24 @@ st.title("📰 Fake News Detector")
|
|
32 |
st.sidebar.title("Select Input Type")
|
33 |
option = st.sidebar.radio("Choose an option", ["Text", "Image", "Video Link"])
|
34 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
35 |
# Input Section
|
36 |
if option == "Text":
|
37 |
news_text = st.text_area("Enter the news content to check:", height=200)
|
38 |
-
|
|
|
|
|
39 |
if not news_text.strip():
|
40 |
st.warning("Please enter some text.")
|
41 |
else:
|
@@ -47,14 +61,18 @@ if option == "Text":
|
|
47 |
|
48 |
elif option == "Image":
|
49 |
uploaded_image = st.file_uploader("Upload a news image", type=["jpg", "png", "jpeg"])
|
50 |
-
|
|
|
|
|
51 |
image = Image.open(uploaded_image)
|
52 |
st.session_state["news_image"] = image
|
53 |
st.session_state["analyze_image"] = True
|
54 |
|
55 |
elif option == "Video Link":
|
56 |
video_url = st.text_input("Enter the video link:")
|
57 |
-
|
|
|
|
|
58 |
if not video_url.strip():
|
59 |
st.warning("Please enter a valid video link.")
|
60 |
else:
|
@@ -96,4 +114,4 @@ if st.session_state.get("analyze_image", False):
|
|
96 |
if st.session_state.get("analyze_video", False):
|
97 |
video_url = st.session_state.get("video_url", "")
|
98 |
st.video(video_url)
|
99 |
-
st.info("Video analysis feature coming soon!")
|
|
|
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 |
+
if "analyze_text" not in st.session_state:
|
37 |
+
st.session_state["analyze_text"] = False
|
38 |
+
if "result_text" not in st.session_state:
|
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 |
if option == "Text":
|
49 |
news_text = st.text_area("Enter the news content to check:", height=200)
|
50 |
+
analyze_text_clicked = st.button("Analyze News", key="analyze_text")
|
51 |
+
|
52 |
+
if analyze_text_clicked:
|
53 |
if not news_text.strip():
|
54 |
st.warning("Please enter some text.")
|
55 |
else:
|
|
|
61 |
|
62 |
elif option == "Image":
|
63 |
uploaded_image = st.file_uploader("Upload a news image", type=["jpg", "png", "jpeg"])
|
64 |
+
analyze_image_clicked = st.button("Analyze Image", key="analyze_image")
|
65 |
+
|
66 |
+
if uploaded_image and analyze_image_clicked:
|
67 |
image = Image.open(uploaded_image)
|
68 |
st.session_state["news_image"] = image
|
69 |
st.session_state["analyze_image"] = True
|
70 |
|
71 |
elif option == "Video Link":
|
72 |
video_url = st.text_input("Enter the video link:")
|
73 |
+
analyze_video_clicked = st.button("Analyze Video", key="analyze_video")
|
74 |
+
|
75 |
+
if analyze_video_clicked:
|
76 |
if not video_url.strip():
|
77 |
st.warning("Please enter a valid video link.")
|
78 |
else:
|
|
|
114 |
if st.session_state.get("analyze_video", False):
|
115 |
video_url = st.session_state.get("video_url", "")
|
116 |
st.video(video_url)
|
117 |
+
st.info("Video analysis feature coming soon!")
|