Spaces:
Sleeping
Sleeping
Change blur slider
Browse files
app.py
CHANGED
|
@@ -118,7 +118,7 @@ with left:
|
|
| 118 |
with right:
|
| 119 |
st.header("Set blur settings.")
|
| 120 |
with st.form("Blur_form"):
|
| 121 |
-
options = ["
|
| 122 |
selection = st.radio(
|
| 123 |
"Choose a blur type:",
|
| 124 |
options, index=None,
|
|
@@ -127,9 +127,11 @@ with right:
|
|
| 127 |
"Use depth estimation"],
|
| 128 |
horizontal=True
|
| 129 |
)
|
| 130 |
-
|
| 131 |
submitted = st.form_submit_button("Apply Blur", disabled=(up_img is None), type="primary")
|
| 132 |
st.divider()
|
|
|
|
|
|
|
| 133 |
if up_img:
|
| 134 |
image = Image.open(up_img).convert("RGB")
|
| 135 |
disp_left, disp_right = st.columns(2)
|
|
@@ -138,7 +140,8 @@ if up_img:
|
|
| 138 |
st.image(og_img, caption="Original Image", width=300)
|
| 139 |
with disp_right:
|
| 140 |
if submitted and selection in options:
|
| 141 |
-
|
|
|
|
| 142 |
with st.spinner(f"Spinning violently around the y-axis..."):
|
| 143 |
result = gaussian_blur(image, blur_str)
|
| 144 |
elif selection == "Lens":
|
|
|
|
| 118 |
with right:
|
| 119 |
st.header("Set blur settings.")
|
| 120 |
with st.form("Blur_form"):
|
| 121 |
+
options = ["Background", "Lens"]
|
| 122 |
selection = st.radio(
|
| 123 |
"Choose a blur type:",
|
| 124 |
options, index=None,
|
|
|
|
| 127 |
"Use depth estimation"],
|
| 128 |
horizontal=True
|
| 129 |
)
|
| 130 |
+
blur_level = st.select_slider("Blur Strength", options=["very low","low","medium","high","very high"])
|
| 131 |
submitted = st.form_submit_button("Apply Blur", disabled=(up_img is None), type="primary")
|
| 132 |
st.divider()
|
| 133 |
+
|
| 134 |
+
blur_levels = {"very low":5, "low":10, "medium":15, "high":20, "very high":30}
|
| 135 |
if up_img:
|
| 136 |
image = Image.open(up_img).convert("RGB")
|
| 137 |
disp_left, disp_right = st.columns(2)
|
|
|
|
| 140 |
st.image(og_img, caption="Original Image", width=300)
|
| 141 |
with disp_right:
|
| 142 |
if submitted and selection in options:
|
| 143 |
+
blur_str = blur_levels[blur_level]
|
| 144 |
+
if selection == "Background":
|
| 145 |
with st.spinner(f"Spinning violently around the y-axis..."):
|
| 146 |
result = gaussian_blur(image, blur_str)
|
| 147 |
elif selection == "Lens":
|