Spaces:
Sleeping
Sleeping
github-actions[bot]
commited on
Commit
·
a859142
1
Parent(s):
f5ee47a
Sync with https://github.com/mozilla-ai/osm-ai-helper
Browse files
app.py
CHANGED
@@ -6,7 +6,6 @@ import folium
|
|
6 |
import streamlit as st
|
7 |
from branca.element import MacroElement
|
8 |
from jinja2 import Template
|
9 |
-
from loguru import logger
|
10 |
from huggingface_hub import hf_hub_download
|
11 |
from PIL import Image
|
12 |
from streamlit_folium import st_folium
|
@@ -15,17 +14,6 @@ from osm_ai_helper.run_inference import run_inference
|
|
15 |
from osm_ai_helper.upload_osm import upload_osm
|
16 |
|
17 |
|
18 |
-
class StreamlitHandler:
|
19 |
-
def __init__(self):
|
20 |
-
self.text_widget = st.empty()
|
21 |
-
self.log_messages = ""
|
22 |
-
|
23 |
-
def write(self, message):
|
24 |
-
self.log_messages += message
|
25 |
-
self.text_widget.code(self.log_messages)
|
26 |
-
return
|
27 |
-
|
28 |
-
|
29 |
@st.fragment
|
30 |
def show_map():
|
31 |
class LatLngPopup(MacroElement):
|
@@ -70,6 +58,7 @@ def inference(lat_lon, margin):
|
|
70 |
lat_lon=lat_lon,
|
71 |
margin=margin,
|
72 |
)
|
|
|
73 |
return output_path, new
|
74 |
|
75 |
|
@@ -116,7 +105,6 @@ def upload_results(output_path):
|
|
116 |
comment = f"Add Swimming Pools. Contributed by {contributor}"
|
117 |
else:
|
118 |
comment = "Add Swimming Pools"
|
119 |
-
logger.add(StreamlitHandler(), format="<level>{message}</level>")
|
120 |
|
121 |
changeset = upload_osm(
|
122 |
results_dir=output_path / "keep",
|
@@ -140,11 +128,9 @@ show_map()
|
|
140 |
lat_lon = st.text_input("Paste the copied (latitude, longitude)")
|
141 |
|
142 |
if st.button("Run Inference") and lat_lon:
|
143 |
-
logger.add(StreamlitHandler(), format="<level>{message}</level>")
|
144 |
-
|
145 |
lat, lon = lat_lon.split(",")
|
146 |
output_path, new = inference(
|
147 |
-
lat_lon=(float(lat.strip()), float(lon.strip())), margin=
|
148 |
)
|
149 |
|
150 |
if new:
|
|
|
6 |
import streamlit as st
|
7 |
from branca.element import MacroElement
|
8 |
from jinja2 import Template
|
|
|
9 |
from huggingface_hub import hf_hub_download
|
10 |
from PIL import Image
|
11 |
from streamlit_folium import st_folium
|
|
|
14 |
from osm_ai_helper.upload_osm import upload_osm
|
15 |
|
16 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
17 |
@st.fragment
|
18 |
def show_map():
|
19 |
class LatLngPopup(MacroElement):
|
|
|
58 |
lat_lon=lat_lon,
|
59 |
margin=margin,
|
60 |
)
|
61 |
+
st.text(f"Found: {len(new)} new polygons")
|
62 |
return output_path, new
|
63 |
|
64 |
|
|
|
105 |
comment = f"Add Swimming Pools. Contributed by {contributor}"
|
106 |
else:
|
107 |
comment = "Add Swimming Pools"
|
|
|
108 |
|
109 |
changeset = upload_osm(
|
110 |
results_dir=output_path / "keep",
|
|
|
128 |
lat_lon = st.text_input("Paste the copied (latitude, longitude)")
|
129 |
|
130 |
if st.button("Run Inference") and lat_lon:
|
|
|
|
|
131 |
lat, lon = lat_lon.split(",")
|
132 |
output_path, new = inference(
|
133 |
+
lat_lon=(float(lat.strip()), float(lon.strip())), margin=2
|
134 |
)
|
135 |
|
136 |
if new:
|