Skip to content

Add support to process full areas. Enable batch downloading and inference. #4

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Mar 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ Get started right away finding swimming pools and contributing them to OpenStree

| Google Colab | HuggingFace Spaces | GitHub Codespaces |
| -------------| ------------------- | ----------------- |
| [![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) |
| 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) |

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

Expand Down
9 changes: 5 additions & 4 deletions demo/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def __init__(self):


@st.fragment
def inference(lat_lon, margin):
def inference(lat_lon):
with st.spinner("Downloading model..."):
hf_hub_download(
"mozilla-ai/swimming-pool-detector",
Expand All @@ -56,8 +56,9 @@ def inference(lat_lon, margin):
yolo_model_file="models/model.pt",
output_dir="/tmp/results",
lat_lon=lat_lon,
margin=margin,
margin=2,
save_full_images=False,
batch_size=64,
)
return output_path, existing, new

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

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