push app
Browse files
app.py
CHANGED
|
@@ -61,13 +61,16 @@ st.markdown(
|
|
| 61 |
"3. **Describe** what should replace it, and let the app do the rest!"
|
| 62 |
)
|
| 63 |
|
|
|
|
|
|
|
|
|
|
| 64 |
# Camera input widget (opens device camera on mobile/desktop)
|
| 65 |
picture = st.camera_input("Take a picture")
|
| 66 |
|
| 67 |
if picture is not None:
|
| 68 |
# When an image is captured, display it and allow point selection
|
| 69 |
img = Image.open(picture) # read image as PIL
|
| 70 |
-
|
| 71 |
|
| 72 |
# Let user click a point on the image. This returns a dict with 'x' and 'y'.
|
| 73 |
coords = streamlit_image_coordinates(img, key="click_img")
|
|
@@ -78,7 +81,7 @@ if picture is not None:
|
|
| 78 |
img_with_dot = img.copy()
|
| 79 |
draw = ImageDraw.Draw(img_with_dot)
|
| 80 |
draw.ellipse((cx-5, cy-5, cx+5, cy+5), fill='red')
|
| 81 |
-
|
| 82 |
else:
|
| 83 |
cx = cy = None
|
| 84 |
|
|
@@ -106,4 +109,4 @@ if picture is not None:
|
|
| 106 |
result = sd_pipe(prompt=prompt, image=img, mask_image=mask_image).images[0]
|
| 107 |
|
| 108 |
# Display the final inpainted image
|
| 109 |
-
|
|
|
|
| 61 |
"3. **Describe** what should replace it, and let the app do the rest!"
|
| 62 |
)
|
| 63 |
|
| 64 |
+
# Create one canvas placeholder for all image updates
|
| 65 |
+
canvas = st.empty()
|
| 66 |
+
|
| 67 |
# Camera input widget (opens device camera on mobile/desktop)
|
| 68 |
picture = st.camera_input("Take a picture")
|
| 69 |
|
| 70 |
if picture is not None:
|
| 71 |
# When an image is captured, display it and allow point selection
|
| 72 |
img = Image.open(picture) # read image as PIL
|
| 73 |
+
canvas.image(img, caption="Captured Image", use_container_width=True)
|
| 74 |
|
| 75 |
# Let user click a point on the image. This returns a dict with 'x' and 'y'.
|
| 76 |
coords = streamlit_image_coordinates(img, key="click_img")
|
|
|
|
| 81 |
img_with_dot = img.copy()
|
| 82 |
draw = ImageDraw.Draw(img_with_dot)
|
| 83 |
draw.ellipse((cx-5, cy-5, cx+5, cy+5), fill='red')
|
| 84 |
+
canvas.image(img_with_dot, caption=f"Selected Point: ({cx}, {cy})", use_container_width=True)
|
| 85 |
else:
|
| 86 |
cx = cy = None
|
| 87 |
|
|
|
|
| 109 |
result = sd_pipe(prompt=prompt, image=img, mask_image=mask_image).images[0]
|
| 110 |
|
| 111 |
# Display the final inpainted image
|
| 112 |
+
canvas.image(result, caption="Inpainted Image", use_container_width=True)
|