dvj4's picture
Update app.py
28fc86e verified
raw
history blame
1.11 kB
from PIL import Image
import numpy as np
import streamlit as st
# Define function to process uploaded image
def process_image(image):
# Convert image to numpy array
img_array = np.array(image)
# Dummy sidewalk segmentation (replace with your actual segmentation algorithm)
segmentation_result = np.zeros_like(img_array)
segmentation_result[:, :, 1] = 255 # Set sidewalk area to green (RGB: 0, 255, 0)
return segmentation_result
# Define Shiny app
def main():
st.title("Sidewalk Segmentation App")
uploaded_image = st.file_uploader("Upload an image", type=["jpg", "jpeg", "png"])
if uploaded_image is not None:
# Display uploaded image
image = Image.open(uploaded_image)
st.image(image, caption="Uploaded Image", use_column_width=True)
# Process uploaded image
with st.spinner("Processing..."):
segmentation_result = process_image(image)
# Display segmentation result
st.image(segmentation_result, caption="Sidewalk Segmentation Result", use_column_width=True)
if __name__ == "__main__":
main()