Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -7,35 +7,23 @@ from huggingface_hub import hf_shiny as hf
|
|
| 7 |
def process_image(image):
|
| 8 |
# Convert image to numpy array
|
| 9 |
img_array = np.array(image)
|
| 10 |
-
|
| 11 |
-
# Dummy sidewalk segmentation (replace with your actual segmentation algorithm)
|
| 12 |
patch_size = 128
|
| 13 |
step = 128
|
| 14 |
-
|
| 15 |
all_img_patches = []
|
| 16 |
-
|
| 17 |
for i in range(0, img_array.shape[0] - patch_size + 1, step):
|
| 18 |
for j in range(0, img_array.shape[1] - patch_size + 1, step):
|
| 19 |
single_patch_img = img_array[i:i + patch_size, j:j + patch_size]
|
| 20 |
all_img_patches.append(single_patch_img)
|
| 21 |
-
|
| 22 |
images = np.array(all_img_patches)
|
| 23 |
-
|
| 24 |
-
# Perform your actual image processing here
|
| 25 |
-
# Replace the code below with your segmentation algorithm or any other processing you need
|
| 26 |
-
# This is just a dummy example to show how to process the image
|
| 27 |
processed_images = []
|
| 28 |
for img in images:
|
| 29 |
processed_image = np.mean(img, axis=-1) # Example: Convert to grayscale
|
| 30 |
processed_images.append(processed_image)
|
| 31 |
-
|
| 32 |
processed_images = np.array(processed_images)
|
| 33 |
-
|
| 34 |
return processed_images
|
| 35 |
-
|
| 36 |
# Define Shiny app
|
| 37 |
app = hf.start()
|
| 38 |
-
|
| 39 |
@app.streamlit_app(
|
| 40 |
title="Sidewalk Segmentation App",
|
| 41 |
uploaders={"Upload an image": ["jpg", "jpeg", "png"]}
|
|
|
|
| 7 |
def process_image(image):
|
| 8 |
# Convert image to numpy array
|
| 9 |
img_array = np.array(image)
|
|
|
|
|
|
|
| 10 |
patch_size = 128
|
| 11 |
step = 128
|
|
|
|
| 12 |
all_img_patches = []
|
|
|
|
| 13 |
for i in range(0, img_array.shape[0] - patch_size + 1, step):
|
| 14 |
for j in range(0, img_array.shape[1] - patch_size + 1, step):
|
| 15 |
single_patch_img = img_array[i:i + patch_size, j:j + patch_size]
|
| 16 |
all_img_patches.append(single_patch_img)
|
|
|
|
| 17 |
images = np.array(all_img_patches)
|
| 18 |
+
# This is just a example to process the image
|
|
|
|
|
|
|
|
|
|
| 19 |
processed_images = []
|
| 20 |
for img in images:
|
| 21 |
processed_image = np.mean(img, axis=-1) # Example: Convert to grayscale
|
| 22 |
processed_images.append(processed_image)
|
|
|
|
| 23 |
processed_images = np.array(processed_images)
|
|
|
|
| 24 |
return processed_images
|
|
|
|
| 25 |
# Define Shiny app
|
| 26 |
app = hf.start()
|
|
|
|
| 27 |
@app.streamlit_app(
|
| 28 |
title="Sidewalk Segmentation App",
|
| 29 |
uploaders={"Upload an image": ["jpg", "jpeg", "png"]}
|