Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
File size: 2,213 Bytes
49c9801 7316a14 6961bab 99d5451 7316a14 99d5451 49c9801 7316a14 b71a362 7316a14 0fda97d 9f3256a f1f31d2 49c9801 55d1ec4 c1671f7 55d1ec4 b71a362 55d1ec4 f4b593e 55d1ec4 79eef28 49c9801 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
import gradio as gr
from whereabouts.utils import download
from whereabouts.Matcher import Matcher
# download the various address databases
download('au_all_sm', 'saunteringcat/whereabouts-db')
download('au_all_lg', 'saunteringcat/whereabouts-db')
download('au_vic_lg', 'saunteringcat/whereabouts-db')
download('au_nsw_lg', 'saunteringcat/whereabouts-db')
# create a matcher object
matcher1 = Matcher('au_all_sm')
matcher2 = Matcher('au_all_lg')
matcher3 = Matcher('au_vic_lg')
matcher4 = Matcher('au_all_sm')
# function to geocode results
def geocode(addresses):
address_list = addresses.split('\n')
return matcher1.geocode(address_list)
# the gradio interface
with gr.Blocks(theme=gr.themes.Soft()) as demo:
gr.Markdown("# whereabouts")
gr.HTML("""
<div style="display:flex;column-gap:4px;">
<a href='https://github.com/ajl2718/whereabouts'>
<img src='https://img.shields.io/badge/Code-github-blue'>
</a>
</div>
""")
gr.Markdown("Fast, accurate open source geocoding in Python")
gr.Markdown("""
[whereabouts](https://www.github.com/ajl2718/whereabouts) is an open source package for Python for fast and accurate geocoding within
your own environment. It currently supports geocoding for Australia but with more countries coming soon. It uses duckDB to geocode up to 1000s of addresses per second based on an algorithm from [this paper](https://arxiv.org/abs/1708.01402)""")
gr.Markdown("""
```
pip install whereabouts
python -m whereabouts download au_all_sm
```
This demo shows whereabouts in action, using the small version of the Australian database. This is faster at the expense of accuracy. Running in your own environment speeds things up too.
""")
with gr.Row():
with gr.Column():
text_input = gr.Textbox(lines=2, label="Addresses to geocode (one row per address)")
geocode_button = gr.Button(variant='primary')
json_output = gr.JSON(label="Output JSON data")
geocode_button.click(fn=geocode, inputs=text_input, outputs=json_output, api_name="whereabouts_geocoder")
demo.launch() |