Update app.py
Browse files
app.py
CHANGED
@@ -1,47 +1,36 @@
|
|
1 |
-
|
2 |
-
|
3 |
-
|
4 |
-
import requests
|
5 |
-
from
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
model = pipeline("image-classification", model="nateraw/resnet50-oxford-flowers")
|
38 |
-
results = model(thumbnail_url)
|
39 |
-
|
40 |
-
st.subheader("Detection Results:")
|
41 |
-
for result in results:
|
42 |
-
st.write(f"**{result['label']}**: {result['score']*100:.2f}% confidence")
|
43 |
-
else:
|
44 |
-
st.error("Failed to load thumbnail. Please check the YouTube link.")
|
45 |
-
|
46 |
-
if __name__ == "__main__":
|
47 |
-
main()
|
|
|
1 |
+
import streamlit as st
|
2 |
+
from transformers import pipeline
|
3 |
+
from PIL import Image
|
4 |
+
import requests
|
5 |
+
from io import BytesIO
|
6 |
+
|
7 |
+
# Title and description
|
8 |
+
st.title("Deepfake Image & Video Detector")
|
9 |
+
st.write("Upload an image or enter a video link to check for AI manipulations.")
|
10 |
+
|
11 |
+
# Image Detection Function
|
12 |
+
def detect_image(image_file):
|
13 |
+
model = pipeline("image-classification", model="microsoft/resnet-50")
|
14 |
+
image = Image.open(image_file)
|
15 |
+
results = model(image)
|
16 |
+
return results
|
17 |
+
|
18 |
+
# Video Detection Function (Placeholder)
|
19 |
+
def detect_video(video_link):
|
20 |
+
st.write("Video detection coming soon.")
|
21 |
+
|
22 |
+
# Image Upload Section
|
23 |
+
uploaded_image = st.file_uploader("Upload an image", type=["jpg", "jpeg", "png"])
|
24 |
+
if uploaded_image:
|
25 |
+
st.image(uploaded_image, caption="Uploaded Image", use_container_width=True)
|
26 |
+
with st.spinner("Analyzing image..."):
|
27 |
+
image_results = detect_image(uploaded_image)
|
28 |
+
st.write("### Detection Results:")
|
29 |
+
for result in image_results:
|
30 |
+
st.write(f"{result['label']}: {result['score']*100:.2f}%")
|
31 |
+
|
32 |
+
# Video Link Section
|
33 |
+
video_link = st.text_input("Enter a video link")
|
34 |
+
if video_link:
|
35 |
+
st.write(f"Analyzing video at: {video_link}")
|
36 |
+
detect_video(video_link)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|