push app
Browse files
app.py
CHANGED
|
@@ -83,29 +83,34 @@ if picture is not None:
|
|
| 83 |
img = picture.copy()
|
| 84 |
img = crop_resize_image(img, size=512)
|
| 85 |
st.session_state.img = img # save the processed image
|
|
|
|
| 86 |
|
| 87 |
if "img" in st.session_state:
|
| 88 |
img = st.session_state.img
|
| 89 |
|
| 90 |
-
#
|
| 91 |
-
if "
|
| 92 |
-
|
| 93 |
-
|
| 94 |
-
|
| 95 |
-
|
| 96 |
-
|
| 97 |
-
|
| 98 |
-
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
|
| 102 |
-
|
| 103 |
-
|
| 104 |
-
|
| 105 |
-
|
|
|
|
| 106 |
st.rerun()
|
| 107 |
|
| 108 |
st.write("Coordinates:", st.session_state.get("coords"))
|
|
|
|
|
|
|
|
|
|
| 109 |
# Prompt input for inpainting
|
| 110 |
prompt = st.text_input("Prompt for inpainting (describe what should replace the selected area):")
|
| 111 |
|
|
|
|
| 83 |
img = picture.copy()
|
| 84 |
img = crop_resize_image(img, size=512)
|
| 85 |
st.session_state.img = img # save the processed image
|
| 86 |
+
st.session_state.coords_list = []
|
| 87 |
|
| 88 |
if "img" in st.session_state:
|
| 89 |
img = st.session_state.img
|
| 90 |
|
| 91 |
+
# Initialize the coordinates list if it doesn't exist.
|
| 92 |
+
if "coords_list" not in st.session_state:
|
| 93 |
+
st.session_state.coords_list = []
|
| 94 |
+
|
| 95 |
+
# Create a copy of the image and draw red dots for every stored coordinate.
|
| 96 |
+
img_with_dots = img.copy()
|
| 97 |
+
draw = ImageDraw.Draw(img_with_dots)
|
| 98 |
+
for coord in st.session_state.coords_list:
|
| 99 |
+
cx, cy = int(coord["x"]), int(coord["y"])
|
| 100 |
+
draw.ellipse((cx - 5, cy - 5, cx + 5, cy + 5), fill="red")
|
| 101 |
+
|
| 102 |
+
# Use the interactive component as the display canvas, showing the image with all dots.
|
| 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 |
+
st.session_state.coords_list.append(new_coord)
|
| 108 |
st.rerun()
|
| 109 |
|
| 110 |
st.write("Coordinates:", st.session_state.get("coords"))
|
| 111 |
+
|
| 112 |
+
|
| 113 |
+
|
| 114 |
# Prompt input for inpainting
|
| 115 |
prompt = st.text_input("Prompt for inpainting (describe what should replace the selected area):")
|
| 116 |
|