Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,9 +1,7 @@
|
|
1 |
from PIL import Image
|
2 |
import numpy as np
|
3 |
-
import
|
4 |
-
|
5 |
-
from PIL import Image
|
6 |
-
import numpy as np
|
7 |
|
8 |
# Define function to process uploaded image
|
9 |
def process_image(image):
|
@@ -36,21 +34,25 @@ def process_image(image):
|
|
36 |
return processed_images
|
37 |
|
38 |
# Define Shiny app
|
39 |
-
|
40 |
-
|
41 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
42 |
|
43 |
-
|
44 |
-
|
45 |
-
image = Image.open(uploaded_image)
|
46 |
-
st.image(image, caption="Uploaded Image", use_column_width=True)
|
47 |
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
|
52 |
-
|
53 |
-
|
54 |
|
55 |
if __name__ == "__main__":
|
56 |
-
|
|
|
1 |
from PIL import Image
|
2 |
import numpy as np
|
3 |
+
import io
|
4 |
+
from huggingface_hub import hf_shiny as hf
|
|
|
|
|
5 |
|
6 |
# Define function to process uploaded image
|
7 |
def process_image(image):
|
|
|
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"]}
|
42 |
+
)
|
43 |
+
def main(uploaded_image):
|
44 |
+
# Convert uploaded image to PIL Image
|
45 |
+
image = Image.open(io.BytesIO(uploaded_image.read()))
|
46 |
|
47 |
+
# Display uploaded image
|
48 |
+
app.image(image, caption="Uploaded Image")
|
|
|
|
|
49 |
|
50 |
+
# Process uploaded image
|
51 |
+
with app.spinner("Processing..."):
|
52 |
+
segmentation_result = process_image(image)
|
53 |
|
54 |
+
# Display segmentation result
|
55 |
+
app.image(segmentation_result, caption="Sidewalk Segmentation Result")
|
56 |
|
57 |
if __name__ == "__main__":
|
58 |
+
app.run()
|