feat: all dropdowns for dead and wounded
Browse files- app/__init__.py +0 -0
- app/dead.py +12 -0
- app/dropdowns.py +32 -0
- app/main.py +24 -79
- app/top_section.py +30 -0
- app/wounded.py +13 -0
app/__init__.py
ADDED
File without changes
|
app/dead.py
ADDED
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from top_section import create_top_section, create_dropdown
|
3 |
+
|
4 |
+
def show_section_dead(visible):
|
5 |
+
with gr.Column(visible=visible) as section_dead:
|
6 |
+
gr.Markdown("# Dead")
|
7 |
+
gr.Markdown("Please describe the cause of death")
|
8 |
+
|
9 |
+
image_row, button_collision, button_deliberate_destruction, button_indirect_destruction, button_natural_cause = create_top_section(visible)
|
10 |
+
dropdown_row, dropdown = create_dropdown(visible)
|
11 |
+
|
12 |
+
return section_dead, button_collision, button_deliberate_destruction, button_indirect_destruction, button_natural_cause, dropdown
|
app/dropdowns.py
ADDED
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
|
3 |
+
def dropdown_collision():
|
4 |
+
return gr.Dropdown(choices=["Road vehicle", "Train", "Aircraft", "Boat", "Other", "Unknown"], label="Collision with a means of transport", interactive=True)
|
5 |
+
|
6 |
+
def dropdown_deliberate_destruction():
|
7 |
+
return gr.Dropdown(choices=["Hunting", "Trap", "Poisoning", "Removal or direct capture", "Fishing", "Other", "Unkown"], label="Destruction / Deliberatly removed", interactive=True)
|
8 |
+
|
9 |
+
def dropdown_indirect_destruction():
|
10 |
+
return gr.Dropdown(choices=["pylone and electric grid",
|
11 |
+
"windfarm",
|
12 |
+
"other collision",
|
13 |
+
"fall",
|
14 |
+
"development work",
|
15 |
+
"pollution / contamination",
|
16 |
+
"agricultural net protection",
|
17 |
+
"vegetal / forest work",
|
18 |
+
"other",
|
19 |
+
"unknown"
|
20 |
+
], label="Indirect destruction", interactive=True)
|
21 |
+
|
22 |
+
def dropdown_natural_cause():
|
23 |
+
return gr.Dropdown(choices=["predation",
|
24 |
+
"weather",
|
25 |
+
"natural disaster",
|
26 |
+
"nest fall",
|
27 |
+
"stranding due to exhaustion",
|
28 |
+
"disease/parasite",
|
29 |
+
"accidental drowning",
|
30 |
+
"other",
|
31 |
+
"unknown"
|
32 |
+
], label="Indirect destruction", interactive=True)
|
app/main.py
CHANGED
@@ -1,74 +1,8 @@
|
|
1 |
import gradio as gr
|
2 |
from functools import partial
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
def truckb_dropdown():
|
8 |
-
return gr.Dropdown(choices=["Hunting", "Trap", "Poisoning", "Removal or direct capture", "Fishing", "Other", "Unkown"], label="Destruction / Deliberatly removed", interactive=True)
|
9 |
-
|
10 |
-
def show_section_dead(visible):
|
11 |
-
with gr.Column(visible=visible) as section_dead:
|
12 |
-
gr.Markdown("# Dead")
|
13 |
-
gr.Markdown("Please describe the cause of death")
|
14 |
-
with gr.Row():
|
15 |
-
with gr.Column(scale=1, min_width="100px"):
|
16 |
-
img1 = gr.Image(value='./assets/van.png', show_download_button=False, show_label=False)
|
17 |
-
butt1 = gr.Button("Collision with a means of transport", visible=visible)
|
18 |
-
|
19 |
-
with gr.Column(scale=1, min_width="100px"):
|
20 |
-
img1 = gr.Image(value='./assets/destruction.png', show_download_button=False, show_label=False)
|
21 |
-
butt2 = gr.Button("Destruction / Deliberatly removed", visible=visible)
|
22 |
-
|
23 |
-
|
24 |
-
with gr.Row():
|
25 |
-
with gr.Column(scale=1, min_width="100px"):
|
26 |
-
img3 = gr.Image(value='./assets/indirect.png', show_download_button=False, show_label=False)
|
27 |
-
butt3 = gr.Button("Indirect destruction", visible=visible)
|
28 |
-
|
29 |
-
with gr.Column(scale=1, min_width="100px"):
|
30 |
-
img4 = gr.Image(value='./assets/natural.png', show_download_button=False, show_label=False)
|
31 |
-
butt4 = gr.Button("Natural cause", visible=visible)
|
32 |
-
|
33 |
-
|
34 |
-
with gr.Row():
|
35 |
-
dropdown = gr.Dropdown(choices=[], label="Dropdown", interactive=True, visible=visible)
|
36 |
-
|
37 |
-
return section_dead, butt1, butt2, butt3, butt4, dropdown
|
38 |
-
|
39 |
-
def show_section_wounded(visible):
|
40 |
-
#with gr.Tab("Wounded Information"):
|
41 |
-
with gr.Column(visible=visible) as wounded_section:
|
42 |
-
gr.Markdown("# Please describe the cause of wound")
|
43 |
-
|
44 |
-
with gr.Row():
|
45 |
-
with gr.Column(scale=1, min_width="100px"):
|
46 |
-
img1 = gr.Image(value='./assets/van.png', show_download_button=False, show_label=False)
|
47 |
-
butt1 = gr.Button("Collision with a means of transport")
|
48 |
-
|
49 |
-
with gr.Column(scale=1, min_width="100px"):
|
50 |
-
img1 = gr.Image(value='./assets/destruction.png', show_download_button=False, show_label=False)
|
51 |
-
butt2 = gr.Button("Destruction / Deliberatly removed")
|
52 |
-
|
53 |
-
with gr.Row():
|
54 |
-
with gr.Column(scale=1, min_width="100px"):
|
55 |
-
img3 = gr.Image(value='./assets/indirect.png', show_download_button=False, show_label=False)
|
56 |
-
butt3 = gr.Button("Indirect destruction")
|
57 |
-
|
58 |
-
with gr.Column(scale=1, min_width="100px"):
|
59 |
-
img4 = gr.Image(value='./assets/natural.png', show_download_button=False, show_label=False)
|
60 |
-
butt4 = gr.Button("Natural cause")
|
61 |
-
|
62 |
-
|
63 |
-
with gr.Row():
|
64 |
-
dropdown = gr.Dropdown(choices=[], label="Dropdown", interactive=True)
|
65 |
-
|
66 |
-
# Change variables and names
|
67 |
-
return wounded_section
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
|
73 |
with gr.Blocks() as demo:
|
74 |
with gr.Row():
|
@@ -88,24 +22,35 @@ with gr.Blocks() as demo:
|
|
88 |
butt_wounded = gr.Button("Wounded")
|
89 |
|
90 |
# Initiate sections
|
91 |
-
section_dead,
|
92 |
-
section_wounded = show_section_wounded(False)
|
93 |
|
94 |
# Dead Button Logic
|
95 |
partial_show_section_dead = partial(show_section_dead, True)
|
96 |
partial_hide_section_wounded = partial(show_section_wounded, False)
|
97 |
-
butt_dead.click(partial_show_section_dead, inputs=None, outputs=[section_dead,
|
98 |
-
|
|
|
|
|
|
|
|
|
99 |
|
100 |
# Wounded Button Logic
|
101 |
partial_show_section_wounded = partial(show_section_wounded, True)
|
102 |
partial_hide_section_dead = partial(show_section_dead, False)
|
103 |
-
butt_wounded.click(partial_show_section_wounded, inputs=None, outputs=section_wounded
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
109 |
|
110 |
with gr.Column(scale=1):
|
111 |
subbutt = gr.Button("Submit")
|
|
|
1 |
import gradio as gr
|
2 |
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():
|
|
|
22 |
butt_wounded = gr.Button("Wounded")
|
23 |
|
24 |
# Initiate sections
|
25 |
+
section_dead, button_collision, button_deliberate_destruction, button_indirect_destruction, button_natural_cause, dropdown = show_section_dead(False)
|
26 |
+
section_wounded, button_collision, button_deliberate_destruction, button_indirect_destruction, button_natural_cause, dropdown = show_section_wounded(False)
|
27 |
|
28 |
# Dead Button Logic
|
29 |
partial_show_section_dead = partial(show_section_dead, True)
|
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)
|
50 |
+
button_deliberate_destruction.click(dropdown_deliberate_destruction, outputs=dropdown)
|
51 |
+
button_indirect_destruction.click(dropdown_indirect_destruction, outputs=dropdown)
|
52 |
+
button_natural_cause.click(dropdown_natural_cause, outputs=dropdown)
|
53 |
+
|
54 |
|
55 |
with gr.Column(scale=1):
|
56 |
subbutt = gr.Button("Submit")
|
app/top_section.py
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
|
3 |
+
def create_top_section(visible):
|
4 |
+
with gr.Row() as image_row:
|
5 |
+
with gr.Column(scale=1, min_width="50px"):
|
6 |
+
img1 = gr.Image(value='app/assets/van.png', show_download_button=False, show_label=False)
|
7 |
+
button_collision = gr.Button("Collision with a means of transport", visible=visible)
|
8 |
+
|
9 |
+
with gr.Column(scale=1, min_width="50px"):
|
10 |
+
img2 = gr.Image(value='app/assets/destruction.png', show_download_button=False, show_label=False)
|
11 |
+
button_deliberate_destruction = gr.Button("Destruction / Deliberatly removed", visible=visible)
|
12 |
+
|
13 |
+
|
14 |
+
#with gr.Row():
|
15 |
+
with gr.Column(scale=1, min_width="50px"):
|
16 |
+
img3 = gr.Image(value='app/assets/indirect.png', show_download_button=False, show_label=False)
|
17 |
+
button_indirect_destruction = gr.Button("Indirect destruction", visible=visible)
|
18 |
+
|
19 |
+
with gr.Column(scale=1, min_width="50px"):
|
20 |
+
img4 = gr.Image(value='app/assets/natural.png', show_download_button=False, show_label=False)
|
21 |
+
button_natural_cause = gr.Button("Natural cause", visible=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
|
28 |
+
|
29 |
+
|
30 |
+
|
app/wounded.py
ADDED
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from top_section import create_top_section, create_dropdown
|
3 |
+
|
4 |
+
def show_section_wounded(visible):
|
5 |
+
#with gr.Tab("Wounded Information"):
|
6 |
+
with gr.Column(visible=visible) as wounded_section:
|
7 |
+
gr.Markdown("# Please describe the cause of wound")
|
8 |
+
|
9 |
+
image_row, button_collision, button_deliberate_destruction, button_indirect_destruction, button_natural_cause = create_top_section(visible)
|
10 |
+
dropdown_row, dropdown = create_dropdown(visible)
|
11 |
+
|
12 |
+
# Change variables and names
|
13 |
+
return wounded_section, button_collision, button_deliberate_destruction, button_indirect_destruction, button_natural_cause, dropdown
|