Nimzi commited on
Commit
b6792a4
·
verified ·
1 Parent(s): ff59733

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +28 -12
app.py CHANGED
@@ -46,43 +46,59 @@ def analyze_video(video_path):
46
 
47
  def verify_news(news_text):
48
  search_url = f"https://www.google.com/search?q={'+'.join(news_text.split())}"
49
- return search_url
 
 
 
 
 
 
 
 
50
 
51
  st.set_page_config(page_title="Fake News Detector", layout="wide")
52
  st.title("📰 Fake News Detector")
53
 
54
- st.sidebar.title("Select Input Type")
55
- option = st.sidebar.radio("Choose an option", ["Text", "Image", "Video Link"])
56
 
57
- if option == "Text":
 
58
  news_text = st.text_area("Enter the news content to check:", height=200)
59
- if st.button("Analyze News"):
60
  if news_text.strip():
61
  result, accuracy = classify_text(news_text)
62
- verification_link = verify_news(news_text)
63
  st.write(f"**Result:** {result} (Accuracy: {accuracy}%)")
64
  st.markdown(f"[Verify on Google]({verification_link})")
 
 
65
  else:
66
  st.warning("Please enter some text.")
67
 
68
- elif option == "Image":
 
69
  uploaded_image = st.file_uploader("Upload a news image", type=["jpg", "png", "jpeg"])
70
- if uploaded_image and st.button("Analyze Image"):
71
  image = Image.open(uploaded_image)
72
  result = analyze_image(image)
73
  st.image(image, caption="Uploaded Image", use_column_width=True)
74
  st.write(f"**Result:** {result}")
75
- verification_link = verify_news("Fake news image verification")
76
  st.markdown(f"[Verify on Google]({verification_link})")
 
 
77
 
78
- elif option == "Video Link":
 
79
  video_url = st.text_input("Enter the video link:")
80
- if st.button("Analyze Video"):
81
  if video_url.strip():
82
  result = analyze_video(video_url)
83
  st.video(video_url)
84
  st.write(f"**Result:** {result}")
85
- verification_link = verify_news("Fake news video verification")
86
  st.markdown(f"[Verify on Google]({verification_link})")
 
 
87
  else:
88
  st.warning("Please enter a valid video link.")
 
46
 
47
  def verify_news(news_text):
48
  search_url = f"https://www.google.com/search?q={'+'.join(news_text.split())}"
49
+ sources = [
50
+ f"https://www.bbc.co.uk/search?q={'+'.join(news_text.split())}",
51
+ f"https://www.cnn.com/search?q={'+'.join(news_text.split())}",
52
+ f"https://www.reuters.com/search/news?blob={'+'.join(news_text.split())}",
53
+ f"https://www.factcheck.org/?s={'+'.join(news_text.split())}",
54
+ f"https://www.snopes.com/?s={'+'.join(news_text.split())}",
55
+ f"https://www.politifact.com/search/?q={'+'.join(news_text.split())}"
56
+ ]
57
+ return search_url, sources
58
 
59
  st.set_page_config(page_title="Fake News Detector", layout="wide")
60
  st.title("📰 Fake News Detector")
61
 
62
+ col1, col2, col3 = st.columns(3)
 
63
 
64
+ with col1:
65
+ st.header("Text News Analysis")
66
  news_text = st.text_area("Enter the news content to check:", height=200)
67
+ if st.button("Analyze News", key="text_analyze"):
68
  if news_text.strip():
69
  result, accuracy = classify_text(news_text)
70
+ verification_link, sources = verify_news(news_text)
71
  st.write(f"**Result:** {result} (Accuracy: {accuracy}%)")
72
  st.markdown(f"[Verify on Google]({verification_link})")
73
+ for source in sources:
74
+ st.markdown(f"[Check Source]({source})")
75
  else:
76
  st.warning("Please enter some text.")
77
 
78
+ with col2:
79
+ st.header("Image News Analysis")
80
  uploaded_image = st.file_uploader("Upload a news image", type=["jpg", "png", "jpeg"])
81
+ if uploaded_image and st.button("Analyze Image", key="image_analyze"):
82
  image = Image.open(uploaded_image)
83
  result = analyze_image(image)
84
  st.image(image, caption="Uploaded Image", use_column_width=True)
85
  st.write(f"**Result:** {result}")
86
+ verification_link, sources = verify_news("Fake news image verification")
87
  st.markdown(f"[Verify on Google]({verification_link})")
88
+ for source in sources:
89
+ st.markdown(f"[Check Source]({source})")
90
 
91
+ with col3:
92
+ st.header("Video News Analysis")
93
  video_url = st.text_input("Enter the video link:")
94
+ if st.button("Analyze Video", key="video_analyze"):
95
  if video_url.strip():
96
  result = analyze_video(video_url)
97
  st.video(video_url)
98
  st.write(f"**Result:** {result}")
99
+ verification_link, sources = verify_news("Fake news video verification")
100
  st.markdown(f"[Verify on Google]({verification_link})")
101
+ for source in sources:
102
+ st.markdown(f"[Check Source]({source})")
103
  else:
104
  st.warning("Please enter a valid video link.")