asad231 commited on
Commit
15a675f
Β·
verified Β·
1 Parent(s): a3332d2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -5
app.py CHANGED
@@ -23,7 +23,7 @@ if st.button("Check News"):
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=50, max_size=(20, 20)): # βœ… Better quality & small size
27
  img = Image.open(image).convert("RGB")
28
  img.thumbnail(max_size)
29
  temp_file = tempfile.NamedTemporaryFile(delete=False, suffix=".jpg")
@@ -32,7 +32,7 @@ def compress_image(image, quality=50, max_size=(20, 20)): # βœ… Better quality
32
 
33
  if uploaded_image is not None:
34
  compressed_image_path = compress_image(uploaded_image)
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
@@ -57,8 +57,8 @@ def compress_video(video):
57
  fourcc = cv2.VideoWriter_fourcc(*'mp4v')
58
 
59
  # βœ… Further Reduce Video Resolution
60
- frame_width = 200
61
- frame_height = 1000
62
  out = cv2.VideoWriter(temp_file.name, fourcc, 12.0, (frame_width, frame_height)) # βœ… Lower FPS to 12
63
 
64
  while cap.isOpened():
@@ -81,4 +81,4 @@ if uploaded_video is not None:
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**")
 
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=60, max_size=(100, 100)): # βœ… Better quality & small size
27
  img = Image.open(image).convert("RGB")
28
  img.thumbnail(max_size)
29
  temp_file = tempfile.NamedTemporaryFile(delete=False, suffix=".jpg")
 
32
 
33
  if uploaded_image is not None:
34
  compressed_image_path = compress_image(uploaded_image)
35
+ st.image(compressed_image_path, caption="πŸ–ΌοΈ Compressed Image", use_container_width=True)
36
  if st.button("Analyze Image"):
37
  st.write("πŸ” Processing...")
38
  st.error("⚠️ Result: This image is a Deepfake.") # Replace with model
 
57
  fourcc = cv2.VideoWriter_fourcc(*'mp4v')
58
 
59
  # βœ… Further Reduce Video Resolution
60
+ frame_width = 180
61
+ frame_height = 320 # Adjusted for a more standard small resolution
62
  out = cv2.VideoWriter(temp_file.name, fourcc, 12.0, (frame_width, frame_height)) # βœ… Lower FPS to 12
63
 
64
  while cap.isOpened():
 
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**")