Update app.py
Browse files
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=
|
28 |
img = Image.open(image).convert("RGB")
|
29 |
-
img.thumbnail(max_size)
|
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
|
62 |
-
frame_width =
|
63 |
-
frame_height =
|
64 |
-
out = cv2.VideoWriter(temp_file.name, fourcc,
|
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**")
|