Update app.py
Browse files
app.py
CHANGED
@@ -1,6 +1,7 @@
|
|
1 |
import os
|
2 |
import gradio as gr
|
3 |
from huggingface_hub import HfApi
|
|
|
4 |
|
5 |
reponame="Omnibus/osm"
|
6 |
save_data=f'https://huggingface.co/datasets/{reponame}/raw/main/'
|
@@ -8,20 +9,21 @@ token_self = os.environ['HF_TOKEN']
|
|
8 |
api=HfApi(token=token_self)
|
9 |
|
10 |
|
11 |
-
def save_file_data(inp):
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
|
|
25 |
|
26 |
def get_map(inp):
|
27 |
if inp == os.environ.get("PASS"):
|
@@ -31,11 +33,21 @@ def get_map(inp):
|
|
31 |
print("done")
|
32 |
#out = os.path.abspath("quebec-latest.osm.pbf")
|
33 |
#print (out)
|
34 |
-
save_file_data("north-america-latest.osm.pbf")
|
35 |
print("saved")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
36 |
with gr.Blocks() as app:
|
37 |
-
with gr.
|
38 |
-
|
39 |
-
|
|
|
|
|
|
|
40 |
btn.click(get_map,inp_pass,None)
|
41 |
app.launch()
|
|
|
1 |
import os
|
2 |
import gradio as gr
|
3 |
from huggingface_hub import HfApi
|
4 |
+
from pydriosm.reader import GeofabrikReader
|
5 |
|
6 |
reponame="Omnibus/osm"
|
7 |
save_data=f'https://huggingface.co/datasets/{reponame}/raw/main/'
|
|
|
9 |
api=HfApi(token=token_self)
|
10 |
|
11 |
|
12 |
+
def save_file_data(inp, key):
|
13 |
+
if inp == os.environ.get("PASS"):
|
14 |
+
try:
|
15 |
+
file_obj=inp
|
16 |
+
api.upload_file(
|
17 |
+
path_or_fileobj=inp,
|
18 |
+
path_in_repo=inp,
|
19 |
+
repo_id=reponame,
|
20 |
+
#repo_id=save_data.split('datasets/',1)[1].split('/raw',1)[0],
|
21 |
+
token=token_self,
|
22 |
+
repo_type="dataset",
|
23 |
+
)
|
24 |
+
print("Done")
|
25 |
+
except Exception as e:
|
26 |
+
print(e)
|
27 |
|
28 |
def get_map(inp):
|
29 |
if inp == os.environ.get("PASS"):
|
|
|
33 |
print("done")
|
34 |
#out = os.path.abspath("quebec-latest.osm.pbf")
|
35 |
#print (out)
|
36 |
+
save_file_data("north-america-latest.osm.pbf", inp)
|
37 |
print("saved")
|
38 |
+
|
39 |
+
def process_data():
|
40 |
+
gfr = GeofabrikReader()
|
41 |
+
subrgn_name=""
|
42 |
+
parsed_1 = gfr.read_osm_pbf(
|
43 |
+
subregion_name=subrgn_name, data_dir=dat_dir, expand=True, verbose=True)
|
44 |
+
|
45 |
with gr.Blocks() as app:
|
46 |
+
with gr.Tab("Process"):
|
47 |
+
proc_btn=gr.Button("Process")
|
48 |
+
with gr.Tab("Load"):
|
49 |
+
with gr.Row():
|
50 |
+
inp_pass=gr.Textbox()
|
51 |
+
btn=gr.Button()
|
52 |
btn.click(get_map,inp_pass,None)
|
53 |
app.launch()
|