File size: 1,616 Bytes
e2d012c 891435c 152548d 40da3e8 152548d 40da3e8 152548d 7d6df95 ceb14ca c717e72 37f2989 778cd43 37f2989 40da3e8 152548d 40da3e8 891435c 40da3e8 152548d 891435c |
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 50 51 52 53 |
import os
import gradio as gr
from huggingface_hub import HfApi
from pydriosm.reader import GeofabrikReader
reponame="Omnibus/osm"
save_data=f'https://huggingface.co/datasets/{reponame}/raw/main/'
token_self = os.environ['HF_TOKEN']
api=HfApi(token=token_self)
def save_file_data(inp, key):
if inp == os.environ.get("PASS"):
try:
file_obj=inp
api.upload_file(
path_or_fileobj=inp,
path_in_repo=inp,
repo_id=reponame,
#repo_id=save_data.split('datasets/',1)[1].split('/raw',1)[0],
token=token_self,
repo_type="dataset",
)
print("Done")
except Exception as e:
print(e)
def get_map(inp):
if inp == os.environ.get("PASS"):
print("downloading")
#os.system("wget https://download.geofabrik.de/north-america/canada/quebec-latest.osm.pbf")
os.system("wget https://download.geofabrik.de/north-america-latest.osm.pbf")
print("done")
#out = os.path.abspath("quebec-latest.osm.pbf")
#print (out)
save_file_data("north-america-latest.osm.pbf", inp)
print("saved")
def process_data():
gfr = GeofabrikReader()
subrgn_name=""
parsed_1 = gfr.read_osm_pbf(
subregion_name=subrgn_name, data_dir=dat_dir, expand=True, verbose=True)
with gr.Blocks() as app:
with gr.Tab("Process"):
proc_btn=gr.Button("Process")
with gr.Tab("Load"):
with gr.Row():
inp_pass=gr.Textbox()
btn=gr.Button()
btn.click(get_map,inp_pass,None)
app.launch() |