Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,7 +1,6 @@
|
|
| 1 |
import streamlit as st, uuid, os, shutil
|
| 2 |
from PIL import Image
|
| 3 |
from model.predict import predict
|
| 4 |
-
from model.heatmap import cam_heatmap
|
| 5 |
from feedback.db import init_db, save
|
| 6 |
|
| 7 |
init_db()
|
|
@@ -9,25 +8,29 @@ st.set_page_config("DeepTrust", "🛡️")
|
|
| 9 |
st.title("🛡️ DeepTrust – AI Image Deepfake Detector")
|
| 10 |
st.caption("Building trust in digital media using explainable AI")
|
| 11 |
|
| 12 |
-
file = st.file_uploader("Upload an image", ["jpg","png","jpeg"])
|
| 13 |
|
| 14 |
if file:
|
| 15 |
img = Image.open(file).convert("RGB")
|
| 16 |
st.image(img)
|
| 17 |
|
| 18 |
-
# Call predict() —
|
| 19 |
-
label, conf,
|
| 20 |
|
| 21 |
-
|
| 22 |
-
st.
|
|
|
|
| 23 |
|
|
|
|
| 24 |
result = "AI-Generated ❌" if label == "Fake" else "Real Image ✅"
|
| 25 |
st.subheader(result)
|
| 26 |
|
|
|
|
| 27 |
os.makedirs("data/uploads", exist_ok=True)
|
| 28 |
path = f"data/uploads/{uuid.uuid4()}.jpg"
|
| 29 |
img.save(path)
|
| 30 |
|
|
|
|
| 31 |
col1, col2 = st.columns(2)
|
| 32 |
if col1.button("Correct"):
|
| 33 |
save(path, label, label)
|
|
|
|
| 1 |
import streamlit as st, uuid, os, shutil
|
| 2 |
from PIL import Image
|
| 3 |
from model.predict import predict
|
|
|
|
| 4 |
from feedback.db import init_db, save
|
| 5 |
|
| 6 |
init_db()
|
|
|
|
| 8 |
st.title("🛡️ DeepTrust – AI Image Deepfake Detector")
|
| 9 |
st.caption("Building trust in digital media using explainable AI")
|
| 10 |
|
| 11 |
+
file = st.file_uploader("Upload an image", ["jpg", "png", "jpeg"])
|
| 12 |
|
| 13 |
if file:
|
| 14 |
img = Image.open(file).convert("RGB")
|
| 15 |
st.image(img)
|
| 16 |
|
| 17 |
+
# Call predict() — now returns 3 values: label, confidence, trust_score
|
| 18 |
+
label, conf, trust_score = predict(img)
|
| 19 |
|
| 20 |
+
# Display trust score
|
| 21 |
+
st.metric("Trust Score", f"{trust_score}/100")
|
| 22 |
+
st.progress(trust_score / 100)
|
| 23 |
|
| 24 |
+
# Show prediction result
|
| 25 |
result = "AI-Generated ❌" if label == "Fake" else "Real Image ✅"
|
| 26 |
st.subheader(result)
|
| 27 |
|
| 28 |
+
# Save uploaded image
|
| 29 |
os.makedirs("data/uploads", exist_ok=True)
|
| 30 |
path = f"data/uploads/{uuid.uuid4()}.jpg"
|
| 31 |
img.save(path)
|
| 32 |
|
| 33 |
+
# Feedback buttons
|
| 34 |
col1, col2 = st.columns(2)
|
| 35 |
if col1.button("Correct"):
|
| 36 |
save(path, label, label)
|