Update app.py
Browse files
app.py
CHANGED
@@ -868,8 +868,7 @@ def main():
|
|
868 |
image = uploaded_image
|
869 |
col1, col2 = st.columns([1, 2])
|
870 |
with col1:
|
871 |
-
|
872 |
-
st.image(image, caption="Uploaded Image", use_column_width=True)
|
873 |
|
874 |
# Continue with Xception model analysis
|
875 |
if st.session_state.xception_model_loaded:
|
@@ -916,23 +915,6 @@ def main():
|
|
916 |
with col2:
|
917 |
st.markdown("### Detection Result")
|
918 |
st.markdown(f"**Classification:** {pred_label} (Confidence: {confidence:.2%})")
|
919 |
-
|
920 |
-
# Display face box on image if detected
|
921 |
-
if face_box:
|
922 |
-
# Create a proper visualization that matches the GradCAM alignment
|
923 |
-
img_to_show = original_image.copy()
|
924 |
-
img_draw = np.array(img_to_show)
|
925 |
-
x, y, w, h = face_box
|
926 |
-
|
927 |
-
# Draw rectangle with thicker line and better color for visibility
|
928 |
-
cv2.rectangle(img_draw, (x, y), (x + w, y + h), (0, 255, 0), 3)
|
929 |
-
|
930 |
-
# Add a caption inside the image for clarity
|
931 |
-
font = cv2.FONT_HERSHEY_SIMPLEX
|
932 |
-
cv2.putText(img_draw, "Detected Face", (x, y-10), font, 0.6, (0, 255, 0), 2)
|
933 |
-
|
934 |
-
# Display full image with box instead of cropped face
|
935 |
-
st.image(Image.fromarray(img_draw), caption="Face Detection Result", use_column_width=True)
|
936 |
|
937 |
# GradCAM visualization with error handling
|
938 |
st.subheader("GradCAM Visualization")
|
@@ -942,11 +924,8 @@ def main():
|
|
942 |
)
|
943 |
|
944 |
if comparison:
|
945 |
-
#
|
946 |
-
st.
|
947 |
-
|
948 |
-
# Display GradCAM results with better sizing and alignment
|
949 |
-
st.image(comparison, caption="Original | CAM | Overlay", use_column_width=True)
|
950 |
|
951 |
# Save for later use
|
952 |
st.session_state.comparison_image = comparison
|
|
|
868 |
image = uploaded_image
|
869 |
col1, col2 = st.columns([1, 2])
|
870 |
with col1:
|
871 |
+
st.image(image, caption="Uploaded Image", width=300)
|
|
|
872 |
|
873 |
# Continue with Xception model analysis
|
874 |
if st.session_state.xception_model_loaded:
|
|
|
915 |
with col2:
|
916 |
st.markdown("### Detection Result")
|
917 |
st.markdown(f"**Classification:** {pred_label} (Confidence: {confidence:.2%})")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
918 |
|
919 |
# GradCAM visualization with error handling
|
920 |
st.subheader("GradCAM Visualization")
|
|
|
924 |
)
|
925 |
|
926 |
if comparison:
|
927 |
+
# Display GradCAM results (controlled size)
|
928 |
+
st.image(comparison, caption="Original | CAM | Overlay", width=700)
|
|
|
|
|
|
|
929 |
|
930 |
# Save for later use
|
931 |
st.session_state.comparison_image = comparison
|