File size: 26,734 Bytes
8f0e835
a56673f
ec819d9
86d2f2e
a56673f
 
 
 
 
 
 
 
 
 
 
 
 
8f0e835
baec762
86d2f2e
baec762
951051a
 
 
 
 
 
18350b3
a56673f
baec762
86d2f2e
baec762
a56673f
 
 
 
 
 
923fa20
86d2f2e
 
 
 
 
 
8f0e835
86d2f2e
 
 
 
 
 
a3786fb
86d2f2e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5fd0892
86d2f2e
 
 
 
 
 
 
baec762
86d2f2e
 
 
 
 
 
 
 
 
 
 
5fd0892
86d2f2e
 
 
 
 
 
 
 
 
 
 
 
baec762
86d2f2e
 
 
 
 
 
 
 
 
 
 
5fd0892
8f0e835
86d2f2e
a56673f
86d2f2e
 
 
 
 
 
 
 
ec819d9
86d2f2e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
a56673f
 
86d2f2e
 
ec819d9
86d2f2e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
baec762
a56673f
baec762
a56673f
 
 
 
 
 
 
 
86d2f2e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
ec819d9
86d2f2e
 
 
 
 
 
 
 
 
ec819d9
86d2f2e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
18350b3
86d2f2e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
ec819d9
86d2f2e
 
 
 
 
 
 
 
0de94b5
86d2f2e
 
 
ec819d9
86d2f2e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
18350b3
86d2f2e
 
 
 
 
 
 
18350b3
86d2f2e
ee406aa
86d2f2e
 
 
8f0e835
cfabaca
8f0e835
a56673f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
import gradio as gr
from gradio_modal import Modal

from validation_submission.utils_individual import add_data_to_individual
from validation_submission.validation import reset_error_box
from geolocalisation.maps import get_location
from functools import partial
from dead import show_section_dead
from wounded import show_section_wounded
from circumstances.circumstances import show_circumstances
from circumstances.circumstances_dropdowns import *
from physical.physical_select_animal import show_physical, find_bounding_box
from physical.physical_checkbox import on_select_body_part, hide_physical
from behavior.behavior_checkbox import show_behavior, on_select_behavior
from follow_up.followup_events import save_fe
from styling.style import *
from styling.theme import css

from geolocalisation.js_geolocation import js_geocode, display_location
from validation_submission.utils_individual import generate_random_md5

from datasets import disable_caching
disable_caching()

dataset_id = "SDSC/digiwild-dataset"
data_files = "data/train-00000-of-00001.parquet"

# with gr.Blocks(theme=theme, css=css) as demo:
with gr.Blocks(theme='shivi/calm_seafoam') as demo:
    individual = gr.State({})
    individual.value = add_data_to_individual("image_md5", generate_random_md5(), individual.value)

    # ---------------------------------------------------------
    # Intro Text
    with gr.Row():
        with gr.Column(scale=1):
            title = gr.Markdown("# Welcome to Digiwild", label="Title")
            description = gr.Markdown("Please record your wildlife observations here !", label="description")

    # ---------------------------------------------------------
    # Intro Text
    with gr.Row():
        with gr.Column(scale=1):
            title = gr.Markdown("# Animal Report", label="Title")
            description = gr.Markdown("Please record your observation here.", label="description")

    # ---------------------------------------------------------
    # Camera
    with gr.Row():
        def save_image(camera, individual):
            individual = add_data_to_individual("image", camera.tolist(), individual)
            return individual

        camera = gr.Image(elem_id="image")
        camera.input(save_image, inputs=[camera, individual], outputs=[individual])
    # ---------------------------------------------------------
    # Location
    #with gr.Row():
        with gr.Column(scale=1):
            gr.Markdown("### Location")
            gr.Markdown("#### Location (Using address)")
            location = gr.Textbox(visible=True, interactive=True, label="Location of Sighting")
            #display location processing
            identified_location= gr.Textbox(visible=False, interactive=False, 
                                            label="Identified GPS Location")
            with gr.Row():
                #to submit it
                submit_location = gr.Button("Get Coordinates using address", 
                                            visible=True, interactive=True, scale=3)
                submit_location.click(get_location, inputs=[location, individual], outputs=[identified_location, individual])
                #to clear it
                clear_location = gr.ClearButton(components=[location, identified_location], 
                                                visible=True, interactive=True, scale=1
                                                )
                clear_location.click()

            # Geolocation
            gr.Markdown("#### Location (Using GPS)")
            location_data = gr.JSON(label="Identified GPS Location")
            hidden_input = gr.Textbox(visible=False, elem_id="textbox_id")
            btn_gpslocation = gr.Button("Get Coordinates using GPS (Permission required)")
            btn_gpslocation.click(None, [], [], js=js_geocode)
            hidden_input.change(display_location, inputs=hidden_input, outputs=location_data)

            
            # Introducing text_box for Species
            gr.Markdown("### General details")
            with gr.Row():
                specie = gr.Textbox(
                    label="Species (if known)",
                    placeholder="e.g. European Robin, Common Blackbird",
                    info="Enter the species name if you can identify it. If unsure, provide your best guess or general description (e.g. 'small brown bird')",
                    visible=True,
                    interactive=True
                )

            # Number of individuals
            with gr.Row():
                num_individuals = gr.Number(
                    label="Number of Individuals",
                    value=1,  # Default value
                    minimum=1,
                    precision=0,  # Only whole numbers
                    info="Enter the number of animals observed",
                    #placeholder="Enter number...",
                    visible=True,
                    interactive=True
                )

            # Introducing text_box for comments 
            with gr.Row():
                comments = gr.TextArea(
                    label="Additional Comments",
                    placeholder="Enter any additional observations or notes about the sighting...",
                    info="Optional: Add any relevant details about the animal(s) or circumstances",
                    lines=3,
                    max_lines=5,
                    visible=True,
                    interactive=True
                )

        
    # ---------------------------------------------------------
        # ---------------------------------------------------------
    # Dead and Wounded Buttons
    gr.Markdown("## The State of the Animal", label="Title")
    gr.Markdown("Please tell us if the animal was wounded / sick or dead.", label="description")
    with gr.Row() as block_form:
        with gr.Column(scale=1):
            butt_wounded = gr.Button("Wounded / Sick", elem_id="wounded")
        with gr.Column(scale=1):
            butt_dead = gr.Button("Dead", elem_id="dead")

    # ---------------------------------------------------------
    # Initiate sections
    section_dead, individual, radio_circumstance_dead, radio_physical_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, \
                physical_boxes_dead, \
                checkbox_beak_dead, text_beak_dead, checkbox_body_dead, text_body_dead, checkbox_feathers_dead, text_feathers_dead, checkbox_head_dead, text_head_dead, checkbox_legs_dead, text_legs_dead, \
                fe_collection_dropdown_dead, fe_recepient_dropdown_dead, fe_radio_dropdown_dead, fe_answer_dropdown_dead, \
                fe_name_recipient_dead, fe_collection_ref_dead \
                = show_section_dead(False, individual)
    
    section_wounded, individual, radio_circumstance_wounded, radio_behavior_wounded, radio_physical_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, \
                behavior_checkbox, behavior_text, \
                    physical_boxes_wounded, \
                        checkbox_beak_wounded, text_beak_wounded, checkbox_body_wounded, text_body_wounded, checkbox_feathers_wounded, text_feathers_wounded, checkbox_head_wounded, text_head_wounded, checkbox_legs_wounded, text_legs_wounded, \
                        fe_collection_dropdown_wounded, fe_recepient_dropdown_wounded, fe_radio_dropdown_wounded, fe_answer_dropdown_wounded, \
                            fe_name_recipient_wounded, fe_collection_ref_wounded \
                            = show_section_wounded(False, individual)

    # ---------------------------------------------------------
    # ---------------------------------------------------------
    # ---------------------------------------------------------
    # Dead Button Logic
    partial_show_section_dead = partial(show_section_dead, True)
    partial_hide_section_wounded = partial(show_section_wounded, False)
    butt_dead.click(partial_show_section_dead, 
                    inputs=[individual], 
                    outputs=[section_dead, 
                            individual,
                            radio_circumstance_dead, radio_physical_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, \
                            physical_boxes_dead, \
                            checkbox_beak_dead, text_beak_dead, checkbox_body_dead, text_body_dead, checkbox_feathers_dead, text_feathers_dead, checkbox_head_dead, text_head_dead, checkbox_legs_dead, text_legs_dead, \
                            fe_collection_dropdown_dead, fe_recepient_dropdown_dead, fe_radio_dropdown_dead, fe_answer_dropdown_dead, \
                            fe_name_recipient_dead, fe_collection_ref_dead \
                            ])
    
    butt_dead.click(partial_hide_section_wounded, 
                    inputs=[individual], 
                    outputs=[section_wounded, 
                            individual,
                            radio_circumstance_wounded, radio_behavior_wounded, radio_physical_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,
                            behavior_checkbox, behavior_text, 
                            physical_boxes_wounded, \
                            checkbox_beak_wounded, text_beak_wounded, checkbox_body_wounded, text_body_wounded, checkbox_feathers_wounded, text_feathers_wounded, checkbox_head_wounded, text_head_wounded, checkbox_legs_wounded, text_legs_wounded, \
                            fe_collection_dropdown_wounded, fe_recepient_dropdown_wounded, fe_radio_dropdown_wounded, fe_answer_dropdown_wounded, \
                            fe_name_recipient_wounded, fe_collection_ref_wounded \
                            ])
    
    # ---------------------------------------------------------
    # Wounded Button Logic
    partial_show_section_wounded = partial(show_section_wounded, True)
    partial_hide_section_dead = partial(show_section_dead, False)

    butt_wounded.click(partial_show_section_wounded, 
                    inputs=[individual], 
                    outputs=[section_wounded, 
                            individual,
                            radio_circumstance_wounded, radio_behavior_wounded, radio_physical_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,
                            behavior_checkbox, behavior_text, 
                            physical_boxes_wounded, \
                            checkbox_beak_wounded, text_beak_wounded, checkbox_body_wounded, text_body_wounded, checkbox_feathers_wounded, text_feathers_wounded, checkbox_head_wounded, text_head_wounded, checkbox_legs_wounded, text_legs_wounded, \
                            fe_collection_dropdown_wounded, fe_recepient_dropdown_wounded, fe_radio_dropdown_wounded, fe_answer_dropdown_wounded, \
                            fe_name_recipient_wounded, fe_collection_ref_wounded \
                            ])
    
    butt_wounded.click(partial_hide_section_dead, 
                        inputs=[individual], 
                        outputs=[section_dead, 
                                individual,
                                radio_circumstance_dead, radio_physical_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, \
                                physical_boxes_dead, \
                                checkbox_beak_dead, text_beak_dead, checkbox_body_dead, text_body_dead, checkbox_feathers_dead, text_feathers_dead, checkbox_head_dead, text_head_dead, checkbox_legs_dead, text_legs_dead, \
                                fe_collection_dropdown_dead, fe_recepient_dropdown_dead, fe_radio_dropdown_dead, fe_answer_dropdown_dead, \
                                fe_name_recipient_dead, fe_collection_ref_dead \
                                ])
    
    # ---------------------------------------------------------
    # ---------------------------------------------------------
    # ---------------------------------------------------------
    # ---------------------------------------------------------
    # DEAD
    # ---------------------------------------------------------
    # Radio Circumstance Dead
    radio_circumstance_dead.change(fn=show_circumstances,
                            inputs=[radio_circumstance_dead, individual],
                            outputs=[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, individual]
                            )
    
    # Dropdowns Dead
    button_collision_dead.click(dropdown_collision,
                                inputs=[individual],
                                outputs=[dropdown_dead, dropdown_level2_dead, openfield_level2_dead, dropdown_extra_level2_dead, individual])
    button_deliberate_destruction_dead.click(dropdown_deliberate_destruction, inputs=[individual], outputs=[dropdown_dead, dropdown_level2_dead, openfield_level2_dead, dropdown_extra_level2_dead, individual])
    button_indirect_destruction_dead.click(dropdown_indirect_destruction, inputs=[individual], outputs=[dropdown_dead, dropdown_level2_dead, openfield_level2_dead, dropdown_extra_level2_dead, individual])
    button_natural_cause_dead.click(dropdown_natural_cause, inputs=[individual], outputs=[dropdown_dead, dropdown_level2_dead, openfield_level2_dead, dropdown_extra_level2_dead, individual])

    dropdown_dead.select(on_select, inputs=[individual], outputs=[dropdown_level2_dead, openfield_level2_dead, dropdown_extra_level2_dead, individual])
    dropdown_level2_dead.select(on_select_dropdown_level2, inputs=[individual], outputs=[individual] )
    openfield_level2_dead.change(on_change_openfield_level2, inputs=[openfield_level2_dead, individual], outputs=[individual])
    dropdown_extra_level2_dead.select(on_select_dropdown_extra_level2, inputs=[individual], outputs=[individual])
    # ---------------------------------------------------------
    # Radio Physical Dead
    radio_physical_dead.change(fn=show_physical,
                                inputs=[radio_physical_dead, gr.Text("dead", visible=False), individual],
                                outputs=[physical_boxes_dead, individual])

    # Checkbox Physical Dead
    physical_boxes_dead.select(find_bounding_box, 
                    inputs=[physical_boxes_dead, gr.Textbox(value="dead", visible=False)], 
                    outputs=[checkbox_beak_dead, text_beak_dead, 
                                checkbox_body_dead, text_body_dead, 
                                checkbox_feathers_dead, text_feathers_dead, 
                                checkbox_head_dead, text_head_dead, 
                                checkbox_legs_dead, text_legs_dead
                                ])
    checkbox_beak_dead.select(on_select_body_part, inputs=[checkbox_beak_dead, gr.Text("beak", visible=False), individual], outputs=[individual])
    checkbox_body_dead.select(on_select_body_part, inputs=[checkbox_body_dead, gr.Text("body", visible=False), individual], outputs=[individual])
    checkbox_feathers_dead.select(on_select_body_part, inputs=[checkbox_feathers_dead, gr.Text("feathers", visible=False), individual], outputs=[individual])
    checkbox_head_dead.select(on_select_body_part, inputs=[checkbox_head_dead, gr.Text("head", visible=False), individual], outputs=[individual])
    checkbox_legs_dead.select(on_select_body_part, inputs=[checkbox_legs_dead, gr.Text("legs", visible=False), individual], outputs=[individual])
    # ---------------------------------------------------------
    # ---------------------------------------------------------
    # ---------------------------------------------------------
    # ---------------------------------------------------------
    # WOUNDED
    # ---------------------------------------------------------
    # Radio Circumstance Wounded
    radio_circumstance_wounded.change(fn=show_circumstances,
                            inputs=[radio_circumstance_wounded, individual],
                            outputs=[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, individual]
                            )
    
    # Dropdowns Circumstance Wounded
    button_collision_wounded.click(dropdown_collision,
                                inputs=[individual],  
                                outputs=[dropdown_wounded, dropdown_level2_wounded, openfield_level2_wounded, dropdown_extra_level2_wounded, individual])
    button_deliberate_destruction_wounded.click(dropdown_deliberate_destruction, inputs=[individual], outputs=[dropdown_wounded, dropdown_level2_wounded, openfield_level2_wounded, dropdown_extra_level2_wounded, individual])
    button_indirect_destruction_wounded.click(dropdown_indirect_destruction, inputs=[individual], outputs=[dropdown_wounded, dropdown_level2_wounded, openfield_level2_wounded, dropdown_extra_level2_wounded, individual])
    button_natural_cause_wounded.click(dropdown_natural_cause, inputs=[individual], outputs=[dropdown_wounded, dropdown_level2_wounded, openfield_level2_wounded, dropdown_extra_level2_wounded, individual])
    
    dropdown_wounded.select(on_select, inputs=[individual], outputs=[dropdown_level2_wounded, openfield_level2_wounded, dropdown_extra_level2_wounded, individual])
    dropdown_level2_wounded.select(on_select_dropdown_level2, inputs=[individual], outputs=[individual])
    openfield_level2_wounded.change(on_change_openfield_level2, inputs=[openfield_level2_wounded, individual])
    dropdown_extra_level2_wounded.select(on_select_dropdown_extra_level2, inputs=[individual], outputs=[individual])
    # ---------------------------------------------------------
    # Radio Behavior Wounded
    radio_behavior_wounded.change(fn=show_behavior,
                                inputs=[radio_behavior_wounded, gr.Text("wounded / sick", visible=False), individual],
                                outputs=[behavior_checkbox, behavior_text, individual])
    behavior_checkbox.select(on_select_behavior, 
                                inputs=[behavior_checkbox, individual],
                                outputs=[individual])
    # ---------------------------------------------------------
    # Radio Physical Wounded
    radio_physical_wounded.change(fn=show_physical,
                                inputs=[radio_physical_wounded, gr.Text("wounded / sick", visible=False), individual],
                                outputs=[physical_boxes_wounded, individual])

    # Checkbox Physical Wounded
    physical_boxes_wounded.select(find_bounding_box, 
                    inputs=[physical_boxes_wounded, gr.Textbox(value="wounded / sick", visible=False)], 
                    outputs=[checkbox_beak_wounded, text_beak_wounded, 
                                checkbox_body_wounded, text_body_wounded, 
                                checkbox_feathers_wounded, text_feathers_wounded, 
                                checkbox_head_wounded, text_head_wounded, 
                                checkbox_legs_wounded, text_legs_wounded
                                ])
    checkbox_beak_wounded.select(on_select_body_part, inputs=[checkbox_beak_wounded, gr.Text("beak", visible=False), individual], outputs=[individual])
    checkbox_body_wounded.select(on_select_body_part, inputs=[checkbox_body_wounded, gr.Text("body", visible=False), individual], outputs=[individual])
    checkbox_feathers_wounded.select(on_select_body_part, inputs=[checkbox_feathers_wounded, gr.Text("feathers", visible=False), individual], outputs=[individual])
    checkbox_head_wounded.select(on_select_body_part, inputs=[checkbox_head_wounded, gr.Text("head", visible=False), individual], outputs=[individual])
    checkbox_legs_wounded.select(on_select_body_part, inputs=[checkbox_legs_wounded, gr.Text("legs", visible=False), individual], outputs=[individual])
    
    # ---------------------------------------------------------
    # Follow Up Events Wounded 
    fe_collection_dropdown_wounded.select(save_fe, inputs=[fe_collection_dropdown_wounded, gr.Textbox("animal collected", visible=False), individual], outputs=[individual])
    fe_recepient_dropdown_wounded.select(save_fe, inputs=[fe_recepient_dropdown_wounded, gr.Textbox("recipient", visible=False), individual],outputs=[individual])
    fe_radio_dropdown_wounded.select(save_fe, inputs=[fe_radio_dropdown_wounded, gr.Textbox("radiography", visible=False), individual],outputs=[individual]) 
    fe_answer_dropdown_wounded.select(save_fe, inputs=[fe_answer_dropdown_wounded, gr.Textbox("given answer", visible=False), individual],outputs=[individual])
    fe_name_recipient_wounded.input(save_fe, inputs=[fe_name_recipient_wounded, gr.Textbox("recipient name", visible=False), individual],outputs=[individual])
    fe_collection_ref_wounded.input(save_fe, inputs=[fe_collection_ref_wounded, gr.Textbox("collection reference", visible=False), individual],outputs=[individual])

    # ---------------------------------------------------------
    # Follow Up Events Dead 
    fe_collection_dropdown_dead.select(save_fe, inputs=[fe_collection_dropdown_dead, gr.Textbox("animal collected", visible=False), individual],outputs=[individual])
    fe_recepient_dropdown_dead.select(save_fe, inputs=[fe_recepient_dropdown_dead, gr.Textbox("recipient", visible=False), individual],outputs=[individual])
    fe_radio_dropdown_dead.select(save_fe, inputs=[fe_radio_dropdown_dead, gr.Textbox("radiography", visible=False), individual],outputs=[individual]) 
    fe_answer_dropdown_dead.select(save_fe, inputs=[fe_answer_dropdown_dead, gr.Textbox("given answer", visible=False), individual],outputs=[individual])
    fe_name_recipient_dead.input(save_fe, inputs=[fe_name_recipient_dead, gr.Textbox("recipient name", visible=False), individual],outputs=[individual])
    fe_collection_ref_dead.input(save_fe, inputs=[fe_collection_ref_dead, gr.Textbox("collection reference", visible=False), individual], outputs=[individual])

    # ---------------------------------------------------------
    # Error Box
    error_box = gr.Text(value=None, visible=False)

    # ---------------------------------------------------------
    # Allow clearing of all previous output
    with gr.Row(): 
        button_df = gr.Button("Submit Animal Report", scale = 3)
        button_clear = gr.ClearButton(scale = 1, 
                                        components=[
            camera,
            location, identified_location, 
            #dead reset
            radio_circumstance_dead, radio_physical_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,
            physical_boxes_dead,
            checkbox_beak_dead, text_beak_dead, checkbox_body_dead, text_body_dead, checkbox_feathers_dead, text_feathers_dead, checkbox_head_dead, text_head_dead, checkbox_legs_dead, text_legs_dead, 
            fe_collection_dropdown_dead, fe_recepient_dropdown_dead, fe_radio_dropdown_dead, fe_answer_dropdown_dead, 
            fe_name_recipient_dead, fe_collection_ref_dead,
            #wounded reset
            radio_circumstance_wounded, radio_behavior_wounded, radio_physical_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,
            behavior_checkbox, behavior_text, 
            physical_boxes_wounded, 
            checkbox_beak_wounded, text_beak_wounded, checkbox_body_wounded, text_body_wounded, checkbox_feathers_wounded, text_feathers_wounded, checkbox_head_wounded, text_head_wounded, checkbox_legs_wounded, text_legs_wounded,
            fe_collection_dropdown_wounded, fe_recepient_dropdown_wounded, fe_radio_dropdown_wounded, fe_answer_dropdown_wounded, 
            fe_name_recipient_wounded, fe_collection_ref_wounded,
            error_box
            ])

    # ---------------------------------------------------------
    # Button Click Logic
    button_clear.click()
    button_clear.click(hide_physical,
                        outputs=[checkbox_beak_wounded, text_beak_wounded, checkbox_body_wounded, text_body_wounded, checkbox_feathers_wounded, text_feathers_wounded, checkbox_head_wounded, text_head_wounded, checkbox_legs_wounded, text_legs_wounded])
    button_clear.click(hide_physical,
                        outputs=[checkbox_beak_dead, text_beak_dead, checkbox_body_dead, text_body_dead, checkbox_feathers_dead, text_feathers_dead, checkbox_head_dead, text_head_dead, checkbox_legs_dead, text_legs_dead])
            
    button_clear.click(reset_error_box, inputs=[error_box], outputs=[error_box])
    
    from validation_submission.submission import validate_save_individual
    button_df.click(validate_save_individual, inputs=[individual, error_box],
                    outputs=[error_box])


if __name__ == "__main__":
    demo.launch(server_name="0.0.0.0", server_port=7860)