Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -77,6 +77,9 @@ if uploaded_image:
|
|
| 77 |
|
| 78 |
st.image(image, caption="Input Image", use_column_width=True)
|
| 79 |
|
|
|
|
|
|
|
|
|
|
| 80 |
# Preprocess and predict
|
| 81 |
resized = image.resize((512, 512))
|
| 82 |
x = np.expand_dims(np.array(resized), axis=0)
|
|
@@ -84,9 +87,8 @@ if uploaded_image:
|
|
| 84 |
|
| 85 |
st.text(f"Prediction min/max: {y.min():.5f} / {y.max():.5f}")
|
| 86 |
|
| 87 |
-
#
|
| 88 |
-
|
| 89 |
-
|
| 90 |
-
result = Image.fromarray(mask)
|
| 91 |
|
| 92 |
-
st.image(
|
|
|
|
| 77 |
|
| 78 |
st.image(image, caption="Input Image", use_column_width=True)
|
| 79 |
|
| 80 |
+
# Confidence threshold slider
|
| 81 |
+
threshold = st.slider("Confidence Threshold", 0.0, 1.0, 0.5, step=0.01)
|
| 82 |
+
|
| 83 |
# Preprocess and predict
|
| 84 |
resized = image.resize((512, 512))
|
| 85 |
x = np.expand_dims(np.array(resized), axis=0)
|
|
|
|
| 87 |
|
| 88 |
st.text(f"Prediction min/max: {y.min():.5f} / {y.max():.5f}")
|
| 89 |
|
| 90 |
+
# Apply thresholding if needed
|
| 91 |
+
mask_bin = (y > threshold).astype(np.uint8) * 255
|
| 92 |
+
mask_image = Image.fromarray(mask_bin)
|
|
|
|
| 93 |
|
| 94 |
+
st.image(mask_image, caption=f"Segmentation Mask (Threshold = {threshold:.2f})", use_column_width=True)
|