feat: use json config for first level of death/wound cause
Browse files- app/assets/dropdowns/dropdown_config.json +130 -0
- app/assets/dropdowns/submit_config.json +23 -0
- app/dropdowns.py +28 -23
- app/main.py +21 -15
app/assets/dropdowns/dropdown_config.json
ADDED
@@ -0,0 +1,130 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"Collision with a means of transport":
|
3 |
+
{
|
4 |
+
"road vehicle":
|
5 |
+
{
|
6 |
+
"road type": {"Options" : ["highway", "main road", "secondary road", "local road/path/trail", "parking lot", "other", "unknown"]},
|
7 |
+
"infrastructure number": "Open"
|
8 |
+
},
|
9 |
+
"train":
|
10 |
+
{
|
11 |
+
"infrastructure number": "Open"
|
12 |
+
},
|
13 |
+
"aircraft": {},
|
14 |
+
"boat": {},
|
15 |
+
"other": {},
|
16 |
+
"unknown": {}
|
17 |
+
},
|
18 |
+
"Destruction / Deliberatly removed" :
|
19 |
+
{
|
20 |
+
"hunting":
|
21 |
+
{
|
22 |
+
"Options": ["shooting", "bow", "falconry", "hounds hunting", "digging up", "other", "unknown"]
|
23 |
+
},
|
24 |
+
"trap":
|
25 |
+
{
|
26 |
+
"Options": ["killing trap", "pole trap", "trap cage", "corvids nasse", "net", "cage trap", "fall-trap", "glue trap", "insect trap", "other", "unknown"]
|
27 |
+
},
|
28 |
+
"poisoning": {},
|
29 |
+
"removal or direct capture":
|
30 |
+
{
|
31 |
+
"Options": ["gassing", "raptor captured at nest", "brood destruction", "traffic/trade", "capture accident", "scientific sample", "other", "unknown"]
|
32 |
+
},
|
33 |
+
"fishing":
|
34 |
+
{
|
35 |
+
"Options": ["drowned/tangled", "beached with capture indications", "other", "unknown"]
|
36 |
+
},
|
37 |
+
"other": {},
|
38 |
+
"unknown": {}
|
39 |
+
},
|
40 |
+
"Indirect destruction":
|
41 |
+
{
|
42 |
+
"pylone and electric grid":
|
43 |
+
{
|
44 |
+
"object":
|
45 |
+
{
|
46 |
+
"Options": ["electric line", "pole/pylon", "other", "unknown"]
|
47 |
+
},
|
48 |
+
"cause":
|
49 |
+
{
|
50 |
+
"Options": ["collision", "electrocution", "unknown"]
|
51 |
+
}
|
52 |
+
},
|
53 |
+
"windfarm": {},
|
54 |
+
"other collision":
|
55 |
+
{
|
56 |
+
"Object":
|
57 |
+
{
|
58 |
+
"Options": ["window", "building", "lighthouse", "cable", "wire fence/barbed wire", "other crash", "unknown"]
|
59 |
+
}
|
60 |
+
},
|
61 |
+
"fall":
|
62 |
+
{
|
63 |
+
"Object":
|
64 |
+
{
|
65 |
+
"Options": ["chimney", "empty pole", "hole/well", "other", "unknown"]
|
66 |
+
}
|
67 |
+
},
|
68 |
+
"development work":
|
69 |
+
{
|
70 |
+
"Type":
|
71 |
+
{
|
72 |
+
"Options": ["transport infrastructure", "building", "other", "unknown"]
|
73 |
+
}
|
74 |
+
},
|
75 |
+
"pollution / contamination":
|
76 |
+
{
|
77 |
+
"Type":
|
78 |
+
{
|
79 |
+
"Options": ["oil pollution", "chemical pollution", "heavy metals", "light", "noise", "plastic ingestion", "other", "unknown"]
|
80 |
+
}
|
81 |
+
},
|
82 |
+
"agricultural net protection": {},
|
83 |
+
"vegetal / forest work":
|
84 |
+
{
|
85 |
+
"Type":
|
86 |
+
{
|
87 |
+
"Options": ["clearing/mowing/plowing", "tree felling/pruning", "other", "unknown"]
|
88 |
+
}
|
89 |
+
},
|
90 |
+
"other": {},
|
91 |
+
"unknown": {}
|
92 |
+
},
|
93 |
+
"Natural cause":
|
94 |
+
{
|
95 |
+
"predation":
|
96 |
+
{
|
97 |
+
"responsible":
|
98 |
+
{
|
99 |
+
"Options": ["cat", "dog", "rooster/hen", "other domestic animal", "wild birds", "wild mammal", "other", "unknown"]
|
100 |
+
}
|
101 |
+
},
|
102 |
+
"weather":
|
103 |
+
{
|
104 |
+
"Type":
|
105 |
+
{
|
106 |
+
"Options": ["cold wave", "drought", "hail", "lightening", "storm", "other", "unknown"]
|
107 |
+
}
|
108 |
+
},
|
109 |
+
"natural disaster":
|
110 |
+
{
|
111 |
+
"Type":
|
112 |
+
{
|
113 |
+
"Options": ["fire", "avalanche", "rock fall", "mudslide", "volcanic eruption/ashes", "other", "unknown"]
|
114 |
+
}
|
115 |
+
},
|
116 |
+
"nest fall": {},
|
117 |
+
"strading due to exhaustion": {},
|
118 |
+
"disease/parasite": {},
|
119 |
+
"accidental drowing":
|
120 |
+
{
|
121 |
+
"Container":
|
122 |
+
{
|
123 |
+
"Options": ["drinking trough", "pool", "storm pool", "irrigation pool", "natural pool", "flood", "other container", "unknown"]
|
124 |
+
}
|
125 |
+
},
|
126 |
+
"other": {},
|
127 |
+
"unknown": {}
|
128 |
+
},
|
129 |
+
"Unknown": {}
|
130 |
+
}
|
app/assets/dropdowns/submit_config.json
ADDED
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"Event follow-up":
|
3 |
+
{
|
4 |
+
"Animal collected": {
|
5 |
+
"Options": ["Yes", "No"]
|
6 |
+
},
|
7 |
+
"Recipient": {
|
8 |
+
"Options": ["Veterinary", "Care center", "Local Museum", "National Museum", "Other"]
|
9 |
+
},
|
10 |
+
"Radiography": {
|
11 |
+
"Options": ["Yes", "No", "Unknown"]
|
12 |
+
},
|
13 |
+
"Given answer": {
|
14 |
+
"Options": ["Nothing", "Complaint against X", "Complaint", "Police call", "Discussion with the speaker", "Press release", "Unknown"]
|
15 |
+
},
|
16 |
+
"Name of recipient / museum": {
|
17 |
+
"Open": {}
|
18 |
+
},
|
19 |
+
"Collection reference": {
|
20 |
+
"Open": {}
|
21 |
+
}
|
22 |
+
}
|
23 |
+
}
|
app/dropdowns.py
CHANGED
@@ -1,32 +1,37 @@
|
|
1 |
import gradio as gr
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
|
3 |
def dropdown_collision():
|
4 |
-
|
|
|
|
|
5 |
|
6 |
def dropdown_deliberate_destruction():
|
7 |
-
|
|
|
|
|
8 |
|
9 |
def dropdown_indirect_destruction():
|
10 |
-
|
11 |
-
|
12 |
-
|
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 |
-
|
24 |
-
|
25 |
-
|
26 |
-
"nest fall",
|
27 |
-
"stranding due to exhaustion",
|
28 |
-
"disease/parasite",
|
29 |
-
"accidental drowning",
|
30 |
-
"other",
|
31 |
-
"unknown"
|
32 |
-
], label="Indirect destruction", interactive=True)
|
|
|
1 |
import gradio as gr
|
2 |
+
import json
|
3 |
+
import os
|
4 |
+
|
5 |
+
def load_config(file_path):
|
6 |
+
with open(file_path) as f:
|
7 |
+
config = json.load(f)
|
8 |
+
return config
|
9 |
+
|
10 |
+
def retrieve_config_options(label):
|
11 |
+
path = os.getcwd()
|
12 |
+
dropdown_config_path = path + "/assets/dropdowns/dropdown_config.json"
|
13 |
+
dropdown_config = load_config(dropdown_config_path)
|
14 |
+
options = list(dropdown_config[label].keys())
|
15 |
+
options = [option.title() for option in options]
|
16 |
+
return options
|
17 |
+
|
18 |
|
19 |
def dropdown_collision():
|
20 |
+
label = "Collision with a means of transport"
|
21 |
+
options = retrieve_config_options(label)
|
22 |
+
return gr.Dropdown(choices=options, label=label, interactive=True)
|
23 |
|
24 |
def dropdown_deliberate_destruction():
|
25 |
+
label = "Destruction / Deliberatly removed"
|
26 |
+
options = retrieve_config_options(label)
|
27 |
+
return gr.Dropdown(choices=options, label=label, interactive=True)
|
28 |
|
29 |
def dropdown_indirect_destruction():
|
30 |
+
label = "Indirect destruction"
|
31 |
+
options = retrieve_config_options(label)
|
32 |
+
return gr.Dropdown(choices=options, label=label, interactive=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
33 |
|
34 |
def dropdown_natural_cause():
|
35 |
+
label = "Natural cause"
|
36 |
+
options = retrieve_config_options(label)
|
37 |
+
return gr.Dropdown(choices=options, label=label, interactive=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/main.py
CHANGED
@@ -42,38 +42,44 @@ with gr.Blocks() as demo:
|
|
42 |
butt_wounded = gr.Button("Wounded")
|
43 |
|
44 |
# Initiate sections
|
45 |
-
section_dead,
|
46 |
-
section_wounded,
|
47 |
|
48 |
# Dead Button Logic
|
49 |
partial_show_section_dead = partial(show_section_dead, True)
|
50 |
partial_hide_section_wounded = partial(show_section_wounded, False)
|
51 |
butt_dead.click(partial_show_section_dead, inputs=None, outputs=[section_dead,
|
52 |
-
|
53 |
-
|
54 |
])
|
55 |
butt_dead.click(partial_hide_section_wounded, inputs=None, outputs=[section_wounded,
|
56 |
-
|
57 |
-
|
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 |
-
|
65 |
-
|
66 |
])
|
67 |
butt_wounded.click(partial_hide_section_dead, inputs=None, outputs=[section_dead,
|
68 |
-
|
69 |
-
|
70 |
])
|
71 |
|
72 |
-
# Dropdowns
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
77 |
|
78 |
|
79 |
with gr.Column(scale=1):
|
|
|
42 |
butt_wounded = gr.Button("Wounded")
|
43 |
|
44 |
# Initiate sections
|
45 |
+
section_dead, button_collision_dead, button_deliberate_destruction_dead, button_indirect_destruction_dead, button_natural_cause_dead, dropdown_dead = show_section_dead(False)
|
46 |
+
section_wounded, button_collision_wounded, button_deliberate_destruction_wounded, button_indirect_destruction_wounded, button_natural_cause_wounded, dropdown_wounded = show_section_wounded(False)
|
47 |
|
48 |
# Dead Button Logic
|
49 |
partial_show_section_dead = partial(show_section_dead, True)
|
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_dead, button_deliberate_destruction_dead, button_indirect_destruction_dead, button_natural_cause_dead,
|
53 |
+
dropdown_dead
|
54 |
])
|
55 |
butt_dead.click(partial_hide_section_wounded, inputs=None, outputs=[section_wounded,
|
56 |
+
button_collision_wounded, button_deliberate_destruction_wounded, button_indirect_destruction_wounded, button_natural_cause_wounded,
|
57 |
+
dropdown_wounded
|
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_wounded, button_deliberate_destruction_wounded, button_indirect_destruction_wounded, button_natural_cause_wounded,
|
65 |
+
dropdown_wounded
|
66 |
])
|
67 |
butt_wounded.click(partial_hide_section_dead, inputs=None, outputs=[section_dead,
|
68 |
+
button_collision_dead, button_deliberate_destruction_dead, button_indirect_destruction_dead, button_natural_cause_dead,
|
69 |
+
dropdown_dead
|
70 |
])
|
71 |
|
72 |
+
# Dropdowns Dead
|
73 |
+
button_collision_dead.click(dropdown_collision, outputs=dropdown_dead)
|
74 |
+
button_deliberate_destruction_dead.click(dropdown_deliberate_destruction, outputs=dropdown_dead)
|
75 |
+
button_indirect_destruction_dead.click(dropdown_indirect_destruction, outputs=dropdown_dead)
|
76 |
+
button_natural_cause_dead.click(dropdown_natural_cause, outputs=dropdown_dead)
|
77 |
+
|
78 |
+
# Dropdwons Wounded
|
79 |
+
button_collision_wounded.click(dropdown_collision, outputs=dropdown_wounded)
|
80 |
+
button_deliberate_destruction_wounded.click(dropdown_deliberate_destruction, outputs=dropdown_wounded)
|
81 |
+
button_indirect_destruction_wounded.click(dropdown_indirect_destruction, outputs=dropdown_wounded)
|
82 |
+
button_natural_cause_wounded.click(dropdown_natural_cause, outputs=dropdown_wounded)
|
83 |
|
84 |
|
85 |
with gr.Column(scale=1):
|