Update app.py
Browse files
app.py
CHANGED
|
@@ -868,7 +868,8 @@ def main():
|
|
| 868 |
image = uploaded_image
|
| 869 |
col1, col2 = st.columns([1, 2])
|
| 870 |
with col1:
|
| 871 |
-
|
|
|
|
| 872 |
|
| 873 |
# Continue with Xception model analysis
|
| 874 |
if st.session_state.xception_model_loaded:
|
|
@@ -918,11 +919,20 @@ def main():
|
|
| 918 |
|
| 919 |
# Display face box on image if detected
|
| 920 |
if face_box:
|
|
|
|
| 921 |
img_to_show = original_image.copy()
|
| 922 |
img_draw = np.array(img_to_show)
|
| 923 |
x, y, w, h = face_box
|
| 924 |
-
|
| 925 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 926 |
|
| 927 |
# GradCAM visualization with error handling
|
| 928 |
st.subheader("GradCAM Visualization")
|
|
@@ -932,8 +942,11 @@ def main():
|
|
| 932 |
)
|
| 933 |
|
| 934 |
if comparison:
|
| 935 |
-
#
|
| 936 |
-
st.
|
|
|
|
|
|
|
|
|
|
| 937 |
|
| 938 |
# Save for later use
|
| 939 |
st.session_state.comparison_image = comparison
|
|
|
|
| 868 |
image = uploaded_image
|
| 869 |
col1, col2 = st.columns([1, 2])
|
| 870 |
with col1:
|
| 871 |
+
# Use a consistent width based on the container
|
| 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:
|
|
|
|
| 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 |
)
|
| 943 |
|
| 944 |
if comparison:
|
| 945 |
+
# Add some spacing for better visual separation
|
| 946 |
+
st.write("")
|
| 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
|