Spaces:
Sleeping
Sleeping
Ludovic Moncla
commited on
Commit
·
a8b7db5
1
Parent(s):
910e2fa
Update app.py
Browse files
app.py
CHANGED
|
@@ -22,6 +22,18 @@ def extract_coordinates(text):
|
|
| 22 |
return "No coordinates found"
|
| 23 |
|
| 24 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 25 |
examples = [
|
| 26 |
"* AACH ou ACH, s. f. petite ville d'Allemagne dans le cercle de Souabe, près de la source de l'Aach. Long. 26. 57. lat. 47. 55.",
|
| 27 |
"* ARCALU (Principauté d') petit état des Tartares-Monguls, sur la riviere d'Hoamko, où commence la grande muraille de la Chine, sous le 122e degré de longitude & le 42e de latitude septentrionale.",
|
|
@@ -33,7 +45,7 @@ examples = [
|
|
| 33 |
|
| 34 |
|
| 35 |
with gr.Blocks() as demo:
|
| 36 |
-
gr.Markdown("## Geographic Coordinate Extractor
|
| 37 |
|
| 38 |
with gr.Row():
|
| 39 |
with gr.Column():
|
|
@@ -47,10 +59,12 @@ with gr.Blocks() as demo:
|
|
| 47 |
|
| 48 |
|
| 49 |
with gr.Column():
|
| 50 |
-
out_text = gr.Textbox(label="Extracted coordinates")
|
| 51 |
-
#out_map = gr.Map(label="Location on Map")
|
| 52 |
run_btn.click(fn=extract_coordinates, inputs=inp, outputs=out_text)
|
| 53 |
|
|
|
|
|
|
|
|
|
|
| 54 |
with gr.Row():
|
| 55 |
|
| 56 |
gr.Examples(
|
|
|
|
| 22 |
return "No coordinates found"
|
| 23 |
|
| 24 |
|
| 25 |
+
def norm_coordinates(text):
|
| 26 |
+
|
| 27 |
+
generator = pipeline("text2text-generation", model="GEODE/mt5-small-coords-norm")
|
| 28 |
+
|
| 29 |
+
# Example input text
|
| 30 |
+
input_text = "extract_coordinates: " + text
|
| 31 |
+
|
| 32 |
+
# Generate prediction using the pipeline
|
| 33 |
+
predicted_coordinates_from_pipeline = generator(input_text, max_length=128)
|
| 34 |
+
|
| 35 |
+
return predicted_coordinates_from_pipeline[0]['generated_text']
|
| 36 |
+
|
| 37 |
examples = [
|
| 38 |
"* AACH ou ACH, s. f. petite ville d'Allemagne dans le cercle de Souabe, près de la source de l'Aach. Long. 26. 57. lat. 47. 55.",
|
| 39 |
"* ARCALU (Principauté d') petit état des Tartares-Monguls, sur la riviere d'Hoamko, où commence la grande muraille de la Chine, sous le 122e degré de longitude & le 42e de latitude septentrionale.",
|
|
|
|
| 45 |
|
| 46 |
|
| 47 |
with gr.Blocks() as demo:
|
| 48 |
+
gr.Markdown("## Geographic Coordinate Extractor")
|
| 49 |
|
| 50 |
with gr.Row():
|
| 51 |
with gr.Column():
|
|
|
|
| 59 |
|
| 60 |
|
| 61 |
with gr.Column():
|
| 62 |
+
out_text = gr.Textbox(label="Extracted coordinates (fine-tuned CamemBERT NER)")
|
|
|
|
| 63 |
run_btn.click(fn=extract_coordinates, inputs=inp, outputs=out_text)
|
| 64 |
|
| 65 |
+
out_text = gr.Textbox(label="Extracted and normalized coordinates (fine-tuned mT5)")
|
| 66 |
+
run_btn.click(fn=norm_coordinates, inputs=inp, outputs=out_text)
|
| 67 |
+
|
| 68 |
with gr.Row():
|
| 69 |
|
| 70 |
gr.Examples(
|