feat: select bird integrated into app
Browse files- app/main.py +5 -2
- app/select_bird.py +6 -12
- app/wounded.py +5 -2
app/main.py
CHANGED
@@ -6,7 +6,7 @@ from dropdowns import *
|
|
6 |
from maps import get_location
|
7 |
from style import *
|
8 |
from theme import theme, css
|
9 |
-
from
|
10 |
|
11 |
with gr.Blocks(theme=theme, css=css) as demo:
|
12 |
# ---------------------------------------------------------
|
@@ -117,7 +117,7 @@ with gr.Blocks(theme=theme, css=css) as demo:
|
|
117 |
# ---------------------------------------------------------
|
118 |
# Initiate sections
|
119 |
section_dead, button_collision_dead, button_deliberate_destruction_dead, button_indirect_destruction_dead, button_natural_cause_dead, dropdown_dead, dropdown_level2_dead, openfield_level2_dead, dropdown_extra_level2_dead = show_section_dead(False)
|
120 |
-
section_wounded, button_collision_wounded, button_deliberate_destruction_wounded, button_indirect_destruction_wounded, button_natural_cause_wounded, dropdown_wounded, dropdown_level2_wounded, openfield_level2_wounded, dropdown_extra_level2_wounded= show_section_wounded(False)
|
121 |
|
122 |
# ---------------------------------------------------------
|
123 |
# Dead Button Logic
|
@@ -143,6 +143,9 @@ with gr.Blocks(theme=theme, css=css) as demo:
|
|
143 |
button_collision_dead, button_deliberate_destruction_dead, button_indirect_destruction_dead, button_natural_cause_dead,
|
144 |
dropdown_dead, dropdown_level2_dead, openfield_level2_dead, dropdown_extra_level2_dead
|
145 |
])
|
|
|
|
|
|
|
146 |
# ---------------------------------------------------------
|
147 |
# Dropdowns Dead
|
148 |
button_collision_dead.click(dropdown_collision,
|
|
|
6 |
from maps import get_location
|
7 |
from style import *
|
8 |
from theme import theme, css
|
9 |
+
from select_bird import find_bounding_box
|
10 |
|
11 |
with gr.Blocks(theme=theme, css=css) as demo:
|
12 |
# ---------------------------------------------------------
|
|
|
117 |
# ---------------------------------------------------------
|
118 |
# Initiate sections
|
119 |
section_dead, button_collision_dead, button_deliberate_destruction_dead, button_indirect_destruction_dead, button_natural_cause_dead, dropdown_dead, dropdown_level2_dead, openfield_level2_dead, dropdown_extra_level2_dead = show_section_dead(False)
|
120 |
+
section_wounded, button_collision_wounded, button_deliberate_destruction_wounded, button_indirect_destruction_wounded, button_natural_cause_wounded, dropdown_wounded, dropdown_level2_wounded, openfield_level2_wounded, dropdown_extra_level2_wounded, img_with_boxes, matched_box= show_section_wounded(False)
|
121 |
|
122 |
# ---------------------------------------------------------
|
123 |
# Dead Button Logic
|
|
|
143 |
button_collision_dead, button_deliberate_destruction_dead, button_indirect_destruction_dead, button_natural_cause_dead,
|
144 |
dropdown_dead, dropdown_level2_dead, openfield_level2_dead, dropdown_extra_level2_dead
|
145 |
])
|
146 |
+
img_with_boxes.select(find_bounding_box,
|
147 |
+
inputs=[img_with_boxes],
|
148 |
+
outputs=[matched_box])
|
149 |
# ---------------------------------------------------------
|
150 |
# Dropdowns Dead
|
151 |
button_collision_dead.click(dropdown_collision,
|
app/select_bird.py
CHANGED
@@ -10,28 +10,22 @@ def find_bounding_box(evt: gr.SelectData, img):
|
|
10 |
x, y = evt.index[0], evt.index[1]
|
11 |
point = Point(x, y)
|
12 |
match = gdf[gdf.contains(point)]
|
13 |
-
|
14 |
if not match.empty:
|
15 |
matched_box = match.iloc[0]['name']
|
16 |
else:
|
17 |
matched_box = "No bounding box found"
|
18 |
return matched_box
|
19 |
|
20 |
-
|
21 |
# Gradio app
|
22 |
-
|
23 |
# Draw bounding boxes on the image
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
|
|
28 |
|
29 |
-
img_with_boxes.select(find_bounding_box,
|
30 |
-
inputs=[img_with_boxes],
|
31 |
-
outputs=[bbox_label])
|
32 |
|
33 |
|
34 |
-
|
35 |
-
demo.launch(server_name="0.0.0.0")
|
36 |
|
37 |
|
|
|
10 |
x, y = evt.index[0], evt.index[1]
|
11 |
point = Point(x, y)
|
12 |
match = gdf[gdf.contains(point)]
|
|
|
13 |
if not match.empty:
|
14 |
matched_box = match.iloc[0]['name']
|
15 |
else:
|
16 |
matched_box = "No bounding box found"
|
17 |
return matched_box
|
18 |
|
|
|
19 |
# Gradio app
|
20 |
+
def create_bird_anatomy():
|
21 |
# Draw bounding boxes on the image
|
22 |
+
img_with_boxes = gr.Image(value='assets/images/bird_boxed.png',
|
23 |
+
show_label=False,
|
24 |
+
height="600px")
|
25 |
+
matched_box = gr.Textbox(label="Selected box")
|
26 |
+
return img_with_boxes, matched_box
|
27 |
|
|
|
|
|
|
|
28 |
|
29 |
|
|
|
|
|
30 |
|
31 |
|
app/wounded.py
CHANGED
@@ -1,6 +1,7 @@
|
|
1 |
import gradio as gr
|
2 |
from top_section import create_top_section, create_dropdown
|
3 |
from followup_events import create_followup_section
|
|
|
4 |
|
5 |
def show_section_wounded(visible):
|
6 |
with gr.Column(visible=visible, elem_id="wounded") as wounded_section:
|
@@ -9,8 +10,10 @@ def show_section_wounded(visible):
|
|
9 |
|
10 |
image_row, button_collision, button_deliberate_destruction, button_indirect_destruction, button_natural_cause = create_top_section(visible)
|
11 |
dropdown_row, dropdown, dropdown_level2, openfield_level2, dropdown_extra_level2 = create_dropdown(visible)
|
12 |
-
|
|
|
|
|
13 |
create_followup_section()
|
14 |
|
15 |
# Change variables and names
|
16 |
-
return wounded_section, button_collision, button_deliberate_destruction, button_indirect_destruction, button_natural_cause, dropdown, dropdown_level2, openfield_level2, dropdown_extra_level2
|
|
|
1 |
import gradio as gr
|
2 |
from top_section import create_top_section, create_dropdown
|
3 |
from followup_events import create_followup_section
|
4 |
+
from select_bird import create_bird_anatomy
|
5 |
|
6 |
def show_section_wounded(visible):
|
7 |
with gr.Column(visible=visible, elem_id="wounded") as wounded_section:
|
|
|
10 |
|
11 |
image_row, button_collision, button_deliberate_destruction, button_indirect_destruction, button_natural_cause = create_top_section(visible)
|
12 |
dropdown_row, dropdown, dropdown_level2, openfield_level2, dropdown_extra_level2 = create_dropdown(visible)
|
13 |
+
|
14 |
+
img_with_boxes, matched_box = create_bird_anatomy()
|
15 |
+
|
16 |
create_followup_section()
|
17 |
|
18 |
# Change variables and names
|
19 |
+
return wounded_section, button_collision, button_deliberate_destruction, button_indirect_destruction, button_natural_cause, dropdown, dropdown_level2, openfield_level2, dropdown_extra_level2, img_with_boxes, matched_box
|