Spaces:
Runtime error
Runtime error
Update app.py
#2
by adi-123 - opened
app.py
CHANGED
|
@@ -10,22 +10,33 @@ pipe = pipeline('image-classification', model=model_name)
|
|
| 10 |
st.title("Deepfake vs Real Image Detection")
|
| 11 |
|
| 12 |
uploaded_file = st.file_uploader("Choose an image...", type="jpg")
|
|
|
|
| 13 |
if uploaded_file is not None:
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
|
|
|
| 18 |
|
| 19 |
-
|
| 20 |
-
|
| 21 |
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 25 |
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
|
|
|
|
|
|
|
|
|
| 30 |
|
| 31 |
-
|
|
|
|
|
|
| 10 |
st.title("Deepfake vs Real Image Detection")
|
| 11 |
|
| 12 |
uploaded_file = st.file_uploader("Choose an image...", type="jpg")
|
| 13 |
+
|
| 14 |
if uploaded_file is not None:
|
| 15 |
+
image = Image.open(uploaded_file)
|
| 16 |
+
st.image(image, caption='Uploaded Image.', use_column_width=True)
|
| 17 |
+
|
| 18 |
+
st.write("")
|
| 19 |
+
st.write("Classifying...")
|
| 20 |
|
| 21 |
+
# Apply the model
|
| 22 |
+
result = pipe(image)
|
| 23 |
|
| 24 |
+
# Display the result
|
| 25 |
+
st.write("**Classification Result:**")
|
| 26 |
+
st.write("---------------")
|
| 27 |
+
for i, res in enumerate(result):
|
| 28 |
+
label = res["label"]
|
| 29 |
+
score = res["score"] * 100 # Convert to percentage
|
| 30 |
+
st.write(f"**{i+1}. {label}**: {score:.2f}%")
|
| 31 |
+
st.write("---------------")
|
| 32 |
|
| 33 |
+
# Determine the majority score
|
| 34 |
+
real_score = result[0]["score"] * 100
|
| 35 |
+
fake_score = result[1]["score"] * 100
|
| 36 |
+
if real_score > fake_score:
|
| 37 |
+
majority_label = "Real"
|
| 38 |
+
else:
|
| 39 |
+
majority_label = "Fake"
|
| 40 |
|
| 41 |
+
# Display the final result
|
| 42 |
+
st.write(f"**Given image is {majority_label}**")
|