vancauwe commited on
Commit
cb23aba
·
1 Parent(s): a62bbf7

fix: address for geolocalisation

Browse files
Files changed (5) hide show
  1. app/main.py +28 -4
  2. app/maps.py +27 -0
  3. app/style.py +19 -0
  4. app/top_section.py +1 -0
  5. requirements.txt +2 -1
app/main.py CHANGED
@@ -3,6 +3,8 @@ from functools import partial
3
  from dead import show_section_dead
4
  from wounded import show_section_wounded
5
  from dropdowns import *
 
 
6
 
7
  with gr.Blocks() as demo:
8
  with gr.Row():
@@ -14,6 +16,24 @@ with gr.Blocks() as demo:
14
  with gr.Column(scale=1):
15
  camera = gr.Image()
16
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
17
  with gr.Row() as block_form:
18
  with gr.Column(scale=1):
19
  butt_dead = gr.Button("Dead")
@@ -30,20 +50,24 @@ with gr.Blocks() as demo:
30
  partial_hide_section_wounded = partial(show_section_wounded, False)
31
  butt_dead.click(partial_show_section_dead, inputs=None, outputs=[section_dead,
32
  button_collision, button_deliberate_destruction, button_indirect_destruction, button_natural_cause,
33
- dropdown])
 
34
  butt_dead.click(partial_hide_section_wounded, inputs=None, outputs=[section_wounded,
35
  button_collision, button_deliberate_destruction, button_indirect_destruction, button_natural_cause,
36
- dropdown])
 
37
 
38
  # Wounded Button Logic
39
  partial_show_section_wounded = partial(show_section_wounded, True)
40
  partial_hide_section_dead = partial(show_section_dead, False)
41
  butt_wounded.click(partial_show_section_wounded, inputs=None, outputs=[section_wounded,
42
  button_collision, button_deliberate_destruction, button_indirect_destruction, button_natural_cause,
43
- dropdown])
 
44
  butt_wounded.click(partial_hide_section_dead, inputs=None, outputs=[section_dead,
45
  button_collision, button_deliberate_destruction, button_indirect_destruction, button_natural_cause,
46
- dropdown])
 
47
 
48
  # Dropdowns
49
  button_collision.click(dropdown_collision, outputs=dropdown)
 
3
  from dead import show_section_dead
4
  from wounded import show_section_wounded
5
  from dropdowns import *
6
+ from maps import get_location
7
+ from style import *
8
 
9
  with gr.Blocks() as demo:
10
  with gr.Row():
 
16
  with gr.Column(scale=1):
17
  camera = gr.Image()
18
 
19
+ with gr.Row():
20
+ with gr.Column(scale=1):
21
+ location = gr.Textbox(visible=True, interactive=True, label="Location of Sighting")
22
+ #display location processing
23
+ identified_location= gr.Textbox(visible=False, interactive=False,
24
+ label="Identified GPS Location")
25
+ with gr.Row():
26
+ #to clear it
27
+ clear_location = gr.ClearButton(components=[location], visible=True, interactive=True,
28
+ #elem_classes=["custom-button"]
29
+ )
30
+ clear_location.click()
31
+ #to submit it
32
+ submit_location = gr.Button("Submit", visible=True, interactive=True)
33
+ submit_location.click(get_location, inputs=[location], outputs=[identified_location])
34
+
35
+
36
+
37
  with gr.Row() as block_form:
38
  with gr.Column(scale=1):
39
  butt_dead = gr.Button("Dead")
 
50
  partial_hide_section_wounded = partial(show_section_wounded, False)
51
  butt_dead.click(partial_show_section_dead, inputs=None, outputs=[section_dead,
52
  button_collision, button_deliberate_destruction, button_indirect_destruction, button_natural_cause,
53
+ dropdown
54
+ ])
55
  butt_dead.click(partial_hide_section_wounded, inputs=None, outputs=[section_wounded,
56
  button_collision, button_deliberate_destruction, button_indirect_destruction, button_natural_cause,
57
+ dropdown
58
+ ])
59
 
60
  # Wounded Button Logic
61
  partial_show_section_wounded = partial(show_section_wounded, True)
62
  partial_hide_section_dead = partial(show_section_dead, False)
63
  butt_wounded.click(partial_show_section_wounded, inputs=None, outputs=[section_wounded,
64
  button_collision, button_deliberate_destruction, button_indirect_destruction, button_natural_cause,
65
+ dropdown
66
+ ])
67
  butt_wounded.click(partial_hide_section_dead, inputs=None, outputs=[section_dead,
68
  button_collision, button_deliberate_destruction, button_indirect_destruction, button_natural_cause,
69
+ dropdown
70
+ ])
71
 
72
  # Dropdowns
73
  button_collision.click(dropdown_collision, outputs=dropdown)
app/maps.py ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from geopy.geocoders import Nominatim
2
+ import gradio as gr
3
+
4
+ def get_location(address):
5
+ try:
6
+ # calling the Nominatim tool
7
+ loc = Nominatim(user_agent="GetLoc")
8
+
9
+ # entering the location name
10
+ getLoc = loc.geocode(address)
11
+
12
+ # latitude and longitude
13
+ lat = getLoc.latitude
14
+ lon = getLoc.longitude
15
+ #display location processing
16
+ value = "Latitude = " + str(lat) + "\n" + "Longitude = " + str(lon)
17
+ identified_location= gr.Textbox(visible=True, interactive=False,
18
+ label="Identified GPS Location",
19
+ value=value)
20
+ return identified_location
21
+
22
+ except:
23
+ error = "Please try another less precise location."
24
+ identified_location= gr.Textbox(visible=True, interactive=False,
25
+ label="Identified GPS Location",
26
+ value=error)
27
+ return identified_location
app/style.py ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+
3
+ gr.HTML('''
4
+ <style>
5
+ .custom-button {
6
+ background-color: #4CAF50; /* Green */
7
+ border: none;
8
+ color: white;
9
+ padding: 15px 32px;
10
+ text-align: center;
11
+ text-decoration: none;
12
+ display: inline-block;
13
+ font-size: 16px;
14
+ margin: 4px 2px;
15
+ cursor: pointer;
16
+ border-radius: 8px;
17
+ }
18
+ </style>
19
+ ''')
app/top_section.py CHANGED
@@ -22,6 +22,7 @@ def create_top_section(visible):
22
  return image_row, button_collision, button_deliberate_destruction, button_indirect_destruction, button_natural_cause
23
 
24
  def create_dropdown(visible):
 
25
  with gr.Row() as dropdown_row:
26
  dropdown = gr.Dropdown(choices=[], label="Dropdown", interactive=True, visible=visible)
27
  return dropdown_row, dropdown
 
22
  return image_row, button_collision, button_deliberate_destruction, button_indirect_destruction, button_natural_cause
23
 
24
  def create_dropdown(visible):
25
+ print(visible)
26
  with gr.Row() as dropdown_row:
27
  dropdown = gr.Dropdown(choices=[], label="Dropdown", interactive=True, visible=visible)
28
  return dropdown_row, dropdown
requirements.txt CHANGED
@@ -1 +1,2 @@
1
- gradio
 
 
1
+ gradio
2
+ geopy