push app
Browse files
app.py
CHANGED
|
@@ -90,8 +90,6 @@ if "is_removing_dot" not in st.session_state:
|
|
| 90 |
st.subheader("InteractiveInpainting")
|
| 91 |
|
| 92 |
|
| 93 |
-
# Create one canvas placeholder for all image updates
|
| 94 |
-
canvas = st.empty()
|
| 95 |
|
| 96 |
# Camera input widget (opens device camera on mobile/desktop)
|
| 97 |
# picture = st.camera_input("Take a picture")
|
|
@@ -155,10 +153,20 @@ else:
|
|
| 155 |
draw.ellipse((cx - 5, cy - 5, cx + 5, cy + 5), fill="red")
|
| 156 |
|
| 157 |
|
|
|
|
|
|
|
| 158 |
|
|
|
|
|
|
|
| 159 |
# Use the interactive component as the display canvas, showing the image with all dots.
|
| 160 |
new_coord = streamlit_image_coordinates(final_img, key="click_img", use_column_width="always")
|
| 161 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 162 |
# If a new coordinate is received and it's not already in our list, add it and force a rerun.
|
| 163 |
if new_coord and new_coord not in st.session_state.coords_list and not st.session_state.is_removing_dot:
|
| 164 |
is_close = False
|
|
|
|
| 90 |
st.subheader("InteractiveInpainting")
|
| 91 |
|
| 92 |
|
|
|
|
|
|
|
| 93 |
|
| 94 |
# Camera input widget (opens device camera on mobile/desktop)
|
| 95 |
# picture = st.camera_input("Take a picture")
|
|
|
|
| 153 |
draw.ellipse((cx - 5, cy - 5, cx + 5, cy + 5), fill="red")
|
| 154 |
|
| 155 |
|
| 156 |
+
# Get the original width from the image stored in session_state.
|
| 157 |
+
original_width = st.session_state.img.width # e.g. 480 from crop_resize_image
|
| 158 |
|
| 159 |
+
# Compute the scaling factor.
|
| 160 |
+
scale_factor = original_width / page_width
|
| 161 |
# Use the interactive component as the display canvas, showing the image with all dots.
|
| 162 |
new_coord = streamlit_image_coordinates(final_img, key="click_img", use_column_width="always")
|
| 163 |
|
| 164 |
+
# Remap from displayed coordinate to original coordinate
|
| 165 |
+
new_coord = {
|
| 166 |
+
"x": new_coord["x"] * scale_factor,
|
| 167 |
+
"y": new_coord["y"] * scale_factor
|
| 168 |
+
}
|
| 169 |
+
|
| 170 |
# If a new coordinate is received and it's not already in our list, add it and force a rerun.
|
| 171 |
if new_coord and new_coord not in st.session_state.coords_list and not st.session_state.is_removing_dot:
|
| 172 |
is_close = False
|