Spaces:
Sleeping
Sleeping
Commit ·
86c9064
1
Parent(s): c777fdb
Implementado sistema de selección visual para botones: el botón activo se muestra en rojo y se añade mensaje de confirmación
Browse files- utils/preprocessing_ui.py +31 -3
utils/preprocessing_ui.py
CHANGED
|
@@ -38,6 +38,10 @@ def show_preprocessing_ui(image_service, img: np.ndarray) -> Dict[str, Any]:
|
|
| 38 |
# Initialize result
|
| 39 |
result = {"success": True, "message": ""}
|
| 40 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 41 |
# Create an expander for the suggested improvements
|
| 42 |
with st.expander("Suggested improvements available", expanded=True):
|
| 43 |
# Create a two-column layout for original and improved images
|
|
@@ -46,10 +50,16 @@ def show_preprocessing_ui(image_service, img: np.ndarray) -> Dict[str, Any]:
|
|
| 46 |
with col1:
|
| 47 |
st.markdown("**Original Image**")
|
| 48 |
st.image(img, use_column_width=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 49 |
# Botón "Continue with Original" debajo de la imagen original
|
| 50 |
continue_original = st.button("Continue with Original",
|
| 51 |
key="continue_original_btn",
|
| 52 |
-
type=
|
| 53 |
use_container_width=True)
|
| 54 |
|
| 55 |
# Apply basic enhancements and display the improved version
|
|
@@ -74,22 +84,40 @@ def show_preprocessing_ui(image_service, img: np.ndarray) -> Dict[str, Any]:
|
|
| 74 |
with col2:
|
| 75 |
st.markdown("**Improved Image**")
|
| 76 |
st.image(improved_rgb, use_column_width=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 77 |
# Botón "Use Improved Image" debajo de la imagen mejorada
|
| 78 |
use_improved = st.button("Use Improved Image",
|
| 79 |
key="use_improved_btn",
|
| 80 |
-
type=
|
| 81 |
use_container_width=True)
|
| 82 |
|
| 83 |
# Store the user's choice for later use
|
| 84 |
if use_improved:
|
| 85 |
st.session_state["use_improved_image"] = True
|
|
|
|
| 86 |
# We'll use this modified image for facial detection
|
| 87 |
st.session_state.current_image = improved_rgb
|
| 88 |
-
|
|
|
|
|
|
|
| 89 |
elif continue_original:
|
| 90 |
st.session_state["use_improved_image"] = False
|
|
|
|
| 91 |
st.session_state.current_image = img
|
|
|
|
|
|
|
| 92 |
st.info("Using original image for analysis.")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 93 |
|
| 94 |
# List the improvements made
|
| 95 |
st.markdown("**Improvements applied:**")
|
|
|
|
| 38 |
# Initialize result
|
| 39 |
result = {"success": True, "message": ""}
|
| 40 |
|
| 41 |
+
# Set default selection to improved image if not already set
|
| 42 |
+
if "selected_image_mode" not in st.session_state:
|
| 43 |
+
st.session_state["selected_image_mode"] = "improved"
|
| 44 |
+
|
| 45 |
# Create an expander for the suggested improvements
|
| 46 |
with st.expander("Suggested improvements available", expanded=True):
|
| 47 |
# Create a two-column layout for original and improved images
|
|
|
|
| 50 |
with col1:
|
| 51 |
st.markdown("**Original Image**")
|
| 52 |
st.image(img, use_column_width=True)
|
| 53 |
+
|
| 54 |
+
# Determine button style based on current selection
|
| 55 |
+
original_button_type = "secondary"
|
| 56 |
+
if st.session_state["selected_image_mode"] == "original":
|
| 57 |
+
original_button_type = "primary"
|
| 58 |
+
|
| 59 |
# Botón "Continue with Original" debajo de la imagen original
|
| 60 |
continue_original = st.button("Continue with Original",
|
| 61 |
key="continue_original_btn",
|
| 62 |
+
type=original_button_type,
|
| 63 |
use_container_width=True)
|
| 64 |
|
| 65 |
# Apply basic enhancements and display the improved version
|
|
|
|
| 84 |
with col2:
|
| 85 |
st.markdown("**Improved Image**")
|
| 86 |
st.image(improved_rgb, use_column_width=True)
|
| 87 |
+
|
| 88 |
+
# Determine button style based on current selection
|
| 89 |
+
improved_button_type = "secondary"
|
| 90 |
+
if st.session_state["selected_image_mode"] == "improved":
|
| 91 |
+
improved_button_type = "primary"
|
| 92 |
+
|
| 93 |
# Botón "Use Improved Image" debajo de la imagen mejorada
|
| 94 |
use_improved = st.button("Use Improved Image",
|
| 95 |
key="use_improved_btn",
|
| 96 |
+
type=improved_button_type,
|
| 97 |
use_container_width=True)
|
| 98 |
|
| 99 |
# Store the user's choice for later use
|
| 100 |
if use_improved:
|
| 101 |
st.session_state["use_improved_image"] = True
|
| 102 |
+
st.session_state["selected_image_mode"] = "improved"
|
| 103 |
# We'll use this modified image for facial detection
|
| 104 |
st.session_state.current_image = improved_rgb
|
| 105 |
+
|
| 106 |
+
# Display a success message with the selected image
|
| 107 |
+
st.success("Using improved image for analysis.")
|
| 108 |
elif continue_original:
|
| 109 |
st.session_state["use_improved_image"] = False
|
| 110 |
+
st.session_state["selected_image_mode"] = "original"
|
| 111 |
st.session_state.current_image = img
|
| 112 |
+
|
| 113 |
+
# Display a success message with the selected image
|
| 114 |
st.info("Using original image for analysis.")
|
| 115 |
+
|
| 116 |
+
# Show a message about the currently selected image
|
| 117 |
+
if st.session_state["selected_image_mode"] == "improved":
|
| 118 |
+
st.markdown("<div style='background-color: #1E3A8A; padding: 10px; border-radius: 5px; color: white;'><center>Using improved image for analysis.</center></div>", unsafe_allow_html=True)
|
| 119 |
+
else:
|
| 120 |
+
st.markdown("<div style='background-color: #1E3A8A; padding: 10px; border-radius: 5px; color: white;'><center>Using original image for analysis.</center></div>", unsafe_allow_html=True)
|
| 121 |
|
| 122 |
# List the improvements made
|
| 123 |
st.markdown("**Improvements applied:**")
|