Spaces:
Sleeping
Sleeping
github-actions[bot]
commited on
Commit
·
01551ef
1
Parent(s):
3eaae45
Sync with https://github.com/mozilla-ai/osm-ai-helper
Browse files
app.py
CHANGED
@@ -26,18 +26,20 @@ class StreamlitHandler:
|
|
26 |
|
27 |
@st.fragment
|
28 |
def inference(lat_lon, margin):
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
|
|
|
|
41 |
return output_path, new
|
42 |
|
43 |
|
@@ -64,7 +66,7 @@ def handle_polygon(polygon):
|
|
64 |
discard_folder = polygon.parent / "discard"
|
65 |
discard_folder.mkdir(parents=True, exist_ok=True)
|
66 |
move(polygon, discard_folder / polygon.name)
|
67 |
-
st.
|
68 |
|
69 |
|
70 |
@st.fragment
|
@@ -73,7 +75,8 @@ def upload_results(output_path):
|
|
73 |
st.header("Upload all polygons in `keep`")
|
74 |
|
75 |
st.markdown("The results will be uploaded using our OpenStreetMap account.")
|
76 |
-
st.markdown(
|
|
|
77 |
" and the [Authorization Guide](https://mozilla-ai.github.io/osm-ai-helper/authorization)"
|
78 |
" to contribute with your own OpenStreetMap account."
|
79 |
)
|
@@ -89,7 +92,9 @@ def upload_results(output_path):
|
|
89 |
client_secret=os.environ["OSM_CLIENT_SECRET"],
|
90 |
comment=comment,
|
91 |
)
|
92 |
-
st.success(
|
|
|
|
|
93 |
|
94 |
|
95 |
st.title("Open Street Map AI Helper")
|
|
|
26 |
|
27 |
@st.fragment
|
28 |
def inference(lat_lon, margin):
|
29 |
+
with st.spinner("Downloading model..."):
|
30 |
+
hf_hub_download(
|
31 |
+
"daavoo/yolo-osm-pool-detector",
|
32 |
+
filename="model.pt",
|
33 |
+
repo_type="model",
|
34 |
+
local_dir="models",
|
35 |
+
)
|
36 |
+
with st.spinner("Running inference..."):
|
37 |
+
output_path, existing, new, missed = run_inference(
|
38 |
+
model_file="models/model.pt",
|
39 |
+
output_dir="results",
|
40 |
+
lat_lon=lat_lon,
|
41 |
+
margin=margin,
|
42 |
+
)
|
43 |
return output_path, new
|
44 |
|
45 |
|
|
|
66 |
discard_folder = polygon.parent / "discard"
|
67 |
discard_folder.mkdir(parents=True, exist_ok=True)
|
68 |
move(polygon, discard_folder / polygon.name)
|
69 |
+
st.warning(f"Polygon moved to {discard_folder}")
|
70 |
|
71 |
|
72 |
@st.fragment
|
|
|
75 |
st.header("Upload all polygons in `keep`")
|
76 |
|
77 |
st.markdown("The results will be uploaded using our OpenStreetMap account.")
|
78 |
+
st.markdown(
|
79 |
+
"You can check the [Colab Notebook](ttps://colab.research.google.com/github/mozilla-ai/osm-ai-helper/blob/main/demo/run_inference.ipynb)"
|
80 |
" and the [Authorization Guide](https://mozilla-ai.github.io/osm-ai-helper/authorization)"
|
81 |
" to contribute with your own OpenStreetMap account."
|
82 |
)
|
|
|
92 |
client_secret=os.environ["OSM_CLIENT_SECRET"],
|
93 |
comment=comment,
|
94 |
)
|
95 |
+
st.success(
|
96 |
+
f"Changeset created: https://www.openstreetmap.org/changeset/{changeset}"
|
97 |
+
)
|
98 |
|
99 |
|
100 |
st.title("Open Street Map AI Helper")
|