feat: behaviour checkboxes for wounded section
Browse files- app/assets/config/config_checkbox_behavior.json +42 -0
- app/behavior_checkbox.py +23 -0
- app/main.py +16 -6
- app/physical_checkbox.py +31 -38
- app/utils_checkbox.py +18 -0
- app/utils_config.py +1 -0
- app/wounded.py +4 -0
app/assets/config/config_checkbox_behavior.json
ADDED
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"Abnormal breating":
|
3 |
+
{
|
4 |
+
"Description": "Problems breathing, breathing sounds"
|
5 |
+
},
|
6 |
+
"Crash, Falling from the sky":
|
7 |
+
{
|
8 |
+
"Description": "Suddenly falling from the sky"
|
9 |
+
},
|
10 |
+
"Diarrhea":
|
11 |
+
{
|
12 |
+
"Description": "Observed diarrhea"
|
13 |
+
},
|
14 |
+
"Lameness":
|
15 |
+
{
|
16 |
+
"Description": "Apparent limping or not able to walk properly"
|
17 |
+
},
|
18 |
+
"Neurological":
|
19 |
+
{
|
20 |
+
"Description": "Circling, incoordination, tremors, convulsions, fast eye movements"
|
21 |
+
},
|
22 |
+
"Other abnormal behavior":
|
23 |
+
{
|
24 |
+
"Description": "Other than weakness, other than neurologic"
|
25 |
+
},
|
26 |
+
"Unable to fly":
|
27 |
+
{
|
28 |
+
"Description": "Animal alert and tries to fly but can not take off"
|
29 |
+
},
|
30 |
+
"Vomiting":
|
31 |
+
{
|
32 |
+
"Description": "Throwing up undigested food, regurgitating"
|
33 |
+
},
|
34 |
+
"Weakness":
|
35 |
+
{
|
36 |
+
"Description": "Non responsive, does not fly away when approached, lethargy"
|
37 |
+
},
|
38 |
+
"No changes":
|
39 |
+
{
|
40 |
+
"Description": "Animal is acting normally"
|
41 |
+
}
|
42 |
+
}
|
app/behavior_checkbox.py
ADDED
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from utils_config import get_custom_config_dropdowns
|
2 |
+
from utils_checkbox import create_checkbox
|
3 |
+
from utils_visible import set_visible
|
4 |
+
|
5 |
+
def retrieve_behavior_options_description():
|
6 |
+
dropdown_config = get_custom_config_dropdowns("/assets/config/config_checkbox_behavior.json")
|
7 |
+
options = list(dropdown_config.keys())
|
8 |
+
options = [option.title() for option in options]
|
9 |
+
descriptions =[]
|
10 |
+
for _,subdict in dropdown_config.items():
|
11 |
+
descriptions.append(subdict["Description"])
|
12 |
+
return options, descriptions
|
13 |
+
|
14 |
+
def create_behavior_checkbox(section: str, visible):
|
15 |
+
options, descriptions = retrieve_behavior_options_description()
|
16 |
+
label_checkbox = "Behavior changes observed"
|
17 |
+
checkbox, text = create_checkbox("", section, label_checkbox, visible, options, descriptions)
|
18 |
+
return checkbox, text
|
19 |
+
|
20 |
+
def show_behavior(choice, section: str):
|
21 |
+
visible = set_visible(choice)
|
22 |
+
checkbox, text = create_behavior_checkbox(section, visible)
|
23 |
+
return checkbox, text
|
app/main.py
CHANGED
@@ -5,6 +5,7 @@ from wounded import show_section_wounded
|
|
5 |
from circumstances import show_causes
|
6 |
from circumstances_dropdowns import *
|
7 |
from physical_select_animal import show_physical, find_bounding_box
|
|
|
8 |
from maps import get_location
|
9 |
from style import *
|
10 |
from theme import theme, css
|
@@ -56,11 +57,12 @@ with gr.Blocks(theme=theme, css=css) as demo:
|
|
56 |
button_collision_dead, button_deliberate_destruction_dead, button_indirect_destruction_dead, button_natural_cause_dead, \
|
57 |
dropdown_dead, dropdown_level2_dead, openfield_level2_dead, dropdown_extra_level2_dead \
|
58 |
= show_section_dead(False)
|
59 |
-
section_wounded, radio_cause_wounded,
|
60 |
button_collision_wounded, button_deliberate_destruction_wounded, button_indirect_destruction_wounded, button_natural_cause_wounded, \
|
61 |
dropdown_wounded, dropdown_level2_wounded, openfield_level2_wounded, dropdown_extra_level2_wounded, \
|
62 |
-
|
63 |
-
|
|
|
64 |
= show_section_wounded(False)
|
65 |
|
66 |
# ---------------------------------------------------------
|
@@ -76,9 +78,10 @@ with gr.Blocks(theme=theme, css=css) as demo:
|
|
76 |
butt_dead.click(partial_hide_section_wounded,
|
77 |
inputs=None,
|
78 |
outputs=[section_wounded,
|
79 |
-
radio_cause_wounded,
|
80 |
button_collision_wounded, button_deliberate_destruction_wounded, button_indirect_destruction_wounded, button_natural_cause_wounded,
|
81 |
dropdown_wounded, dropdown_level2_wounded, openfield_level2_wounded, dropdown_extra_level2_wounded,
|
|
|
82 |
physical_boxes_wounded,
|
83 |
checkbox_beak, text_beak, checkbox_body, text_body, checkbox_feathers, text_feathers, checkbox_head, text_head, checkbox_legs, text_legs
|
84 |
|
@@ -91,9 +94,10 @@ with gr.Blocks(theme=theme, css=css) as demo:
|
|
91 |
butt_wounded.click(partial_show_section_wounded,
|
92 |
inputs=None,
|
93 |
outputs=[section_wounded,
|
94 |
-
radio_cause_wounded,
|
95 |
button_collision_wounded, button_deliberate_destruction_wounded, button_indirect_destruction_wounded, button_natural_cause_wounded,
|
96 |
dropdown_wounded, dropdown_level2_wounded, openfield_level2_wounded, dropdown_extra_level2_wounded,
|
|
|
97 |
physical_boxes_wounded,
|
98 |
checkbox_beak, text_beak, checkbox_body, text_body, checkbox_feathers, text_feathers, checkbox_head, text_head, checkbox_legs, text_legs
|
99 |
])
|
@@ -128,12 +132,18 @@ with gr.Blocks(theme=theme, css=css) as demo:
|
|
128 |
|
129 |
dropdown_wounded.select(on_select, None, [dropdown_level2_wounded, openfield_level2_wounded, dropdown_extra_level2_wounded])
|
130 |
|
|
|
|
|
|
|
|
|
|
|
|
|
131 |
# ---------------------------------------------------------
|
132 |
# Radio Physical Wounded
|
133 |
radio_physical_wounded.change(fn=show_physical,
|
134 |
inputs=[radio_physical_wounded, gr.Text("wounded", visible=False)],
|
135 |
outputs=[physical_boxes_wounded])
|
136 |
-
|
137 |
# Checkbox Physical Wounded
|
138 |
physical_boxes_wounded.select(find_bounding_box,
|
139 |
inputs=[physical_boxes_wounded, gr.Textbox(value="wounded", visible=False)],
|
|
|
5 |
from circumstances import show_causes
|
6 |
from circumstances_dropdowns import *
|
7 |
from physical_select_animal import show_physical, find_bounding_box
|
8 |
+
from behavior_checkbox import show_behavior
|
9 |
from maps import get_location
|
10 |
from style import *
|
11 |
from theme import theme, css
|
|
|
57 |
button_collision_dead, button_deliberate_destruction_dead, button_indirect_destruction_dead, button_natural_cause_dead, \
|
58 |
dropdown_dead, dropdown_level2_dead, openfield_level2_dead, dropdown_extra_level2_dead \
|
59 |
= show_section_dead(False)
|
60 |
+
section_wounded, radio_cause_wounded, radio_behavior_wounded, radio_physical_wounded, \
|
61 |
button_collision_wounded, button_deliberate_destruction_wounded, button_indirect_destruction_wounded, button_natural_cause_wounded, \
|
62 |
dropdown_wounded, dropdown_level2_wounded, openfield_level2_wounded, dropdown_extra_level2_wounded, \
|
63 |
+
behavior_checkbox, behavior_text, \
|
64 |
+
physical_boxes_wounded, \
|
65 |
+
checkbox_beak, text_beak, checkbox_body, text_body, checkbox_feathers, text_feathers, checkbox_head, text_head, checkbox_legs, text_legs \
|
66 |
= show_section_wounded(False)
|
67 |
|
68 |
# ---------------------------------------------------------
|
|
|
78 |
butt_dead.click(partial_hide_section_wounded,
|
79 |
inputs=None,
|
80 |
outputs=[section_wounded,
|
81 |
+
radio_cause_wounded, radio_behavior_wounded, radio_physical_wounded,
|
82 |
button_collision_wounded, button_deliberate_destruction_wounded, button_indirect_destruction_wounded, button_natural_cause_wounded,
|
83 |
dropdown_wounded, dropdown_level2_wounded, openfield_level2_wounded, dropdown_extra_level2_wounded,
|
84 |
+
behavior_checkbox, behavior_text,
|
85 |
physical_boxes_wounded,
|
86 |
checkbox_beak, text_beak, checkbox_body, text_body, checkbox_feathers, text_feathers, checkbox_head, text_head, checkbox_legs, text_legs
|
87 |
|
|
|
94 |
butt_wounded.click(partial_show_section_wounded,
|
95 |
inputs=None,
|
96 |
outputs=[section_wounded,
|
97 |
+
radio_cause_wounded, radio_behavior_wounded, radio_physical_wounded,
|
98 |
button_collision_wounded, button_deliberate_destruction_wounded, button_indirect_destruction_wounded, button_natural_cause_wounded,
|
99 |
dropdown_wounded, dropdown_level2_wounded, openfield_level2_wounded, dropdown_extra_level2_wounded,
|
100 |
+
behavior_checkbox, behavior_text,
|
101 |
physical_boxes_wounded,
|
102 |
checkbox_beak, text_beak, checkbox_body, text_body, checkbox_feathers, text_feathers, checkbox_head, text_head, checkbox_legs, text_legs
|
103 |
])
|
|
|
132 |
|
133 |
dropdown_wounded.select(on_select, None, [dropdown_level2_wounded, openfield_level2_wounded, dropdown_extra_level2_wounded])
|
134 |
|
135 |
+
# ---------------------------------------------------------
|
136 |
+
# Radio Behavior Wounded
|
137 |
+
radio_behavior_wounded.change(fn=show_behavior,
|
138 |
+
inputs=[radio_behavior_wounded, gr.Text("wounded", visible=False)],
|
139 |
+
outputs=[behavior_checkbox, behavior_text])
|
140 |
+
|
141 |
# ---------------------------------------------------------
|
142 |
# Radio Physical Wounded
|
143 |
radio_physical_wounded.change(fn=show_physical,
|
144 |
inputs=[radio_physical_wounded, gr.Text("wounded", visible=False)],
|
145 |
outputs=[physical_boxes_wounded])
|
146 |
+
|
147 |
# Checkbox Physical Wounded
|
148 |
physical_boxes_wounded.select(find_bounding_box,
|
149 |
inputs=[physical_boxes_wounded, gr.Textbox(value="wounded", visible=False)],
|
app/physical_checkbox.py
CHANGED
@@ -1,19 +1,23 @@
|
|
1 |
import gradio as gr
|
2 |
from utils_config import get_custom_config_dropdowns
|
3 |
-
from
|
4 |
-
|
5 |
#---------------------------------------------------------
|
6 |
def get_body_parts():
|
7 |
dropdown_config = get_custom_config_dropdowns("/assets/config/config_checkbox_physical.json")
|
8 |
return list(dropdown_config.keys())
|
9 |
|
10 |
-
|
|
|
|
|
|
|
|
|
11 |
def get_options_description(value):
|
12 |
dropdown_config = get_custom_config_dropdowns("/assets/config/config_checkbox_physical.json")
|
13 |
# get options
|
14 |
-
|
15 |
options_for_value = retrieve_config_options(value, dropdown_config)
|
16 |
-
|
|
|
17 |
# get descriptions
|
18 |
descriptions = []
|
19 |
for key, sub_dict in dropdown_config.items():
|
@@ -24,55 +28,44 @@ def get_options_description(value):
|
|
24 |
descriptions.append(description)
|
25 |
return options, descriptions
|
26 |
|
27 |
-
#---------------------------------------------------------
|
28 |
-
def
|
29 |
-
options, descriptions = get_options_description(body_part)
|
30 |
-
descriptions_info = "".join([f"\t{option}: {description}\n" for option, description in zip(options, descriptions)])
|
31 |
-
checkbox = gr.CheckboxGroup(options,
|
32 |
-
label=f"Physical changes observed on {body_part}:",
|
33 |
-
visible=visible,
|
34 |
-
interactive=True,
|
35 |
-
elem_id=section)
|
36 |
-
text = gr.Textbox(descriptions_info,
|
37 |
-
label = "Info",
|
38 |
-
visible=visible,
|
39 |
-
interactive=False,
|
40 |
-
lines=13,
|
41 |
-
max_lines=15,
|
42 |
-
elem_id=section)
|
43 |
-
return checkbox, text
|
44 |
-
|
45 |
-
def create_checkbox_beak(section, visible):
|
46 |
body_part="Beak"
|
47 |
-
|
|
|
48 |
|
49 |
-
def create_checkbox_body(section, visible):
|
50 |
body_part="Body"
|
51 |
-
|
|
|
52 |
|
53 |
-
def create_checkbox_feathers(section, visible):
|
54 |
body_part="Feathers/Wings/Tail"
|
55 |
-
|
|
|
56 |
|
57 |
-
def create_checkbox_head(section, visible):
|
58 |
body_part="Head incl. eyes"
|
59 |
-
|
|
|
60 |
|
61 |
-
def create_checkbox_legs(section, visible):
|
62 |
body_part="Legs"
|
63 |
-
|
|
|
64 |
|
65 |
#---------------------------------------------------------
|
66 |
def process_body_parts(section, matched_box):
|
67 |
#take all except "Common"
|
68 |
body_parts = get_body_parts()
|
69 |
body_parts = body_parts[1:]
|
|
|
70 |
visibles = [True if matched_box==body_part else False for body_part in body_parts ]
|
71 |
-
checkbox_beak, text_beak = create_checkbox_beak(section, visibles[0])
|
72 |
-
checkbox_body, text_body = create_checkbox_body(section, visibles[1])
|
73 |
-
checkbox_feathers, text_feathers = create_checkbox_feathers(section, visibles[2])
|
74 |
-
checkbox_head, text_head = create_checkbox_head(section, visibles[3])
|
75 |
-
checkbox_legs, text_legs = create_checkbox_legs(section, visibles[4])
|
76 |
return checkbox_beak, text_beak, checkbox_body, text_body, checkbox_feathers, text_feathers, checkbox_head, text_head, checkbox_legs, text_legs
|
77 |
|
78 |
|
|
|
1 |
import gradio as gr
|
2 |
from utils_config import get_custom_config_dropdowns
|
3 |
+
from utils_checkbox import create_checkbox
|
|
|
4 |
#---------------------------------------------------------
|
5 |
def get_body_parts():
|
6 |
dropdown_config = get_custom_config_dropdowns("/assets/config/config_checkbox_physical.json")
|
7 |
return list(dropdown_config.keys())
|
8 |
|
9 |
+
def retrieve_config_options(label, dropdown_config):
|
10 |
+
options = list(dropdown_config[label].keys())
|
11 |
+
options = [option.title() for option in options]
|
12 |
+
return options
|
13 |
+
|
14 |
def get_options_description(value):
|
15 |
dropdown_config = get_custom_config_dropdowns("/assets/config/config_checkbox_physical.json")
|
16 |
# get options
|
17 |
+
options_common = retrieve_config_options("Common", dropdown_config)
|
18 |
options_for_value = retrieve_config_options(value, dropdown_config)
|
19 |
+
options_common.extend(options_for_value)
|
20 |
+
options = options_common
|
21 |
# get descriptions
|
22 |
descriptions = []
|
23 |
for key, sub_dict in dropdown_config.items():
|
|
|
28 |
descriptions.append(description)
|
29 |
return options, descriptions
|
30 |
|
31 |
+
#---------------------------------------------------------
|
32 |
+
def create_checkbox_beak(section, label_checkbox, visible):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
33 |
body_part="Beak"
|
34 |
+
options, descriptions = get_options_description(body_part)
|
35 |
+
return create_checkbox(body_part, section, label_checkbox, visible, options, descriptions)
|
36 |
|
37 |
+
def create_checkbox_body(section, label_checkbox, visible):
|
38 |
body_part="Body"
|
39 |
+
options, descriptions = get_options_description(body_part)
|
40 |
+
return create_checkbox(body_part, section, label_checkbox, visible, options, descriptions)
|
41 |
|
42 |
+
def create_checkbox_feathers(section, label_checkbox, visible):
|
43 |
body_part="Feathers/Wings/Tail"
|
44 |
+
options, descriptions = get_options_description(body_part)
|
45 |
+
return create_checkbox(body_part, section, label_checkbox, visible, options, descriptions)
|
46 |
|
47 |
+
def create_checkbox_head(section, label_checkbox, visible):
|
48 |
body_part="Head incl. eyes"
|
49 |
+
options, descriptions = get_options_description(body_part)
|
50 |
+
return create_checkbox(body_part, section, label_checkbox, visible, options, descriptions)
|
51 |
|
52 |
+
def create_checkbox_legs(section, label_checkbox, visible):
|
53 |
body_part="Legs"
|
54 |
+
options, descriptions = get_options_description(body_part)
|
55 |
+
return create_checkbox(body_part, section, label_checkbox, visible, options, descriptions)
|
56 |
|
57 |
#---------------------------------------------------------
|
58 |
def process_body_parts(section, matched_box):
|
59 |
#take all except "Common"
|
60 |
body_parts = get_body_parts()
|
61 |
body_parts = body_parts[1:]
|
62 |
+
label_checkbox = "Physical changes to "
|
63 |
visibles = [True if matched_box==body_part else False for body_part in body_parts ]
|
64 |
+
checkbox_beak, text_beak = create_checkbox_beak(section, label_checkbox, visibles[0])
|
65 |
+
checkbox_body, text_body = create_checkbox_body(section, label_checkbox, visibles[1])
|
66 |
+
checkbox_feathers, text_feathers = create_checkbox_feathers(section, label_checkbox, visibles[2])
|
67 |
+
checkbox_head, text_head = create_checkbox_head(section, label_checkbox, visibles[3])
|
68 |
+
checkbox_legs, text_legs = create_checkbox_legs(section, label_checkbox, visibles[4])
|
69 |
return checkbox_beak, text_beak, checkbox_body, text_body, checkbox_feathers, text_feathers, checkbox_head, text_head, checkbox_legs, text_legs
|
70 |
|
71 |
|
app/utils_checkbox.py
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
|
3 |
+
#---------------------------------------------------------
|
4 |
+
def create_checkbox(value, section, label_checkbox, visible, options, descriptions):
|
5 |
+
descriptions_info = "".join([f"\t{option}: {description}\n" for option, description in zip(options, descriptions)])
|
6 |
+
checkbox = gr.CheckboxGroup(options,
|
7 |
+
label=label_checkbox + f" {value}:",
|
8 |
+
visible=visible,
|
9 |
+
interactive=True,
|
10 |
+
elem_id=section)
|
11 |
+
text = gr.Textbox(descriptions_info,
|
12 |
+
label = "Info",
|
13 |
+
visible=visible,
|
14 |
+
interactive=False,
|
15 |
+
lines=13,
|
16 |
+
max_lines=15,
|
17 |
+
elem_id=section)
|
18 |
+
return checkbox, text
|
app/utils_config.py
CHANGED
@@ -12,3 +12,4 @@ def get_custom_config_dropdowns(config_path):
|
|
12 |
dropdown_config = load_config(dropdown_config_path)
|
13 |
return dropdown_config
|
14 |
|
|
|
|
12 |
dropdown_config = load_config(dropdown_config_path)
|
13 |
return dropdown_config
|
14 |
|
15 |
+
|
app/wounded.py
CHANGED
@@ -2,6 +2,7 @@ import gradio as gr
|
|
2 |
from circumstances import create_causes
|
3 |
from physical_select_animal import create_bird_anatomy
|
4 |
from physical_checkbox import process_body_parts
|
|
|
5 |
from followup_events import create_followup_section
|
6 |
|
7 |
def show_section_wounded(visible):
|
@@ -14,6 +15,8 @@ def show_section_wounded(visible):
|
|
14 |
|
15 |
gr.Markdown("## Is the bird displaying behavioural changes?" , label="description")
|
16 |
radio_behaviour = gr.Radio(["Yes", "No"], value=None, show_label=False, interactive=True)
|
|
|
|
|
17 |
|
18 |
gr.Markdown("## Are there physical changes on the bird?" , label="description")
|
19 |
radio_physical = gr.Radio(["Yes", "No"], value=None, show_label=False, interactive=True)
|
@@ -30,5 +33,6 @@ def show_section_wounded(visible):
|
|
30 |
return wounded_section, radio_cause, radio_behaviour, radio_physical, \
|
31 |
button_collision, button_deliberate_destruction, button_indirect_destruction, button_natural_cause, \
|
32 |
dropdown, dropdown_level2, openfield_level2, dropdown_extra_level2, \
|
|
|
33 |
physical_boxes, \
|
34 |
checkbox_beak, text_beak, checkbox_body, text_body, checkbox_feathers, text_feathers, checkbox_head, text_head, checkbox_legs, text_legs
|
|
|
2 |
from circumstances import create_causes
|
3 |
from physical_select_animal import create_bird_anatomy
|
4 |
from physical_checkbox import process_body_parts
|
5 |
+
from behavior_checkbox import create_behavior_checkbox
|
6 |
from followup_events import create_followup_section
|
7 |
|
8 |
def show_section_wounded(visible):
|
|
|
15 |
|
16 |
gr.Markdown("## Is the bird displaying behavioural changes?" , label="description")
|
17 |
radio_behaviour = gr.Radio(["Yes", "No"], value=None, show_label=False, interactive=True)
|
18 |
+
with gr.Row():
|
19 |
+
behavior_checkbox, behavior_text = create_behavior_checkbox("wounded", False)
|
20 |
|
21 |
gr.Markdown("## Are there physical changes on the bird?" , label="description")
|
22 |
radio_physical = gr.Radio(["Yes", "No"], value=None, show_label=False, interactive=True)
|
|
|
33 |
return wounded_section, radio_cause, radio_behaviour, radio_physical, \
|
34 |
button_collision, button_deliberate_destruction, button_indirect_destruction, button_natural_cause, \
|
35 |
dropdown, dropdown_level2, openfield_level2, dropdown_extra_level2, \
|
36 |
+
behavior_checkbox, behavior_text, \
|
37 |
physical_boxes, \
|
38 |
checkbox_beak, text_beak, checkbox_body, text_body, checkbox_feathers, text_feathers, checkbox_head, text_head, checkbox_legs, text_legs
|