push app
Browse files
app.py
CHANGED
|
@@ -66,6 +66,10 @@ def load_models():
|
|
| 66 |
# Initialize the models (this will run only once thanks to caching)
|
| 67 |
# fastsam_model, sd_pipe = load_models()
|
| 68 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 69 |
# Title
|
| 70 |
st.subheader("ReDesign")
|
| 71 |
|
|
@@ -103,7 +107,7 @@ if "img" in st.session_state:
|
|
| 103 |
new_coord = streamlit_image_coordinates(img_with_dots, key="click_img")
|
| 104 |
|
| 105 |
# If a new coordinate is received and it's not already in our list, add it and force a rerun.
|
| 106 |
-
if new_coord and new_coord not in st.session_state.coords_list:
|
| 107 |
is_close = False
|
| 108 |
for coord in st.session_state.coords_list:
|
| 109 |
existing = np.array([coord["x"], coord["y"]])
|
|
@@ -113,8 +117,10 @@ if "img" in st.session_state:
|
|
| 113 |
break
|
| 114 |
if is_close:
|
| 115 |
st.session_state.coords_list.remove(coord)
|
|
|
|
| 116 |
else:
|
| 117 |
st.session_state.coords_list.append(new_coord)
|
|
|
|
| 118 |
st.rerun()
|
| 119 |
|
| 120 |
st.write("Coordinates:", st.session_state.get("coords"))
|
|
|
|
| 66 |
# Initialize the models (this will run only once thanks to caching)
|
| 67 |
# fastsam_model, sd_pipe = load_models()
|
| 68 |
|
| 69 |
+
# Ensure we have a state for removing_dots
|
| 70 |
+
if "is_removing_dot" not in st.session_state:
|
| 71 |
+
st.session_state.is_removing_dot = False
|
| 72 |
+
|
| 73 |
# Title
|
| 74 |
st.subheader("ReDesign")
|
| 75 |
|
|
|
|
| 107 |
new_coord = streamlit_image_coordinates(img_with_dots, key="click_img")
|
| 108 |
|
| 109 |
# If a new coordinate is received and it's not already in our list, add it and force a rerun.
|
| 110 |
+
if new_coord and new_coord not in st.session_state.coords_list and not st.session_state.is_removing_dot:
|
| 111 |
is_close = False
|
| 112 |
for coord in st.session_state.coords_list:
|
| 113 |
existing = np.array([coord["x"], coord["y"]])
|
|
|
|
| 117 |
break
|
| 118 |
if is_close:
|
| 119 |
st.session_state.coords_list.remove(coord)
|
| 120 |
+
st.session_state.is_removing_dot = True
|
| 121 |
else:
|
| 122 |
st.session_state.coords_list.append(new_coord)
|
| 123 |
+
st.session_state.is_removing_dot = False
|
| 124 |
st.rerun()
|
| 125 |
|
| 126 |
st.write("Coordinates:", st.session_state.get("coords"))
|