Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -50,11 +50,15 @@ if uploaded_image:
|
|
| 50 |
image = Image.open(uploaded_image).convert("RGB")
|
| 51 |
st.image(image, caption="Original Image", use_column_width=True)
|
| 52 |
|
| 53 |
-
# Preprocess and predict
|
| 54 |
resized = image.resize((512, 512))
|
| 55 |
-
x = np.expand_dims(np.array(resized)
|
| 56 |
y = model.predict(x)[0, :, :, 0]
|
| 57 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 58 |
y_norm = (y - y.min()) / (y.max() - y.min() + 1e-6)
|
| 59 |
mask = (y_norm * 255).astype(np.uint8)
|
| 60 |
result = Image.fromarray(mask)
|
|
|
|
| 50 |
image = Image.open(uploaded_image).convert("RGB")
|
| 51 |
st.image(image, caption="Original Image", use_column_width=True)
|
| 52 |
|
| 53 |
+
# Preprocess and predict (NO normalization here)
|
| 54 |
resized = image.resize((512, 512))
|
| 55 |
+
x = np.expand_dims(np.array(resized), axis=0)
|
| 56 |
y = model.predict(x)[0, :, :, 0]
|
| 57 |
|
| 58 |
+
# Print min/max to logs
|
| 59 |
+
st.text(f"Prediction min/max: {y.min():.5f} / {y.max():.5f}")
|
| 60 |
+
|
| 61 |
+
# Contrast stretch
|
| 62 |
y_norm = (y - y.min()) / (y.max() - y.min() + 1e-6)
|
| 63 |
mask = (y_norm * 255).astype(np.uint8)
|
| 64 |
result = Image.fromarray(mask)
|