vancauwe commited on
Commit
869adb6
·
1 Parent(s): b87ee04

feat: simple physical and behavior definitions

Browse files
app/assets/config/config_checkbox_behavior_simple.json ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "General weakness":
3
+ {
4
+ "Description": "Abnormal breathing (dyspnoea), sudden crash, apathy, lethargy, unable to fly but responsive."
5
+ },
6
+ "Vomiting":
7
+ {
8
+ "Description": "Throwing up undigested food, regurgitating"
9
+ },
10
+ "Atypical behavior":
11
+ {
12
+ "Description": "Circling, incoordination, tremors, convulsions"
13
+ },
14
+ "No changes":
15
+ {
16
+ "Description": "Animal is acting normally"
17
+ }
18
+ }
app/assets/config/config_checkbox_physical_simple.json ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "Common":
3
+ {
4
+ "Abnormal position": {
5
+ "Description": "Hanging wing, tilted head, lameness"},
6
+ "Injury": {
7
+ "Description": "Visible blood, fracture, missing limb, swelling without visible injury, foreign body"}
8
+ },
9
+ "Beak":
10
+ {
11
+ "Adhesion/Discharge": {
12
+ "Description": "Material (food, saliva) around/ in the beak, discharge from ears/ eyes/ beak/ nose"
13
+ }
14
+ },
15
+ "Body":
16
+ {},
17
+ "Feathers/Wings/Tail":
18
+ {
19
+ "Feathers and skin change": {
20
+ "Description": "Blackened/ burnt skin or feathers, deformed feathers, ear changes (swollen, crusts, plugged, discharge), discolored/ missing/ broken/ stained feathers, fluffed up plumage, warts/ crusts/ tumor-like growth, parasites"}
21
+ },
22
+ "Head incl. eyes":
23
+ {
24
+ "Eye changes": {
25
+ "Description": "Swollen, reddened, closed, discharge, crusts"}
26
+ },
27
+ "Legs":
28
+ {}
29
+
30
+ }
app/behavior/behavior_checkbox.py CHANGED
@@ -9,8 +9,12 @@ def on_select_behavior(behavior_checkbox, individual):
9
  individual = add_data_to_individual("behaviors_type", behavior_checkbox, individual)
10
  return individual
11
 
12
- def retrieve_behavior_options_description():
13
- dropdown_config = get_custom_config_dropdowns("config_checkbox_behavior.json")
 
 
 
 
14
  options = list(dropdown_config.keys())
15
  options = [option.title() for option in options]
16
  descriptions =[]
@@ -18,14 +22,15 @@ def retrieve_behavior_options_description():
18
  descriptions.append(subdict["Description"])
19
  return options, descriptions
20
 
21
- def create_behavior_checkbox(section: str, visible):
22
- options, descriptions = retrieve_behavior_options_description()
23
  label_checkbox = "Behavior changes observed"
24
  checkbox, text = create_checkbox("", section, label_checkbox, visible, options, descriptions)
25
  return checkbox, text
26
 
27
- def show_behavior(choice, section: str, individual):
 
28
  visible = set_visible(choice)
29
- checkbox, text = create_behavior_checkbox(section, visible)
30
  individual = add_data_to_individual("behaviors_radio", choice, individual)
31
  return checkbox, text, individual
 
9
  individual = add_data_to_individual("behaviors_type", behavior_checkbox, individual)
10
  return individual
11
 
12
+ def retrieve_behavior_options_description(mode:str):
13
+ print(mode)
14
+ if mode =="simple":
15
+ dropdown_config = get_custom_config_dropdowns("config_checkbox_behavior_simple.json")
16
+ elif mode=="advanced":
17
+ dropdown_config = get_custom_config_dropdowns("config_checkbox_behavior.json")
18
  options = list(dropdown_config.keys())
19
  options = [option.title() for option in options]
20
  descriptions =[]
 
22
  descriptions.append(subdict["Description"])
23
  return options, descriptions
24
 
25
+ def create_behavior_checkbox(section: str, mode: str, visible):
26
+ options, descriptions = retrieve_behavior_options_description(mode)
27
  label_checkbox = "Behavior changes observed"
28
  checkbox, text = create_checkbox("", section, label_checkbox, visible, options, descriptions)
29
  return checkbox, text
30
 
31
+ def show_behavior(choice, section: str, mode: str, individual):
32
+ print(mode)
33
  visible = set_visible(choice)
34
+ checkbox, text = create_behavior_checkbox(section, mode, visible)
35
  individual = add_data_to_individual("behaviors_radio", choice, individual)
36
  return checkbox, text, individual
app/behavior/class_behavior_simple.py ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from pydantic import BaseModel, Field
2
+ from typing import Literal, List, Union, Optional
3
+
4
+ class BehaviorSimple(BaseModel):
5
+ type: str
6
+ description: Optional[str] = None # Making the description field optional
7
+
8
+ # --- Specific BehaviorSimple classes ---
9
+ class GeneralWeakness(BehaviorSimple):
10
+ type: Literal['general weakness']
11
+ description: Optional[Literal["Abnormal breathing (dyspnoea), sudden crash, apathy, lethargy, unable to fly but responsive"]] = None
12
+
13
+ class Vomiting(BehaviorSimple):
14
+ type: Literal['vomiting']
15
+ description: Optional[Literal["Throwing up undigested food, regurgitating"]] = None
16
+
17
+ class AtypicalBehavior(BehaviorSimple):
18
+ type: Literal['atypical behavior']
19
+ description: Optional[Literal["Circling, incoordination, tremors, convulsions"]] = None
20
+
21
+ class NoChanges(BehaviorSimple):
22
+ type: Literal['no changes']
23
+ description: Optional[Literal["Animal is acting normally"]] = None
24
+
25
+ # Union of all possible behaviors
26
+ BehaviorSimpleType = Union[
27
+ GeneralWeakness,
28
+ Vomiting,
29
+ AtypicalBehavior,
30
+ NoChanges
31
+ ]
32
+
33
+ # Main class that logs multiple behaviors
34
+ class BehaviorsSimple(BaseModel):
35
+ behaviors_radio: str # e.g., "Yes"
36
+ behaviors_type: Optional[List[BehaviorSimpleType]] = None
app/circumstances/circumstances.py CHANGED
@@ -15,7 +15,7 @@ CAUSE_COL_WIDTH = "50px"
15
 
16
  def show_circumstances(choice, individual):
17
  visible = set_visible(choice)
18
- individual = add_data_to_individual("wounded_dead",
19
  "circumstance_radio",
20
  choice, individual)
21
  button_collision, button_deliberate_destruction, button_indirect_destruction, button_natural_cause, dropdown, dropdown_level2, openfield_level2, dropdown_extra_level2 = create_circumstances(visible)
 
15
 
16
  def show_circumstances(choice, individual):
17
  visible = set_visible(choice)
18
+ individual = add_data_to_individual(
19
  "circumstance_radio",
20
  choice, individual)
21
  button_collision, button_deliberate_destruction, button_indirect_destruction, button_natural_cause, dropdown, dropdown_level2, openfield_level2, dropdown_extra_level2 = create_circumstances(visible)
app/circumstances/circumstances_dropdowns.py CHANGED
@@ -23,22 +23,22 @@ def create_dropdown_level1(label, individual):
23
 
24
  def dropdown_collision(individual):
25
  label = "Collision with a means of transport"
26
- individual = add_data_to_individual("wounded_dead", "circumstance", label.lower(), individual)
27
  return create_dropdown_level1(label, individual)
28
 
29
  def dropdown_deliberate_destruction(individual):
30
  label = "Destruction / Deliberatly removed"
31
- individual = add_data_to_individual("wounded_dead", "circumstance", label.lower(), individual)
32
  return create_dropdown_level1(label, individual)
33
 
34
  def dropdown_indirect_destruction(individual):
35
  label = "Indirect destruction"
36
- individual = add_data_to_individual("wounded_dead", "circumstance", label.lower(), individual)
37
  return create_dropdown_level1(label, individual)
38
 
39
  def dropdown_natural_cause(individual):
40
  label = "Natural cause"
41
- individual = add_data_to_individual("wounded_dead", "circumstance", label.lower(), individual)
42
  return create_dropdown_level1(label, individual)
43
 
44
 
@@ -72,7 +72,7 @@ def get_options(value):
72
 
73
  def on_select(evt: gr.SelectData, individual): # SelectData is a subclass of EventData
74
  options_label, options_dropdown, open_field, extras, extras_label = get_options(evt.value)
75
- individual = add_data_to_individual("wounded_dead",
76
  "circumstance_type",
77
  {"type": (evt.value).lower(),
78
  "option_dropdown_label" : options_label.lower() if options_label is not None else 'NA',
@@ -96,20 +96,20 @@ def on_select(evt: gr.SelectData, individual): # SelectData is a subclass of Ev
96
  return dropdown_level2, openfield_level2, dropdown_extra_level2, individual
97
 
98
  def on_select_dropdown_level2(evt: gr.SelectData, individual):
99
- individual = add_data_to_individual("wounded_dead",
100
  "circumstance_option_dropdown",
101
  evt.value.lower(), individual)
102
  return individual
103
 
104
  def on_select_dropdown_extra_level2(evt: gr.SelectData, individual):
105
- individual = add_data_to_individual("wounded_dead",
106
  "circumstance_extra",
107
  evt.value.lower(), individual)
108
  return individual
109
 
110
  def on_change_openfield_level2(openfield_level2_dead, individual):
111
  print("Saving open field")
112
- individual = add_data_to_individual("wounded_dead",
113
  "circumstance_open_field",
114
  str(openfield_level2_dead).lower(), individual)
115
  return individual
 
23
 
24
  def dropdown_collision(individual):
25
  label = "Collision with a means of transport"
26
+ individual = add_data_to_individual("circumstance", label.lower(), individual)
27
  return create_dropdown_level1(label, individual)
28
 
29
  def dropdown_deliberate_destruction(individual):
30
  label = "Destruction / Deliberatly removed"
31
+ individual = add_data_to_individual("circumstance", label.lower(), individual)
32
  return create_dropdown_level1(label, individual)
33
 
34
  def dropdown_indirect_destruction(individual):
35
  label = "Indirect destruction"
36
+ individual = add_data_to_individual("circumstance", label.lower(), individual)
37
  return create_dropdown_level1(label, individual)
38
 
39
  def dropdown_natural_cause(individual):
40
  label = "Natural cause"
41
+ individual = add_data_to_individual( "circumstance", label.lower(), individual)
42
  return create_dropdown_level1(label, individual)
43
 
44
 
 
72
 
73
  def on_select(evt: gr.SelectData, individual): # SelectData is a subclass of EventData
74
  options_label, options_dropdown, open_field, extras, extras_label = get_options(evt.value)
75
+ individual = add_data_to_individual(
76
  "circumstance_type",
77
  {"type": (evt.value).lower(),
78
  "option_dropdown_label" : options_label.lower() if options_label is not None else 'NA',
 
96
  return dropdown_level2, openfield_level2, dropdown_extra_level2, individual
97
 
98
  def on_select_dropdown_level2(evt: gr.SelectData, individual):
99
+ individual = add_data_to_individual(
100
  "circumstance_option_dropdown",
101
  evt.value.lower(), individual)
102
  return individual
103
 
104
  def on_select_dropdown_extra_level2(evt: gr.SelectData, individual):
105
+ individual = add_data_to_individual(
106
  "circumstance_extra",
107
  evt.value.lower(), individual)
108
  return individual
109
 
110
  def on_change_openfield_level2(openfield_level2_dead, individual):
111
  print("Saving open field")
112
+ individual = add_data_to_individual(
113
  "circumstance_open_field",
114
  str(openfield_level2_dead).lower(), individual)
115
  return individual
app/dead.py CHANGED
@@ -12,7 +12,7 @@ PATH = os.getcwd() + "/"
12
  PATH_ASSETS = os.getenv('PATH_ASSETS')
13
  PATH_ICONS = PATH + PATH_ASSETS + "icons/"
14
 
15
- def show_section_dead(visible, individual):
16
  if visible==True:
17
  individual = add_data_to_individual("wounded_state", "No", individual)
18
  individual = add_data_to_individual("dead_state", "Yes", individual)
@@ -33,7 +33,7 @@ def show_section_dead(visible, individual):
33
  with gr.Row():
34
  physical_boxes = create_bird_anatomy(False, "dead")
35
  with gr.Column():
36
- checkbox_beak, text_beak, checkbox_body, text_body, checkbox_feathers, text_feathers, checkbox_head, text_head, checkbox_legs, text_legs = process_body_parts("dead", "None")
37
 
38
  gr.Button("Follow-Up Events",
39
  icon=PATH_ICONS + "schedule.png",
 
12
  PATH_ASSETS = os.getenv('PATH_ASSETS')
13
  PATH_ICONS = PATH + PATH_ASSETS + "icons/"
14
 
15
+ def show_section_dead(visible, mode, individual):
16
  if visible==True:
17
  individual = add_data_to_individual("wounded_state", "No", individual)
18
  individual = add_data_to_individual("dead_state", "Yes", individual)
 
33
  with gr.Row():
34
  physical_boxes = create_bird_anatomy(False, "dead")
35
  with gr.Column():
36
+ checkbox_beak, text_beak, checkbox_body, text_body, checkbox_feathers, text_feathers, checkbox_head, text_head, checkbox_legs, text_legs = process_body_parts("dead", mode, "None")
37
 
38
  gr.Button("Follow-Up Events",
39
  icon=PATH_ICONS + "schedule.png",
app/mode_advanced.py CHANGED
@@ -1,6 +1,8 @@
1
  import gradio as gr
2
  from gradio_modal import Modal
3
 
 
 
4
  from validation_submission.utils_individual import add_data_to_individual
5
  from validation_submission.submission import validate_save_individual
6
  from validation_submission.validation import reset_error_box
@@ -17,9 +19,6 @@ from follow_up.followup_events import save_fe
17
  from styling.style import *
18
  from credits import credits_text
19
 
20
- from geolocalisation.js_geolocation import js_geocode, display_location
21
- from validation_submission.utils_individual import generate_random_md5
22
-
23
  from dotenv import load_dotenv
24
  import os
25
  load_dotenv()
@@ -28,6 +27,7 @@ PATH_ASSETS = os.getenv('PATH_ASSETS')
28
  PATH_ICONS = PATH + PATH_ASSETS + "icons/"
29
 
30
  with gr.Blocks(theme='shivi/calm_seafoam') as advanced:
 
31
  individual = gr.State({})
32
  individual.value = add_data_to_individual("image_md5", generate_random_md5(), individual.value)
33
 
@@ -149,7 +149,7 @@ with gr.Blocks(theme='shivi/calm_seafoam') as advanced:
149
  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, \
150
  fe_collection_dropdown_dead, fe_recepient_dropdown_dead, fe_radio_dropdown_dead, fe_answer_dropdown_dead, \
151
  fe_name_recipient_dead, fe_collection_ref_dead \
152
- = show_section_dead(False, individual)
153
 
154
  section_wounded, individual, radio_circumstance_wounded, radio_behavior_wounded, radio_physical_wounded, \
155
  button_collision_wounded, button_deliberate_destruction_wounded, button_indirect_destruction_wounded, button_natural_cause_wounded, \
@@ -159,7 +159,7 @@ with gr.Blocks(theme='shivi/calm_seafoam') as advanced:
159
  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, \
160
  fe_collection_dropdown_wounded, fe_recepient_dropdown_wounded, fe_radio_dropdown_wounded, fe_answer_dropdown_wounded, \
161
  fe_name_recipient_wounded, fe_collection_ref_wounded \
162
- = show_section_wounded(False, individual)
163
 
164
  # ---------------------------------------------------------
165
  # ---------------------------------------------------------
@@ -168,7 +168,8 @@ with gr.Blocks(theme='shivi/calm_seafoam') as advanced:
168
  partial_show_section_dead = partial(show_section_dead, True)
169
  partial_hide_section_wounded = partial(show_section_wounded, False)
170
  butt_dead.click(partial_show_section_dead,
171
- inputs=[individual],
 
172
  outputs=[section_dead,
173
  individual,
174
  radio_circumstance_dead, radio_physical_dead,
@@ -181,7 +182,8 @@ with gr.Blocks(theme='shivi/calm_seafoam') as advanced:
181
  ])
182
 
183
  butt_dead.click(partial_hide_section_wounded,
184
- inputs=[individual],
 
185
  outputs=[section_wounded,
186
  individual,
187
  radio_circumstance_wounded, radio_behavior_wounded, radio_physical_wounded,
@@ -200,7 +202,8 @@ with gr.Blocks(theme='shivi/calm_seafoam') as advanced:
200
  partial_hide_section_dead = partial(show_section_dead, False)
201
 
202
  butt_wounded.click(partial_show_section_wounded,
203
- inputs=[individual],
 
204
  outputs=[section_wounded,
205
  individual,
206
  radio_circumstance_wounded, radio_behavior_wounded, radio_physical_wounded,
@@ -214,7 +217,8 @@ with gr.Blocks(theme='shivi/calm_seafoam') as advanced:
214
  ])
215
 
216
  butt_wounded.click(partial_hide_section_dead,
217
- inputs=[individual],
 
218
  outputs=[section_dead,
219
  individual,
220
  radio_circumstance_dead, radio_physical_dead,
@@ -254,7 +258,9 @@ with gr.Blocks(theme='shivi/calm_seafoam') as advanced:
254
  # ---------------------------------------------------------
255
  # Radio Physical Dead
256
  radio_physical_dead.change(fn=show_physical,
257
- inputs=[radio_physical_dead, gr.Text("dead", visible=False), individual],
 
 
258
  outputs=[physical_boxes_dead, individual])
259
 
260
  # Checkbox Physical Dead
@@ -299,7 +305,10 @@ with gr.Blocks(theme='shivi/calm_seafoam') as advanced:
299
  # ---------------------------------------------------------
300
  # Radio Behavior Wounded
301
  radio_behavior_wounded.change(fn=show_behavior,
302
- inputs=[radio_behavior_wounded, gr.Text("wounded / sick", visible=False), individual],
 
 
 
303
  outputs=[behavior_checkbox, behavior_text, individual])
304
  behavior_checkbox.select(on_select_behavior,
305
  inputs=[behavior_checkbox, individual],
@@ -307,7 +316,9 @@ with gr.Blocks(theme='shivi/calm_seafoam') as advanced:
307
  # ---------------------------------------------------------
308
  # Radio Physical Wounded
309
  radio_physical_wounded.change(fn=show_physical,
310
- inputs=[radio_physical_wounded, gr.Text("wounded / sick", visible=False), individual],
 
 
311
  outputs=[physical_boxes_wounded, individual])
312
 
313
  # Checkbox Physical Wounded
@@ -405,7 +416,10 @@ with gr.Blocks(theme='shivi/calm_seafoam') as advanced:
405
 
406
  # ---------------------------------------------------------
407
  # VALIDATE ANIMAL
408
- button_df.click(validate_save_individual, inputs=[individual, error_box],
 
 
 
409
  outputs=[error_box])
410
  # ---------------------------------------------------------
411
  #CREDITS
 
1
  import gradio as gr
2
  from gradio_modal import Modal
3
 
4
+ from geolocalisation.js_geolocation import js_geocode, display_location
5
+ from validation_submission.utils_individual import generate_random_md5
6
  from validation_submission.utils_individual import add_data_to_individual
7
  from validation_submission.submission import validate_save_individual
8
  from validation_submission.validation import reset_error_box
 
19
  from styling.style import *
20
  from credits import credits_text
21
 
 
 
 
22
  from dotenv import load_dotenv
23
  import os
24
  load_dotenv()
 
27
  PATH_ICONS = PATH + PATH_ASSETS + "icons/"
28
 
29
  with gr.Blocks(theme='shivi/calm_seafoam') as advanced:
30
+ mode = "advanced"
31
  individual = gr.State({})
32
  individual.value = add_data_to_individual("image_md5", generate_random_md5(), individual.value)
33
 
 
149
  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, \
150
  fe_collection_dropdown_dead, fe_recepient_dropdown_dead, fe_radio_dropdown_dead, fe_answer_dropdown_dead, \
151
  fe_name_recipient_dead, fe_collection_ref_dead \
152
+ = show_section_dead(False, mode, individual)
153
 
154
  section_wounded, individual, radio_circumstance_wounded, radio_behavior_wounded, radio_physical_wounded, \
155
  button_collision_wounded, button_deliberate_destruction_wounded, button_indirect_destruction_wounded, button_natural_cause_wounded, \
 
159
  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, \
160
  fe_collection_dropdown_wounded, fe_recepient_dropdown_wounded, fe_radio_dropdown_wounded, fe_answer_dropdown_wounded, \
161
  fe_name_recipient_wounded, fe_collection_ref_wounded \
162
+ = show_section_wounded(False, mode, individual)
163
 
164
  # ---------------------------------------------------------
165
  # ---------------------------------------------------------
 
168
  partial_show_section_dead = partial(show_section_dead, True)
169
  partial_hide_section_wounded = partial(show_section_wounded, False)
170
  butt_dead.click(partial_show_section_dead,
171
+ inputs=[gr.Text(mode, visible=False),
172
+ individual],
173
  outputs=[section_dead,
174
  individual,
175
  radio_circumstance_dead, radio_physical_dead,
 
182
  ])
183
 
184
  butt_dead.click(partial_hide_section_wounded,
185
+ inputs=[gr.Text(mode, visible=False),
186
+ individual],
187
  outputs=[section_wounded,
188
  individual,
189
  radio_circumstance_wounded, radio_behavior_wounded, radio_physical_wounded,
 
202
  partial_hide_section_dead = partial(show_section_dead, False)
203
 
204
  butt_wounded.click(partial_show_section_wounded,
205
+ inputs=[gr.Text(mode, visible=False),
206
+ individual],
207
  outputs=[section_wounded,
208
  individual,
209
  radio_circumstance_wounded, radio_behavior_wounded, radio_physical_wounded,
 
217
  ])
218
 
219
  butt_wounded.click(partial_hide_section_dead,
220
+ inputs=[gr.Text(mode, visible=False),
221
+ individual],
222
  outputs=[section_dead,
223
  individual,
224
  radio_circumstance_dead, radio_physical_dead,
 
258
  # ---------------------------------------------------------
259
  # Radio Physical Dead
260
  radio_physical_dead.change(fn=show_physical,
261
+ inputs=[radio_physical_dead,
262
+ gr.Text("dead", visible=False),
263
+ individual],
264
  outputs=[physical_boxes_dead, individual])
265
 
266
  # Checkbox Physical Dead
 
305
  # ---------------------------------------------------------
306
  # Radio Behavior Wounded
307
  radio_behavior_wounded.change(fn=show_behavior,
308
+ inputs=[radio_behavior_wounded,
309
+ gr.Text("wounded / sick", visible=False),
310
+ gr.Text(mode, visible=False),
311
+ individual],
312
  outputs=[behavior_checkbox, behavior_text, individual])
313
  behavior_checkbox.select(on_select_behavior,
314
  inputs=[behavior_checkbox, individual],
 
316
  # ---------------------------------------------------------
317
  # Radio Physical Wounded
318
  radio_physical_wounded.change(fn=show_physical,
319
+ inputs=[radio_physical_wounded,
320
+ gr.Text("wounded / sick", visible=False),
321
+ individual],
322
  outputs=[physical_boxes_wounded, individual])
323
 
324
  # Checkbox Physical Wounded
 
416
 
417
  # ---------------------------------------------------------
418
  # VALIDATE ANIMAL
419
+ button_df.click(validate_save_individual,
420
+ inputs=[individual,
421
+ error_box,
422
+ gr.Text(mode, visible=False)],
423
  outputs=[error_box])
424
  # ---------------------------------------------------------
425
  #CREDITS
app/mode_simple.py CHANGED
@@ -4,7 +4,6 @@ from gradio_modal import Modal
4
  from validation_submission.utils_individual import add_data_to_individual
5
  from validation_submission.submission import validate_save_individual
6
  from validation_submission.validation import reset_error_box
7
- from geolocalisation.maps import get_location
8
  from functools import partial
9
  from dead import show_section_dead
10
  from wounded import show_section_wounded
@@ -28,6 +27,7 @@ PATH_ASSETS = os.getenv('PATH_ASSETS')
28
  PATH_ICONS = PATH + PATH_ASSETS + "icons/"
29
 
30
  with gr.Blocks(theme='shivi/calm_seafoam') as simple:
 
31
  individual = gr.State({})
32
  individual.value = add_data_to_individual("image_md5", generate_random_md5(), individual.value)
33
 
@@ -99,6 +99,25 @@ with gr.Blocks(theme='shivi/calm_seafoam') as simple:
99
  btn_gpslocation = gr.Button("Get Coordinates using GPS (Permission required)")
100
  btn_gpslocation.click(None, [], [], js=js_geocode)
101
  hidden_input.change(display_location, inputs=hidden_input, outputs=location_data)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
102
 
103
  # ---------------------------------------------------------
104
  # Dead and Wounded Buttons
@@ -128,7 +147,7 @@ with gr.Blocks(theme='shivi/calm_seafoam') as simple:
128
  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, \
129
  fe_collection_dropdown_dead, fe_recepient_dropdown_dead, fe_radio_dropdown_dead, fe_answer_dropdown_dead, \
130
  fe_name_recipient_dead, fe_collection_ref_dead \
131
- = show_section_dead(False, individual)
132
 
133
  section_wounded, individual, radio_circumstance_wounded, radio_behavior_wounded, radio_physical_wounded, \
134
  button_collision_wounded, button_deliberate_destruction_wounded, button_indirect_destruction_wounded, button_natural_cause_wounded, \
@@ -138,7 +157,7 @@ with gr.Blocks(theme='shivi/calm_seafoam') as simple:
138
  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, \
139
  fe_collection_dropdown_wounded, fe_recepient_dropdown_wounded, fe_radio_dropdown_wounded, fe_answer_dropdown_wounded, \
140
  fe_name_recipient_wounded, fe_collection_ref_wounded \
141
- = show_section_wounded(False, individual)
142
 
143
  # ---------------------------------------------------------
144
  # ---------------------------------------------------------
@@ -147,7 +166,8 @@ with gr.Blocks(theme='shivi/calm_seafoam') as simple:
147
  partial_show_section_dead = partial(show_section_dead, True)
148
  partial_hide_section_wounded = partial(show_section_wounded, False)
149
  butt_dead.click(partial_show_section_dead,
150
- inputs=[individual],
 
151
  outputs=[section_dead,
152
  individual,
153
  radio_circumstance_dead, radio_physical_dead,
@@ -160,7 +180,8 @@ with gr.Blocks(theme='shivi/calm_seafoam') as simple:
160
  ])
161
 
162
  butt_dead.click(partial_hide_section_wounded,
163
- inputs=[individual],
 
164
  outputs=[section_wounded,
165
  individual,
166
  radio_circumstance_wounded, radio_behavior_wounded, radio_physical_wounded,
@@ -179,7 +200,8 @@ with gr.Blocks(theme='shivi/calm_seafoam') as simple:
179
  partial_hide_section_dead = partial(show_section_dead, False)
180
 
181
  butt_wounded.click(partial_show_section_wounded,
182
- inputs=[individual],
 
183
  outputs=[section_wounded,
184
  individual,
185
  radio_circumstance_wounded, radio_behavior_wounded, radio_physical_wounded,
@@ -193,7 +215,8 @@ with gr.Blocks(theme='shivi/calm_seafoam') as simple:
193
  ])
194
 
195
  butt_wounded.click(partial_hide_section_dead,
196
- inputs=[individual],
 
197
  outputs=[section_dead,
198
  individual,
199
  radio_circumstance_dead, radio_physical_dead,
@@ -233,12 +256,16 @@ with gr.Blocks(theme='shivi/calm_seafoam') as simple:
233
  # ---------------------------------------------------------
234
  # Radio Physical Dead
235
  radio_physical_dead.change(fn=show_physical,
236
- inputs=[radio_physical_dead, gr.Text("dead", visible=False), individual],
 
 
237
  outputs=[physical_boxes_dead, individual])
238
 
239
  # Checkbox Physical Dead
240
  physical_boxes_dead.select(find_bounding_box,
241
- inputs=[physical_boxes_dead, gr.Textbox(value="dead", visible=False)],
 
 
242
  outputs=[checkbox_beak_dead, text_beak_dead,
243
  checkbox_body_dead, text_body_dead,
244
  checkbox_feathers_dead, text_feathers_dead,
@@ -278,7 +305,10 @@ with gr.Blocks(theme='shivi/calm_seafoam') as simple:
278
  # ---------------------------------------------------------
279
  # Radio Behavior Wounded
280
  radio_behavior_wounded.change(fn=show_behavior,
281
- inputs=[radio_behavior_wounded, gr.Text("wounded / sick", visible=False), individual],
 
 
 
282
  outputs=[behavior_checkbox, behavior_text, individual])
283
  behavior_checkbox.select(on_select_behavior,
284
  inputs=[behavior_checkbox, individual],
@@ -286,12 +316,16 @@ with gr.Blocks(theme='shivi/calm_seafoam') as simple:
286
  # ---------------------------------------------------------
287
  # Radio Physical Wounded
288
  radio_physical_wounded.change(fn=show_physical,
289
- inputs=[radio_physical_wounded, gr.Text("wounded / sick", visible=False), individual],
 
 
290
  outputs=[physical_boxes_wounded, individual])
291
 
292
  # Checkbox Physical Wounded
293
  physical_boxes_wounded.select(find_bounding_box,
294
- inputs=[physical_boxes_wounded, gr.Textbox(value="wounded / sick", visible=False)],
 
 
295
  outputs=[checkbox_beak_wounded, text_beak_wounded,
296
  checkbox_body_wounded, text_body_wounded,
297
  checkbox_feathers_wounded, text_feathers_wounded,
@@ -382,7 +416,10 @@ with gr.Blocks(theme='shivi/calm_seafoam') as simple:
382
 
383
  # ---------------------------------------------------------
384
  # VALIDATE ANIMAL
385
- button_df.click(validate_save_individual, inputs=[individual, error_box],
 
 
 
386
  outputs=[error_box])
387
  # ---------------------------------------------------------
388
  #CREDITS
 
4
  from validation_submission.utils_individual import add_data_to_individual
5
  from validation_submission.submission import validate_save_individual
6
  from validation_submission.validation import reset_error_box
 
7
  from functools import partial
8
  from dead import show_section_dead
9
  from wounded import show_section_wounded
 
27
  PATH_ICONS = PATH + PATH_ASSETS + "icons/"
28
 
29
  with gr.Blocks(theme='shivi/calm_seafoam') as simple:
30
+ mode = "simple"
31
  individual = gr.State({})
32
  individual.value = add_data_to_individual("image_md5", generate_random_md5(), individual.value)
33
 
 
99
  btn_gpslocation = gr.Button("Get Coordinates using GPS (Permission required)")
100
  btn_gpslocation.click(None, [], [], js=js_geocode)
101
  hidden_input.change(display_location, inputs=hidden_input, outputs=location_data)
102
+
103
+ from geolocalisation.maps import get_location
104
+ with gr.Column(scale=1):
105
+ gr.Markdown("#### Location (Using address)")
106
+ location = gr.Textbox(visible=True, interactive=True,
107
+ label="Location of Sighting")
108
+ #display location processing
109
+ identified_location= gr.Textbox(visible=False, interactive=False,
110
+ label="Identified GPS Location")
111
+ with gr.Row():
112
+ #to submit it
113
+ submit_location = gr.Button("Get Coordinates using address",
114
+ visible=True, interactive=True, scale=3)
115
+ submit_location.click(get_location, inputs=[location, individual], outputs=[identified_location, individual])
116
+ #to clear it
117
+ clear_location = gr.ClearButton(components=[location, identified_location],
118
+ visible=True, interactive=True, scale=1
119
+ )
120
+ clear_location.click()
121
 
122
  # ---------------------------------------------------------
123
  # Dead and Wounded Buttons
 
147
  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, \
148
  fe_collection_dropdown_dead, fe_recepient_dropdown_dead, fe_radio_dropdown_dead, fe_answer_dropdown_dead, \
149
  fe_name_recipient_dead, fe_collection_ref_dead \
150
+ = show_section_dead(False, mode, individual)
151
 
152
  section_wounded, individual, radio_circumstance_wounded, radio_behavior_wounded, radio_physical_wounded, \
153
  button_collision_wounded, button_deliberate_destruction_wounded, button_indirect_destruction_wounded, button_natural_cause_wounded, \
 
157
  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, \
158
  fe_collection_dropdown_wounded, fe_recepient_dropdown_wounded, fe_radio_dropdown_wounded, fe_answer_dropdown_wounded, \
159
  fe_name_recipient_wounded, fe_collection_ref_wounded \
160
+ = show_section_wounded(False, mode, individual)
161
 
162
  # ---------------------------------------------------------
163
  # ---------------------------------------------------------
 
166
  partial_show_section_dead = partial(show_section_dead, True)
167
  partial_hide_section_wounded = partial(show_section_wounded, False)
168
  butt_dead.click(partial_show_section_dead,
169
+ inputs=[gr.Text(mode, visible=False),
170
+ individual],
171
  outputs=[section_dead,
172
  individual,
173
  radio_circumstance_dead, radio_physical_dead,
 
180
  ])
181
 
182
  butt_dead.click(partial_hide_section_wounded,
183
+ inputs=[gr.Text(mode, visible=False),
184
+ individual],
185
  outputs=[section_wounded,
186
  individual,
187
  radio_circumstance_wounded, radio_behavior_wounded, radio_physical_wounded,
 
200
  partial_hide_section_dead = partial(show_section_dead, False)
201
 
202
  butt_wounded.click(partial_show_section_wounded,
203
+ inputs=[gr.Text(mode, visible=False),
204
+ individual],
205
  outputs=[section_wounded,
206
  individual,
207
  radio_circumstance_wounded, radio_behavior_wounded, radio_physical_wounded,
 
215
  ])
216
 
217
  butt_wounded.click(partial_hide_section_dead,
218
+ inputs=[gr.Text(mode, visible=False),
219
+ individual],
220
  outputs=[section_dead,
221
  individual,
222
  radio_circumstance_dead, radio_physical_dead,
 
256
  # ---------------------------------------------------------
257
  # Radio Physical Dead
258
  radio_physical_dead.change(fn=show_physical,
259
+ inputs=[radio_physical_dead,
260
+ gr.Text("dead", visible=False),
261
+ individual],
262
  outputs=[physical_boxes_dead, individual])
263
 
264
  # Checkbox Physical Dead
265
  physical_boxes_dead.select(find_bounding_box,
266
+ inputs=[physical_boxes_dead,
267
+ gr.Textbox(value="dead", visible=False),
268
+ gr.Text(mode, visible=False)],
269
  outputs=[checkbox_beak_dead, text_beak_dead,
270
  checkbox_body_dead, text_body_dead,
271
  checkbox_feathers_dead, text_feathers_dead,
 
305
  # ---------------------------------------------------------
306
  # Radio Behavior Wounded
307
  radio_behavior_wounded.change(fn=show_behavior,
308
+ inputs=[radio_behavior_wounded,
309
+ gr.Text("wounded / sick", visible=False),
310
+ gr.Text(mode, visible=False),
311
+ individual],
312
  outputs=[behavior_checkbox, behavior_text, individual])
313
  behavior_checkbox.select(on_select_behavior,
314
  inputs=[behavior_checkbox, individual],
 
316
  # ---------------------------------------------------------
317
  # Radio Physical Wounded
318
  radio_physical_wounded.change(fn=show_physical,
319
+ inputs=[radio_physical_wounded,
320
+ gr.Text("wounded / sick", visible=False),
321
+ individual],
322
  outputs=[physical_boxes_wounded, individual])
323
 
324
  # Checkbox Physical Wounded
325
  physical_boxes_wounded.select(find_bounding_box,
326
+ inputs=[physical_boxes_wounded,
327
+ gr.Textbox(value="wounded / sick", visible=False),
328
+ gr.Text(mode, visible=False)],
329
  outputs=[checkbox_beak_wounded, text_beak_wounded,
330
  checkbox_body_wounded, text_body_wounded,
331
  checkbox_feathers_wounded, text_feathers_wounded,
 
416
 
417
  # ---------------------------------------------------------
418
  # VALIDATE ANIMAL
419
+ button_df.click(validate_save_individual,
420
+ inputs=[individual,
421
+ error_box,
422
+ gr.Text(mode, visible=False)],
423
  outputs=[error_box])
424
  # ---------------------------------------------------------
425
  #CREDITS
app/physical/class_physical_simple.py ADDED
@@ -0,0 +1,60 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from pydantic import BaseModel, Field
2
+ from typing import Literal, List, Union, Optional
3
+
4
+ # Define common anomalies as a Literal type
5
+ CommonAnomaliesSimple = Literal[
6
+ 'injury',
7
+ 'abnormal position'
8
+ ]
9
+
10
+ # --- Beak-related Anomalies ---
11
+ class BeakAnomaly(BaseModel):
12
+ type: Literal['beak']
13
+ anomaly_type: List[Literal[
14
+ 'adhesion/discharge',
15
+ CommonAnomaliesSimple
16
+ ]]
17
+
18
+ # --- Body-related Anomalies ---
19
+ class BodyAnomaly(BaseModel):
20
+ type: Literal['body']
21
+ anomaly_type: List[Literal[
22
+ CommonAnomaliesSimple
23
+ ]]
24
+
25
+ # --- Feathers/Wings/Tail-related Anomalies ---
26
+ class FeathersWingsTailAnomaly(BaseModel):
27
+ type: Literal['feathers/wings/tail']
28
+ anomaly_type: List[Literal[
29
+ 'feather and skin change',
30
+ CommonAnomaliesSimple
31
+ ]]
32
+
33
+ # --- Head-related Anomalies (including eyes) ---
34
+ class HeadAnomaly(BaseModel):
35
+ type: Literal['head incl. eyes']
36
+ anomaly_type: List[Literal[
37
+ 'eye changes',
38
+ CommonAnomaliesSimple
39
+ ]]
40
+
41
+ # --- Legs-related Anomalies ---
42
+ class LegAnomaly(BaseModel):
43
+ type: Literal['legs']
44
+ anomaly_type: List[Literal[
45
+ CommonAnomaliesSimple
46
+ ]]
47
+
48
+ # Union of all possible anomaly types for specific body parts
49
+ AnomalyTypeSimple = Union[
50
+ BeakAnomaly,
51
+ BodyAnomaly,
52
+ LegAnomaly,
53
+ FeathersWingsTailAnomaly,
54
+ HeadAnomaly
55
+ ]
56
+
57
+ # Main PhysicalAnomaly class that logs anomalies across different body parts
58
+ class PhysicalAnomaliesSimple(BaseModel):
59
+ physical_radio: str
60
+ physical_anomalies_type: Optional[List[AnomalyTypeSimple]] = None
app/physical/physical_checkbox.py CHANGED
@@ -3,8 +3,11 @@ from utils.utils_config import get_custom_config_dropdowns
3
  from utils.utils_checkbox import create_checkbox
4
  from validation_submission.utils_individual import add_data_to_individual
5
  #---------------------------------------------------------
6
- def get_body_parts():
7
- dropdown_config = get_custom_config_dropdowns("config_checkbox_physical.json")
 
 
 
8
  return list(dropdown_config.keys())
9
 
10
  def retrieve_config_options(label, dropdown_config):
@@ -12,8 +15,12 @@ def retrieve_config_options(label, dropdown_config):
12
  options = [option.title() for option in options]
13
  return options
14
 
15
- def get_options_description(value):
16
- dropdown_config = get_custom_config_dropdowns("config_checkbox_physical.json")
 
 
 
 
17
  # get options
18
  options_common = retrieve_config_options("Common", dropdown_config)
19
  options_for_value = retrieve_config_options(value, dropdown_config)
@@ -30,56 +37,56 @@ def get_options_description(value):
30
  return options, descriptions
31
 
32
  #---------------------------------------------------------
33
- def create_checkbox_beak(section, label_checkbox, visible):
34
  body_part="Beak"
35
- options, descriptions = get_options_description(body_part)
36
  return create_checkbox(body_part, section, label_checkbox, visible, options, descriptions)
37
 
38
- def create_checkbox_body(section, label_checkbox, visible):
39
  body_part="Body"
40
- options, descriptions = get_options_description(body_part)
41
  return create_checkbox(body_part, section, label_checkbox, visible, options, descriptions)
42
 
43
- def create_checkbox_feathers(section, label_checkbox, visible):
44
  body_part="Feathers/Wings/Tail"
45
- options, descriptions = get_options_description(body_part)
46
  return create_checkbox(body_part, section, label_checkbox, visible, options, descriptions)
47
 
48
- def create_checkbox_head(section, label_checkbox, visible):
49
  body_part="Head incl. eyes"
50
- options, descriptions = get_options_description(body_part)
51
  return create_checkbox(body_part, section, label_checkbox, visible, options, descriptions)
52
 
53
- def create_checkbox_legs(section, label_checkbox, visible):
54
  body_part="Legs"
55
- options, descriptions = get_options_description(body_part)
56
  return create_checkbox(body_part, section, label_checkbox, visible, options, descriptions)
57
 
58
  #---------------------------------------------------------
59
- def process_body_parts(section, matched_box):
60
  #take all except "Common"
61
- body_parts = get_body_parts()
62
  body_parts = body_parts[1:]
63
  label_checkbox = "Physical changes to "
64
  visibles = [True if matched_box==body_part else False for body_part in body_parts ]
65
- checkbox_beak, text_beak = create_checkbox_beak(section, label_checkbox, visibles[0])
66
- checkbox_body, text_body = create_checkbox_body(section, label_checkbox, visibles[1])
67
- checkbox_feathers, text_feathers = create_checkbox_feathers(section, label_checkbox, visibles[2])
68
- checkbox_head, text_head = create_checkbox_head(section, label_checkbox, visibles[3])
69
- checkbox_legs, text_legs = create_checkbox_legs(section, label_checkbox, visibles[4])
70
  return checkbox_beak, text_beak, checkbox_body, text_body, checkbox_feathers, text_feathers, checkbox_head, text_head, checkbox_legs, text_legs
71
 
72
  #---------------------------------------------------------
73
 
74
  def on_select_body_part(body_part_checkbox, body_part, individual):
75
- individual = add_data_to_individual("wounded_dead", "physical_type_"+body_part.lower(), body_part.lower(), individual)
76
  body_part_checkbox = [body_part_check.lower() for body_part_check in body_part_checkbox]
77
- individual = add_data_to_individual("wounded_dead", "physical_anomaly_"+body_part.lower(), body_part_checkbox, individual)
78
  return individual
79
 
80
  #---------------------------------------------------------
81
 
82
- def hide_physical():
83
- checkbox_beak, text_beak, checkbox_body, text_body, checkbox_feathers, text_feathers, checkbox_head, text_head, checkbox_legs, text_legs = process_body_parts("wounded", "None")
84
  return checkbox_beak, text_beak, checkbox_body, text_body, checkbox_feathers, text_feathers, checkbox_head, text_head, checkbox_legs, text_legs
85
 
 
3
  from utils.utils_checkbox import create_checkbox
4
  from validation_submission.utils_individual import add_data_to_individual
5
  #---------------------------------------------------------
6
+ def get_body_parts(mode):
7
+ if mode=="simple":
8
+ dropdown_config = get_custom_config_dropdowns("config_checkbox_physical_simple.json")
9
+ elif mode == "advanced":
10
+ dropdown_config = get_custom_config_dropdowns("config_checkbox_physical.json")
11
  return list(dropdown_config.keys())
12
 
13
  def retrieve_config_options(label, dropdown_config):
 
15
  options = [option.title() for option in options]
16
  return options
17
 
18
+ def get_options_description(value, mode):
19
+ print(mode)
20
+ if mode=="simple":
21
+ dropdown_config = get_custom_config_dropdowns("config_checkbox_physical_simple.json")
22
+ elif mode == "advanced":
23
+ dropdown_config = get_custom_config_dropdowns("config_checkbox_physical.json")
24
  # get options
25
  options_common = retrieve_config_options("Common", dropdown_config)
26
  options_for_value = retrieve_config_options(value, dropdown_config)
 
37
  return options, descriptions
38
 
39
  #---------------------------------------------------------
40
+ def create_checkbox_beak(section, mode, label_checkbox, visible):
41
  body_part="Beak"
42
+ options, descriptions = get_options_description(body_part, mode)
43
  return create_checkbox(body_part, section, label_checkbox, visible, options, descriptions)
44
 
45
+ def create_checkbox_body(section, mode, label_checkbox, visible):
46
  body_part="Body"
47
+ options, descriptions = get_options_description(body_part, mode)
48
  return create_checkbox(body_part, section, label_checkbox, visible, options, descriptions)
49
 
50
+ def create_checkbox_feathers(section, mode, label_checkbox, visible):
51
  body_part="Feathers/Wings/Tail"
52
+ options, descriptions = get_options_description(body_part, mode)
53
  return create_checkbox(body_part, section, label_checkbox, visible, options, descriptions)
54
 
55
+ def create_checkbox_head(section, mode, label_checkbox, visible):
56
  body_part="Head incl. eyes"
57
+ options, descriptions = get_options_description(body_part, mode)
58
  return create_checkbox(body_part, section, label_checkbox, visible, options, descriptions)
59
 
60
+ def create_checkbox_legs(section, mode, label_checkbox, visible):
61
  body_part="Legs"
62
+ options, descriptions = get_options_description(body_part, mode)
63
  return create_checkbox(body_part, section, label_checkbox, visible, options, descriptions)
64
 
65
  #---------------------------------------------------------
66
+ def process_body_parts(section, mode, matched_box):
67
  #take all except "Common"
68
+ body_parts = get_body_parts(mode)
69
  body_parts = body_parts[1:]
70
  label_checkbox = "Physical changes to "
71
  visibles = [True if matched_box==body_part else False for body_part in body_parts ]
72
+ checkbox_beak, text_beak = create_checkbox_beak(section, mode, label_checkbox, visibles[0])
73
+ checkbox_body, text_body = create_checkbox_body(section, mode, label_checkbox, visibles[1])
74
+ checkbox_feathers, text_feathers = create_checkbox_feathers(section, mode, label_checkbox, visibles[2])
75
+ checkbox_head, text_head = create_checkbox_head(section, mode, label_checkbox, visibles[3])
76
+ checkbox_legs, text_legs = create_checkbox_legs(section, mode, label_checkbox, visibles[4])
77
  return checkbox_beak, text_beak, checkbox_body, text_body, checkbox_feathers, text_feathers, checkbox_head, text_head, checkbox_legs, text_legs
78
 
79
  #---------------------------------------------------------
80
 
81
  def on_select_body_part(body_part_checkbox, body_part, individual):
82
+ individual = add_data_to_individual("physical_type_"+body_part.lower(), body_part.lower(), individual)
83
  body_part_checkbox = [body_part_check.lower() for body_part_check in body_part_checkbox]
84
+ individual = add_data_to_individual("physical_anomaly_"+body_part.lower(), body_part_checkbox, individual)
85
  return individual
86
 
87
  #---------------------------------------------------------
88
 
89
+ def hide_physical(mode):
90
+ checkbox_beak, text_beak, checkbox_body, text_body, checkbox_feathers, text_feathers, checkbox_head, text_head, checkbox_legs, text_legs = process_body_parts("wounded", mode, "None")
91
  return checkbox_beak, text_beak, checkbox_body, text_body, checkbox_feathers, text_feathers, checkbox_head, text_head, checkbox_legs, text_legs
92
 
app/physical/physical_select_animal.py CHANGED
@@ -8,20 +8,22 @@ from physical.physical_checkbox import *
8
  from physical.physical_boxes_define import gdf
9
  from utils.utils_visible import set_visible
10
 
 
 
11
  load_dotenv()
12
  PATH_ASSETS = os.getenv('PATH_ASSETS')
13
 
14
  # Function to find the matching bounding box for a given point and return the image with boxes
15
- def find_bounding_box(evt: gr.SelectData, img, section: str):
16
  x, y = evt.index[0], evt.index[1]
17
  point = Point(x, y)
18
  match = gdf[gdf.contains(point)]
19
  if not match.empty:
20
  matched_box = match.iloc[0]['name']
21
- checkbox_beak, text_beak, checkbox_body, text_body, checkbox_feathers, text_feathers, checkbox_head, text_head, checkbox_legs, text_legs = process_body_parts(section, matched_box)
22
  else:
23
  matched_box = None
24
- checkbox_beak, text_beak, checkbox_body, text_body, checkbox_feathers, text_feathers, checkbox_head, text_head, checkbox_legs, text_legs = process_body_parts(section, matched_box)
25
  return checkbox_beak, text_beak, checkbox_body, text_body, checkbox_feathers, text_feathers, checkbox_head, text_head, checkbox_legs, text_legs
26
 
27
 
@@ -39,7 +41,7 @@ def create_bird_anatomy(visible, section: str):
39
  def show_physical(choice, section: str, individual):
40
  visible = set_visible(choice)
41
  physical_boxes = create_bird_anatomy(visible, section)
42
- individual = add_data_tmp("wounded_dead", "physical_radio", choice, individual)
43
  return physical_boxes, individual
44
 
45
 
 
8
  from physical.physical_boxes_define import gdf
9
  from utils.utils_visible import set_visible
10
 
11
+ from validation_submission.utils_individual import add_data_to_individual
12
+
13
  load_dotenv()
14
  PATH_ASSETS = os.getenv('PATH_ASSETS')
15
 
16
  # Function to find the matching bounding box for a given point and return the image with boxes
17
+ def find_bounding_box(evt: gr.SelectData, img, section: str, mode: str):
18
  x, y = evt.index[0], evt.index[1]
19
  point = Point(x, y)
20
  match = gdf[gdf.contains(point)]
21
  if not match.empty:
22
  matched_box = match.iloc[0]['name']
23
+ checkbox_beak, text_beak, checkbox_body, text_body, checkbox_feathers, text_feathers, checkbox_head, text_head, checkbox_legs, text_legs = process_body_parts(section, mode, matched_box)
24
  else:
25
  matched_box = None
26
+ checkbox_beak, text_beak, checkbox_body, text_body, checkbox_feathers, text_feathers, checkbox_head, text_head, checkbox_legs, text_legs = process_body_parts(section, mode, matched_box)
27
  return checkbox_beak, text_beak, checkbox_body, text_body, checkbox_feathers, text_feathers, checkbox_head, text_head, checkbox_legs, text_legs
28
 
29
 
 
41
  def show_physical(choice, section: str, individual):
42
  visible = set_visible(choice)
43
  physical_boxes = create_bird_anatomy(visible, section)
44
+ individual = add_data_to_individual("physical_radio", choice, individual)
45
  return physical_boxes, individual
46
 
47
 
app/validation_submission/submission.py CHANGED
@@ -4,8 +4,8 @@ from validation_submission.validation import validate_individual
4
  from huggingface_hub import HfApi
5
  import os
6
 
7
- def validate_save_individual(data, error_box):
8
- individual, error_box = validate_individual(data, error_box)
9
  if individual:
10
  push_to_dataset_hf(individual.model_dump())
11
  return error_box
@@ -19,9 +19,10 @@ def push_to_dataset_hf(individual):
19
  f.flush()
20
  f.close()
21
  path_in_repo= f"data/{individual['image_md5']}.json"
22
- api.upload_file(
23
- path_or_fileobj=f.name,
24
- path_in_repo=path_in_repo,
25
- repo_id="SDSC/digiwild-dataset",
26
- repo_type="dataset",
27
- )
 
 
4
  from huggingface_hub import HfApi
5
  import os
6
 
7
+ def validate_save_individual(data, error_box, mode):
8
+ individual, error_box = validate_individual(data, error_box, mode)
9
  if individual:
10
  push_to_dataset_hf(individual.model_dump())
11
  return error_box
 
19
  f.flush()
20
  f.close()
21
  path_in_repo= f"data/{individual['image_md5']}.json"
22
+ print(path_in_repo)
23
+ # api.upload_file(
24
+ # path_or_fileobj=f.name,
25
+ # path_in_repo=path_in_repo,
26
+ # repo_id="SDSC/digiwild-dataset",
27
+ # repo_type="dataset",
28
+ # )
app/validation_submission/validation.py CHANGED
@@ -5,7 +5,9 @@ import gradio as gr
5
  # from validation_submission.get_json import get_json_tmp, get_json_one_individual
6
  from circumstances.class_circumstance import Circumstances
7
  from behavior.class_behavior import Behaviors
 
8
  from physical.class_physical import PhysicalAnomalies
 
9
  from follow_up.class_follow_up import FollowUpEvents
10
  from classes import Report, Wounded, Dead, ImageBase64
11
  from validation_submission.processing import process_circumstance, process_behaviors, process_physical, process_followup
@@ -17,7 +19,7 @@ def get_fields(data_dict, keyword):
17
  extract[key] = val
18
  return extract
19
 
20
- def validate_individual(data, error_box):
21
  error_box = reset_error_box(error_box)
22
  #data = get_json_one_individual() # TODO: This should change
23
  data["identifier"] = str(uuid.uuid4())
@@ -40,13 +42,14 @@ def validate_individual(data, error_box):
40
  data["dead_state"] = "No"
41
  if (data["wounded_state"] == "Yes") or (data["dead_state"] == "Yes"):
42
  data_wounded_dead = data #get_json_tmp("wounded_dead")
 
43
  circumstance, error_circumstance = validate_circumstance(data_wounded_dead)
44
- physical, error_physical = validate_physical(data_wounded_dead)
45
  followup, error_followup = validate_follow_up(data_wounded_dead)
46
 
47
  if data["wounded_state"]=="Yes":
48
  print(physical)
49
- behavior, error_behavior = validate_behavior(data_wounded_dead)
50
  try :
51
  individual = Report(identifier = data["identifier"],
52
  image = img,
@@ -130,12 +133,16 @@ def validate_circumstance(data):
130
  return circumstances, error
131
 
132
 
133
- def validate_behavior(data):
134
  behaviors_raw = get_fields(data, "behaviors")
135
  behaviors_formatted = process_behaviors(behaviors_raw)
136
  try:
137
- Behaviors.model_validate(behaviors_formatted)
138
- behavior = Behaviors(**behaviors_formatted)
 
 
 
 
139
  error = None
140
  except ValidationError as e:
141
  print(e)
@@ -145,12 +152,17 @@ def validate_behavior(data):
145
  return behavior, error
146
 
147
 
148
- def validate_physical(data):
149
  physical_raw = get_fields(data, "physical")
150
  physical_formatted = process_physical(physical_raw)
 
151
  try:
152
- PhysicalAnomalies.model_validate(physical_formatted)
153
- physical = PhysicalAnomalies(**physical_formatted)
 
 
 
 
154
  error = None
155
  except ValidationError as e:
156
  print(e)
 
5
  # from validation_submission.get_json import get_json_tmp, get_json_one_individual
6
  from circumstances.class_circumstance import Circumstances
7
  from behavior.class_behavior import Behaviors
8
+ from behavior.class_behavior_simple import BehaviorsSimple
9
  from physical.class_physical import PhysicalAnomalies
10
+ from physical.class_physical_simple import PhysicalAnomaliesSimple
11
  from follow_up.class_follow_up import FollowUpEvents
12
  from classes import Report, Wounded, Dead, ImageBase64
13
  from validation_submission.processing import process_circumstance, process_behaviors, process_physical, process_followup
 
19
  extract[key] = val
20
  return extract
21
 
22
+ def validate_individual(data, error_box, mode:str):
23
  error_box = reset_error_box(error_box)
24
  #data = get_json_one_individual() # TODO: This should change
25
  data["identifier"] = str(uuid.uuid4())
 
42
  data["dead_state"] = "No"
43
  if (data["wounded_state"] == "Yes") or (data["dead_state"] == "Yes"):
44
  data_wounded_dead = data #get_json_tmp("wounded_dead")
45
+ print(data_wounded_dead)
46
  circumstance, error_circumstance = validate_circumstance(data_wounded_dead)
47
+ physical, error_physical = validate_physical(data_wounded_dead, mode)
48
  followup, error_followup = validate_follow_up(data_wounded_dead)
49
 
50
  if data["wounded_state"]=="Yes":
51
  print(physical)
52
+ behavior, error_behavior = validate_behavior(data_wounded_dead, mode)
53
  try :
54
  individual = Report(identifier = data["identifier"],
55
  image = img,
 
133
  return circumstances, error
134
 
135
 
136
+ def validate_behavior(data, mode):
137
  behaviors_raw = get_fields(data, "behaviors")
138
  behaviors_formatted = process_behaviors(behaviors_raw)
139
  try:
140
+ if mode=="simple":
141
+ BehaviorsSimple.model_validate(behaviors_formatted)
142
+ behavior = BehaviorsSimple(**behaviors_formatted)
143
+ elif mode=="advanced":
144
+ Behaviors.model_validate(behaviors_formatted)
145
+ behavior = Behaviors(**behaviors_formatted)
146
  error = None
147
  except ValidationError as e:
148
  print(e)
 
152
  return behavior, error
153
 
154
 
155
+ def validate_physical(data, mode):
156
  physical_raw = get_fields(data, "physical")
157
  physical_formatted = process_physical(physical_raw)
158
+ print(physical_formatted)
159
  try:
160
+ if mode=="simple":
161
+ PhysicalAnomaliesSimple.model_validate(physical_formatted)
162
+ physical = PhysicalAnomaliesSimple(**physical_formatted)
163
+ elif mode=="advanced":
164
+ PhysicalAnomalies.model_validate(physical_formatted)
165
+ physical = PhysicalAnomalies(**physical_formatted)
166
  error = None
167
  except ValidationError as e:
168
  print(e)
app/wounded.py CHANGED
@@ -13,7 +13,7 @@ PATH = os.getcwd() + "/"
13
  PATH_ASSETS = os.getenv('PATH_ASSETS')
14
  PATH_ICONS = PATH + PATH_ASSETS + "icons/"
15
 
16
- def show_section_wounded(visible, individual):
17
  if visible==True:
18
  individual = add_data_to_individual("wounded_state", "Yes", individual)
19
  individual = add_data_to_individual("dead_state", "No", individual)
@@ -32,7 +32,7 @@ def show_section_wounded(visible, individual):
32
  variant= "primary")
33
  radio_behaviour = gr.Radio(["Yes", "No"], value=None, show_label=False, interactive=True)
34
  with gr.Row():
35
- behavior_checkbox, behavior_text = create_behavior_checkbox("wounded", False)
36
 
37
  gr.Button("Are there physical changes on the animal?",
38
  icon=PATH_ICONS + "cardiogram.png",
@@ -41,7 +41,7 @@ def show_section_wounded(visible, individual):
41
  with gr.Row():
42
  physical_boxes = create_bird_anatomy(False, "wounded")
43
  with gr.Column():
44
- checkbox_beak, text_beak, checkbox_body, text_body, checkbox_feathers, text_feathers, checkbox_head, text_head, checkbox_legs, text_legs = process_body_parts("wounded", "None")
45
 
46
 
47
  gr.Button("Follow-Up Events",
 
13
  PATH_ASSETS = os.getenv('PATH_ASSETS')
14
  PATH_ICONS = PATH + PATH_ASSETS + "icons/"
15
 
16
+ def show_section_wounded(visible, mode, individual):
17
  if visible==True:
18
  individual = add_data_to_individual("wounded_state", "Yes", individual)
19
  individual = add_data_to_individual("dead_state", "No", individual)
 
32
  variant= "primary")
33
  radio_behaviour = gr.Radio(["Yes", "No"], value=None, show_label=False, interactive=True)
34
  with gr.Row():
35
+ behavior_checkbox, behavior_text = create_behavior_checkbox("wounded", mode, False)
36
 
37
  gr.Button("Are there physical changes on the animal?",
38
  icon=PATH_ICONS + "cardiogram.png",
 
41
  with gr.Row():
42
  physical_boxes = create_bird_anatomy(False, "wounded")
43
  with gr.Column():
44
+ checkbox_beak, text_beak, checkbox_body, text_body, checkbox_feathers, text_feathers, checkbox_head, text_head, checkbox_legs, text_legs = process_body_parts("wounded", mode, "None")
45
 
46
 
47
  gr.Button("Follow-Up Events",