Spaces:
Running
on
Zero
Running
on
Zero
Suchinthana
commited on
Commit
·
084a1c8
1
Parent(s):
42897ae
Return type correction
Browse files
app.py
CHANGED
@@ -109,22 +109,28 @@ def generate_geojson(response):
|
|
109 |
# Generate static map image
|
110 |
@spaces.GPU
|
111 |
def generate_static_map(geojson_data):
|
|
|
112 |
m = StaticMap(500, 500)
|
|
|
|
|
113 |
for feature in geojson_data["features"]:
|
114 |
geom_type = feature["geometry"]["type"]
|
115 |
coords = feature["geometry"]["coordinates"]
|
116 |
|
117 |
if geom_type == "Point":
|
|
|
118 |
m.add_marker(CircleMarker((coords[0], coords[1]), 'blue', 10))
|
119 |
elif geom_type in ["MultiPoint", "LineString"]:
|
|
|
120 |
for coord in coords:
|
121 |
m.add_marker(CircleMarker((coord[0], coord[1]), 'red', 10))
|
122 |
elif geom_type in ["Polygon", "MultiPolygon"]:
|
|
|
123 |
for polygon in coords:
|
124 |
m.add_polygon(Polygon([(c[0], c[1]) for c in polygon], 'green', 3))
|
125 |
-
|
126 |
-
|
127 |
-
return
|
128 |
|
129 |
# ControlNet pipeline setup
|
130 |
controlnet = ControlNetModel.from_pretrained("lllyasviel/control_v11p_sd15_inpaint", torch_dtype=torch.float16)
|
|
|
109 |
# Generate static map image
|
110 |
@spaces.GPU
|
111 |
def generate_static_map(geojson_data):
|
112 |
+
# Create a static map object with specified dimensions
|
113 |
m = StaticMap(500, 500)
|
114 |
+
|
115 |
+
# Process each feature in the GeoJSON
|
116 |
for feature in geojson_data["features"]:
|
117 |
geom_type = feature["geometry"]["type"]
|
118 |
coords = feature["geometry"]["coordinates"]
|
119 |
|
120 |
if geom_type == "Point":
|
121 |
+
# Add a blue marker for Point geometries
|
122 |
m.add_marker(CircleMarker((coords[0], coords[1]), 'blue', 10))
|
123 |
elif geom_type in ["MultiPoint", "LineString"]:
|
124 |
+
# Add a red marker for each point in MultiPoint or LineString geometries
|
125 |
for coord in coords:
|
126 |
m.add_marker(CircleMarker((coord[0], coord[1]), 'red', 10))
|
127 |
elif geom_type in ["Polygon", "MultiPolygon"]:
|
128 |
+
# Add green polygons for Polygon or MultiPolygon geometries
|
129 |
for polygon in coords:
|
130 |
m.add_polygon(Polygon([(c[0], c[1]) for c in polygon], 'green', 3))
|
131 |
+
|
132 |
+
# Render the static map and return the Pillow Image object
|
133 |
+
return m.render(zoom=10)
|
134 |
|
135 |
# ControlNet pipeline setup
|
136 |
controlnet = ControlNetModel.from_pretrained("lllyasviel/control_v11p_sd15_inpaint", torch_dtype=torch.float16)
|