asad231 commited on
Commit
7f38c40
Β·
verified Β·
1 Parent(s): 2676ae4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -9
app.py CHANGED
@@ -17,16 +17,15 @@ news_input = st.text_area("Enter News Text:", "Type here...")
17
 
18
  if st.button("Check News"):
19
  st.write("πŸ” Processing...")
20
- # Fake news detection logic (Placeholder)
21
  st.success("βœ… Result: This news is FAKE.") # Replace with ML Model
22
 
23
  # ---- Deepfake Image Detection Section ----
24
  st.subheader("πŸ“Έ Deepfake Image Detection")
25
  uploaded_image = st.file_uploader("Upload an Image", type=["jpg", "png", "jpeg"])
26
 
27
- def compress_image(image, quality=30, max_size=(100, 100)):
28
  img = Image.open(image).convert("RGB")
29
- img.thumbnail(max_size) # Resize while keeping aspect ratio
30
  temp_file = tempfile.NamedTemporaryFile(delete=False, suffix=".jpg")
31
  img.save(temp_file.name, "JPEG", quality=quality)
32
  return temp_file.name
@@ -36,7 +35,6 @@ if uploaded_image is not None:
36
  st.image(compressed_image_path, caption="πŸ–ΌοΈ Compressed Image", use_column_width=True)
37
  if st.button("Analyze Image"):
38
  st.write("πŸ” Processing...")
39
- # Deepfake detection logic (Placeholder)
40
  st.error("⚠️ Result: This image is a Deepfake.") # Replace with model
41
 
42
  # ---- Deepfake Video Detection Section ----
@@ -58,10 +56,10 @@ def compress_video(video):
58
 
59
  fourcc = cv2.VideoWriter_fourcc(*'mp4v')
60
 
61
- # βœ… Reduce resolution to 480p
62
- frame_width = 320
63
- frame_height = 140
64
- out = cv2.VideoWriter(temp_file.name, fourcc, 20.0, (frame_width, frame_height))
65
 
66
  while cap.isOpened():
67
  ret, frame = cap.read()
@@ -81,7 +79,6 @@ if uploaded_video is not None:
81
  st.video(compressed_video_path)
82
  if st.button("Analyze Video"):
83
  st.write("πŸ” Processing...")
84
- # Deepfake video detection logic (Placeholder)
85
  st.warning("⚠️ Result: This video contains Deepfake elements.") # Replace with model
86
 
87
  st.markdown("πŸ”Ή **Developed for Fake News & Deepfake Detection Hackathon**")
 
17
 
18
  if st.button("Check News"):
19
  st.write("πŸ” Processing...")
 
20
  st.success("βœ… Result: This news is FAKE.") # Replace with ML Model
21
 
22
  # ---- Deepfake Image Detection Section ----
23
  st.subheader("πŸ“Έ Deepfake Image Detection")
24
  uploaded_image = st.file_uploader("Upload an Image", type=["jpg", "png", "jpeg"])
25
 
26
+ def compress_image(image, quality=25, max_size=(80, 80)): # ⬇️ Reduce size further
27
  img = Image.open(image).convert("RGB")
28
+ img.thumbnail(max_size)
29
  temp_file = tempfile.NamedTemporaryFile(delete=False, suffix=".jpg")
30
  img.save(temp_file.name, "JPEG", quality=quality)
31
  return temp_file.name
 
35
  st.image(compressed_image_path, caption="πŸ–ΌοΈ Compressed Image", use_column_width=True)
36
  if st.button("Analyze Image"):
37
  st.write("πŸ” Processing...")
 
38
  st.error("⚠️ Result: This image is a Deepfake.") # Replace with model
39
 
40
  # ---- Deepfake Video Detection Section ----
 
56
 
57
  fourcc = cv2.VideoWriter_fourcc(*'mp4v')
58
 
59
+ # βœ… Further Reduce Video Resolution
60
+ frame_width = 240
61
+ frame_height = 100
62
+ out = cv2.VideoWriter(temp_file.name, fourcc, 15.0, (frame_width, frame_height)) # ⬇️ Lower FPS to 15
63
 
64
  while cap.isOpened():
65
  ret, frame = cap.read()
 
79
  st.video(compressed_video_path)
80
  if st.button("Analyze Video"):
81
  st.write("πŸ” Processing...")
 
82
  st.warning("⚠️ Result: This video contains Deepfake elements.") # Replace with model
83
 
84
  st.markdown("πŸ”Ή **Developed for Fake News & Deepfake Detection Hackathon**")