Skip to content

Commit 3a45c27

Browse files
authored
Add support to process full areas. Enable batch downloading and inference. (#4)
* Add split_area_into_lat_lon_centers. * enh(download_tiles): Speeduo download process. Use ThreadPoolExecutor. Drop unnecessary usage of PIL for saving. * feat(demo): Add `run_inference_area`. Rename `run_inference` to `run_inference_point`. * test ThreadPoolExecutor * try batch prediction * Fix last batch call. Expose batch_size. Defaullt to 32. * Set defaults in notebooks and app * Update README to show process_area
1 parent ff35d4f commit 3a45c27

12 files changed

+638
-90
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ Get started right away finding swimming pools and contributing them to OpenStree
3838

3939
| Google Colab | HuggingFace Spaces | GitHub Codespaces |
4040
| -------------| ------------------- | ----------------- |
41-
| [![Run Inference](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/mozilla-ai/osm-ai-helper/blob/main/demo/run_inference.ipynb) | [![Try on Spaces](https://img.shields.io/badge/%F0%9F%A4%97%20Try%20on-Spaces-blue)](https://huggingface.co/spaces/mozilla-ai/osm-ai-helper) | [![Try on Codespaces](https://github.com/codespaces/badge.svg)](https://github.com/codespaces/new?hide_repo_select=true&ref=main&repo=928839264&skip_quickstart=true&machine=standardLinux32gb) |
41+
| Process full Area <br>[![Inference Area](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/mozilla-ai/osm-ai-helper/blob/main/demo/run_inference_area.ipynb) <br> Around a Point <br> [![Inference point](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/mozilla-ai/osm-ai-helper/blob/main/demo/run_inference_point.ipynb) | [![Try on Spaces](https://img.shields.io/badge/%F0%9F%A4%97%20Try%20on-Spaces-blue)](https://huggingface.co/spaces/mozilla-ai/osm-ai-helper) | [![Try on Codespaces](https://github.com/codespaces/badge.svg)](https://github.com/codespaces/new?hide_repo_select=true&ref=main&repo=928839264&skip_quickstart=true&machine=standardLinux32gb) |
4242

4343
You can also create your own dataset and finetune a new model for a different use case:
4444

demo/app.py

+5-4
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def __init__(self):
4343

4444

4545
@st.fragment
46-
def inference(lat_lon, margin):
46+
def inference(lat_lon):
4747
with st.spinner("Downloading model..."):
4848
hf_hub_download(
4949
"mozilla-ai/swimming-pool-detector",
@@ -56,8 +56,9 @@ def inference(lat_lon, margin):
5656
yolo_model_file="models/model.pt",
5757
output_dir="/tmp/results",
5858
lat_lon=lat_lon,
59-
margin=margin,
59+
margin=2,
6060
save_full_images=False,
61+
batch_size=64,
6162
)
6263
return output_path, existing, new
6364

@@ -97,7 +98,7 @@ def upload_results(output_path):
9798
"The results will be uploaded using the [osm-ai-helper](https://www.openstreetmap.org/user/osm-ai-helper) profile."
9899
)
99100
st.markdown(
100-
"You can check the [Colab Notebook](ttps://colab.research.google.com/github/mozilla-ai/osm-ai-helper/blob/main/demo/run_inference.ipynb)"
101+
"You can check the [Colab Notebook](ttps://colab.research.google.com/github/mozilla-ai/osm-ai-helper/blob/main/demo/run_inference_point.ipynb)"
101102
" and the [Authorization Guide](https://mozilla-ai.github.io/osm-ai-helper/authorization)"
102103
" to contribute with your own OpenStreetMap account."
103104
)
@@ -152,7 +153,7 @@ def upload_results(output_path):
152153
if st.button("Run Inference") and lat_lon:
153154
lat, lon = lat_lon.split(",")
154155
output_path, existing, new = inference(
155-
lat_lon=(float(lat.strip()), float(lon.strip())), margin=2
156+
lat_lon=(float(lat.strip()), float(lon.strip()))
156157
)
157158

158159
st.info(f"Found {len(existing)} swimming pools already in OpenStreetMaps.")

0 commit comments

Comments
 (0)