Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -73,10 +73,9 @@ def predict_image(img, image_model):
|
|
| 73 |
img_array = np.expand_dims(img_array, axis=0)
|
| 74 |
prediction = image_model.predict(img_array)
|
| 75 |
confidence = float(prediction[0][0]) * 100
|
| 76 |
-
if confidence > 50
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
return "REAL", 100 - confidence
|
| 80 |
|
| 81 |
|
| 82 |
# # ---------------------------
|
|
@@ -163,12 +162,13 @@ with tab2:
|
|
| 163 |
img = Image.open(uploaded_file).convert("RGB")
|
| 164 |
st.image(img, caption="Uploaded Image", use_container_width=True)
|
| 165 |
|
| 166 |
-
confidence = predict_image(img, image_model)
|
| 167 |
|
| 168 |
-
if
|
| 169 |
st.error(f"⚠️ AI GENERATED IMAGE ({confidence:.2f}%)")
|
| 170 |
else:
|
| 171 |
-
st.success(f"✅ REAL IMAGE ({
|
|
|
|
| 172 |
st.progress(int(confidence))
|
| 173 |
|
| 174 |
# ---------------------------
|
|
|
|
| 73 |
img_array = np.expand_dims(img_array, axis=0)
|
| 74 |
prediction = image_model.predict(img_array)
|
| 75 |
confidence = float(prediction[0][0]) * 100
|
| 76 |
+
label = "AI" if confidence > 50 else "REAL"
|
| 77 |
+
score = confidence if confidence > 50 else 100 - confidence
|
| 78 |
+
return label, score
|
|
|
|
| 79 |
|
| 80 |
|
| 81 |
# # ---------------------------
|
|
|
|
| 162 |
img = Image.open(uploaded_file).convert("RGB")
|
| 163 |
st.image(img, caption="Uploaded Image", use_container_width=True)
|
| 164 |
|
| 165 |
+
label, confidence = predict_image(img, image_model)
|
| 166 |
|
| 167 |
+
if label == "AI":
|
| 168 |
st.error(f"⚠️ AI GENERATED IMAGE ({confidence:.2f}%)")
|
| 169 |
else:
|
| 170 |
+
st.success(f"✅ REAL IMAGE ({confidence:.2f}%)")
|
| 171 |
+
|
| 172 |
st.progress(int(confidence))
|
| 173 |
|
| 174 |
# ---------------------------
|