vancauwe commited on
Commit
161d75f
Β·
1 Parent(s): 0de94b5

refactor: folders for code subparts and pydantic classes

Browse files
Files changed (35) hide show
  1. app/archive_main_old.py +0 -199
  2. app/assets/config/{config_dropdown_conditions.json β†’ config_dropdown_circumstances.json} +0 -0
  3. app/assets/images/empty_image.jpg +0 -0
  4. app/behavior/__init__.py +0 -0
  5. app/{behavior_checkbox.py β†’ behavior/behavior_checkbox.py} +4 -4
  6. app/behavior/class_behavior.py +66 -0
  7. app/circumstances/__init__.py +0 -0
  8. app/{circumstances.py β†’ circumstances/circumstances.py} +8 -8
  9. app/{circumstances_dropdowns.py β†’ circumstances/circumstances_dropdowns.py} +4 -4
  10. app/circumstances/class_circumstance.py +171 -0
  11. app/classes.py +42 -0
  12. app/dead.py +4 -4
  13. app/follow_up/class_follow_up.py +57 -0
  14. app/{followup_events.py β†’ follow_up/followup_events.py} +2 -2
  15. app/{utils_gallery.py β†’ gallery.py} +4 -2
  16. app/geolocalisation/__init__.py +0 -0
  17. app/geolocalisation/class_geolocalisation.py +16 -0
  18. app/{maps.py β†’ geolocalisation/maps.py} +1 -1
  19. app/main_multianimal.py +13 -13
  20. app/physical/__init__.py +0 -0
  21. app/physical/class_physical.py +78 -0
  22. app/{physical_boxes_define.py β†’ physical/physical_boxes_define.py} +0 -0
  23. app/{physical_boxes_map.py β†’ physical/physical_boxes_map.py} +0 -0
  24. app/{physical_checkbox.py β†’ physical/physical_checkbox.py} +3 -3
  25. app/{physical_select_animal.py β†’ physical/physical_select_animal.py} +7 -6
  26. app/styling/__init__.py +0 -0
  27. app/{style.py β†’ styling/style.py} +0 -0
  28. app/{theme.py β†’ styling/theme.py} +0 -0
  29. app/tests.py +25 -0
  30. app/utils/__init__.py +0 -0
  31. app/{utils_checkbox.py β†’ utils/utils_checkbox.py} +0 -0
  32. app/{utils_config.py β†’ utils/utils_config.py} +0 -0
  33. app/{utils_json.py β†’ utils/utils_json.py} +0 -0
  34. app/{utils_visible.py β†’ utils/utils_visible.py} +0 -0
  35. app/wounded.py +7 -7
app/archive_main_old.py DELETED
@@ -1,199 +0,0 @@
1
- import gradio as gr
2
- from functools import partial
3
- from dead import show_section_dead
4
- from wounded import show_section_wounded
5
- from circumstances import show_causes
6
- from circumstances_dropdowns import *
7
- from physical_select_animal import show_physical, find_bounding_box
8
- from behavior_checkbox import show_behavior
9
- from maps import get_location
10
- from style import *
11
- from theme import theme, css
12
-
13
- with gr.Blocks(theme=theme, css=css) as demo:
14
- # ---------------------------------------------------------
15
- # Intro Text
16
- with gr.Row():
17
- with gr.Column(scale=1):
18
- title = gr.Markdown("# Welcome to Digiwild", label="Title")
19
- description = gr.Markdown("Please record your wildlife observations here !", label="description")
20
-
21
- # ---------------------------------------------------------
22
- # Camera
23
- with gr.Row():
24
- #with gr.Column(scale=1):
25
- camera = gr.Image(elem_id="image")
26
-
27
- # ---------------------------------------------------------
28
- # Location
29
- #with gr.Row():
30
- with gr.Column(scale=1):
31
- location = gr.Textbox(visible=True, interactive=True, label="Location of Sighting")
32
- #display location processing
33
- identified_location= gr.Textbox(visible=False, interactive=False,
34
- label="Identified GPS Location")
35
- with gr.Row():
36
- #to clear it
37
- clear_location = gr.ClearButton(components=[location], visible=True, interactive=True, scale=1
38
- )
39
- clear_location.click()
40
- #to submit it
41
- submit_location = gr.Button("Get GPS Coordinates", visible=True, interactive=True, scale=3)
42
- submit_location.click(get_location, inputs=[location], outputs=[identified_location])
43
-
44
- # ---------------------------------------------------------
45
- # ---------------------------------------------------------
46
- # ---------------------------------------------------------
47
- # ---------------------------------------------------------
48
- with gr.Tab("Animal 1"):
49
- # ---------------------------------------------------------
50
- # Dead and Wounded Buttons
51
- gr.Markdown("## The State of the Animal", label="Title")
52
- gr.Markdown("Please tell us if the animal was wounded or dead.", label="description")
53
- with gr.Row() as block_form:
54
- with gr.Column(scale=1):
55
- butt_wounded = gr.Button("Wounded", elem_id="wounded")
56
- with gr.Column(scale=1):
57
- butt_dead = gr.Button("Dead", elem_id="dead")
58
-
59
- # ---------------------------------------------------------
60
- # Initiate sections
61
- section_dead, \
62
- button_collision_dead, button_deliberate_destruction_dead, button_indirect_destruction_dead, button_natural_cause_dead, \
63
- dropdown_dead, dropdown_level2_dead, openfield_level2_dead, dropdown_extra_level2_dead \
64
- = show_section_dead(False)
65
- section_wounded, radio_cause_wounded, radio_behavior_wounded, radio_physical_wounded, \
66
- button_collision_wounded, button_deliberate_destruction_wounded, button_indirect_destruction_wounded, button_natural_cause_wounded, \
67
- dropdown_wounded, dropdown_level2_wounded, openfield_level2_wounded, dropdown_extra_level2_wounded, \
68
- behavior_checkbox, behavior_text, \
69
- physical_boxes_wounded, \
70
- checkbox_beak, text_beak, checkbox_body, text_body, checkbox_feathers, text_feathers, checkbox_head, text_head, checkbox_legs, text_legs \
71
- = show_section_wounded(False)
72
-
73
- # ---------------------------------------------------------
74
- # ---------------------------------------------------------
75
- # ---------------------------------------------------------
76
- with gr.Tab("Animal 2"):
77
- # ---------------------------------------------------------
78
- # Dead and Wounded Buttons
79
- gr.Markdown("## The State of the Animal", label="Title")
80
- gr.Markdown("Please tell us if the animal was wounded or dead.", label="description")
81
- with gr.Row() as block_form:
82
- with gr.Column(scale=1):
83
- butt_wounded = gr.Button("Wounded", elem_id="wounded")
84
- with gr.Column(scale=1):
85
- butt_dead = gr.Button("Dead", elem_id="dead")
86
-
87
- # ---------------------------------------------------------
88
- # Initiate sections
89
- section_dead, \
90
- button_collision_dead, button_deliberate_destruction_dead, button_indirect_destruction_dead, button_natural_cause_dead, \
91
- dropdown_dead, dropdown_level2_dead, openfield_level2_dead, dropdown_extra_level2_dead \
92
- = show_section_dead(False)
93
- section_wounded, radio_cause_wounded, radio_behavior_wounded, radio_physical_wounded, \
94
- button_collision_wounded, button_deliberate_destruction_wounded, button_indirect_destruction_wounded, button_natural_cause_wounded, \
95
- dropdown_wounded, dropdown_level2_wounded, openfield_level2_wounded, dropdown_extra_level2_wounded, \
96
- behavior_checkbox, behavior_text, \
97
- physical_boxes_wounded, \
98
- checkbox_beak, text_beak, checkbox_body, text_body, checkbox_feathers, text_feathers, checkbox_head, text_head, checkbox_legs, text_legs \
99
- = show_section_wounded(False)
100
- # ---------------------------------------------------------
101
- # ---------------------------------------------------------
102
- # ---------------------------------------------------------
103
-
104
- # ---------------------------------------------------------
105
- # Dead Button Logic
106
- partial_show_section_dead = partial(show_section_dead, True)
107
- partial_hide_section_wounded = partial(show_section_wounded, False)
108
- butt_dead.click(partial_show_section_dead,
109
- inputs=None,
110
- outputs=[section_dead,
111
- button_collision_dead, button_deliberate_destruction_dead, button_indirect_destruction_dead, button_natural_cause_dead,
112
- dropdown_dead, dropdown_level2_dead, openfield_level2_dead, dropdown_extra_level2_dead
113
- ])
114
- butt_dead.click(partial_hide_section_wounded,
115
- inputs=None,
116
- outputs=[section_wounded,
117
- radio_cause_wounded, radio_behavior_wounded, radio_physical_wounded,
118
- button_collision_wounded, button_deliberate_destruction_wounded, button_indirect_destruction_wounded, button_natural_cause_wounded,
119
- dropdown_wounded, dropdown_level2_wounded, openfield_level2_wounded, dropdown_extra_level2_wounded,
120
- behavior_checkbox, behavior_text,
121
- physical_boxes_wounded,
122
- checkbox_beak, text_beak, checkbox_body, text_body, checkbox_feathers, text_feathers, checkbox_head, text_head, checkbox_legs, text_legs
123
- ])
124
- # ---------------------------------------------------------
125
- # Wounded Button Logic
126
- partial_show_section_wounded = partial(show_section_wounded, True)
127
- partial_hide_section_dead = partial(show_section_dead, False)
128
-
129
- butt_wounded.click(partial_show_section_wounded,
130
- inputs=None,
131
- outputs=[section_wounded,
132
- radio_cause_wounded, radio_behavior_wounded, radio_physical_wounded,
133
- button_collision_wounded, button_deliberate_destruction_wounded, button_indirect_destruction_wounded, button_natural_cause_wounded,
134
- dropdown_wounded, dropdown_level2_wounded, openfield_level2_wounded, dropdown_extra_level2_wounded,
135
- behavior_checkbox, behavior_text,
136
- physical_boxes_wounded,
137
- checkbox_beak, text_beak, checkbox_body, text_body, checkbox_feathers, text_feathers, checkbox_head, text_head, checkbox_legs, text_legs
138
- ])
139
- butt_wounded.click(partial_hide_section_dead, inputs=None, outputs=[section_dead,
140
- button_collision_dead, button_deliberate_destruction_dead, button_indirect_destruction_dead, button_natural_cause_dead,
141
- dropdown_dead, dropdown_level2_dead, openfield_level2_dead, dropdown_extra_level2_dead
142
- ])
143
- # ---------------------------------------------------------
144
- # Dropdowns Dead
145
- button_collision_dead.click(dropdown_collision,
146
- outputs=[dropdown_dead, dropdown_level2_dead, openfield_level2_dead, dropdown_extra_level2_dead])
147
- button_deliberate_destruction_dead.click(dropdown_deliberate_destruction, outputs=[dropdown_dead, dropdown_level2_dead, openfield_level2_dead, dropdown_extra_level2_dead])
148
- button_indirect_destruction_dead.click(dropdown_indirect_destruction, outputs=[dropdown_dead, dropdown_level2_dead, openfield_level2_dead, dropdown_extra_level2_dead])
149
- button_natural_cause_dead.click(dropdown_natural_cause, outputs=[dropdown_dead, dropdown_level2_dead, openfield_level2_dead, dropdown_extra_level2_dead])
150
-
151
- dropdown_dead.select(on_select, None, [dropdown_level2_dead, openfield_level2_dead, dropdown_extra_level2_dead])
152
-
153
- # ---------------------------------------------------------
154
- # Radio Cause Wounded
155
- radio_cause_wounded.change(fn=show_causes,
156
- inputs=[radio_cause_wounded],
157
- outputs=[button_collision_wounded, button_deliberate_destruction_wounded, button_indirect_destruction_wounded, button_natural_cause_wounded,
158
- dropdown_wounded, dropdown_level2_wounded, openfield_level2_wounded, dropdown_extra_level2_wounded]
159
- )
160
-
161
- # Dropdowns Cause Wounded
162
- button_collision_wounded.click(dropdown_collision,
163
- outputs=[dropdown_wounded, dropdown_level2_wounded, openfield_level2_wounded, dropdown_extra_level2_wounded])
164
- button_deliberate_destruction_wounded.click(dropdown_deliberate_destruction, outputs=[dropdown_wounded, dropdown_level2_wounded, openfield_level2_wounded, dropdown_extra_level2_wounded])
165
- button_indirect_destruction_wounded.click(dropdown_indirect_destruction, outputs=[dropdown_wounded, dropdown_level2_wounded, openfield_level2_wounded, dropdown_extra_level2_wounded])
166
- button_natural_cause_wounded.click(dropdown_natural_cause, outputs=[dropdown_wounded, dropdown_level2_wounded, openfield_level2_wounded, dropdown_extra_level2_wounded])
167
-
168
- dropdown_wounded.select(on_select, None, [dropdown_level2_wounded, openfield_level2_wounded, dropdown_extra_level2_wounded])
169
-
170
- # ---------------------------------------------------------
171
- # Radio Behavior Wounded
172
- radio_behavior_wounded.change(fn=show_behavior,
173
- inputs=[radio_behavior_wounded, gr.Text("wounded", visible=False)],
174
- outputs=[behavior_checkbox, behavior_text])
175
-
176
- # ---------------------------------------------------------
177
- # Radio Physical Wounded
178
- radio_physical_wounded.change(fn=show_physical,
179
- inputs=[radio_physical_wounded, gr.Text("wounded", visible=False)],
180
- outputs=[physical_boxes_wounded])
181
-
182
- # Checkbox Physical Wounded
183
- physical_boxes_wounded.select(find_bounding_box,
184
- inputs=[physical_boxes_wounded, gr.Textbox(value="wounded", visible=False)],
185
- outputs=[checkbox_beak, text_beak, checkbox_body, text_body, checkbox_feathers, text_feathers, checkbox_head, text_head, checkbox_legs, text_legs
186
- ])
187
-
188
- # ---------------------------------------------------------
189
- #Submit Button
190
- with gr.Column(scale=1):
191
- subbutt = gr.Button("SUBMIT YOUR OBSERVATION TO ORNITHO",
192
- elem_id="submit",
193
- icon="https://cdn.iconscout.com/icon/free/png-256/free-send-2451554-2082560.png",
194
- scale=1)
195
- output_message = gr.Markdown("Thank you, you are a champion of biodiversity conservation !")
196
-
197
-
198
-
199
- demo.launch(server_name="0.0.0.0")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/assets/config/{config_dropdown_conditions.json β†’ config_dropdown_circumstances.json} RENAMED
File without changes
app/assets/images/empty_image.jpg ADDED
app/behavior/__init__.py ADDED
File without changes
app/{behavior_checkbox.py β†’ behavior/behavior_checkbox.py} RENAMED
@@ -1,8 +1,8 @@
1
  import gradio as gr
2
- from utils_config import get_custom_config_dropdowns
3
- from utils_checkbox import create_checkbox
4
- from utils_visible import set_visible
5
- from utils_json import add_data_to_individual
6
 
7
  def on_select_behavior(behavior_checkbox):
8
  add_data_to_individual("behavior", behavior_checkbox)
 
1
  import gradio as gr
2
+ from utils.utils_config import get_custom_config_dropdowns
3
+ from utils.utils_checkbox import create_checkbox
4
+ from utils.utils_visible import set_visible
5
+ from utils.utils_json import add_data_to_individual
6
 
7
  def on_select_behavior(behavior_checkbox):
8
  add_data_to_individual("behavior", behavior_checkbox)
app/behavior/class_behavior.py ADDED
@@ -0,0 +1,66 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from pydantic import BaseModel, Field
2
+ from typing import Literal, List, Union
3
+
4
+
5
+ class Behavior(BaseModel):
6
+ type: str
7
+ description: str
8
+
9
+ # --- Specific Behavior classes ---
10
+ class AbnormalBreathing(Behavior):
11
+ type: Literal['abnormal breathing']
12
+ description: Literal["Problems breathing, breathing sounds"]
13
+
14
+ class CrashFalling(Behavior):
15
+ type: Literal['crash, falling from the sky']
16
+ description: Literal["Suddenly falling from the sky"]
17
+
18
+ class Diarrhea(Behavior):
19
+ type: Literal['diarrhea']
20
+ description: Literal["Observed diarrhea"]
21
+
22
+ class Lameness(Behavior):
23
+ type: Literal['lameness']
24
+ description: Literal["Apparent limping or not able to walk properly"]
25
+
26
+ class Neurological(Behavior):
27
+ type: Literal['neurological']
28
+ description: Literal["Circling, incoordination, tremors, convulsions, fast eye movements"]
29
+
30
+ class OtherAbnormalBehavior(Behavior):
31
+ type: Literal['other abnormal behavior']
32
+ description: Literal["Other than weakness, other than neurologic"]
33
+
34
+ class UnableToFly(Behavior):
35
+ type: Literal['unable to fly']
36
+ description: Literal["Animal alert and tries to fly but can not take off"]
37
+
38
+ class Vomiting(Behavior):
39
+ type: Literal['vomiting']
40
+ description: Literal["Throwing up undigested food, regurgitating"]
41
+
42
+ class Weakness(Behavior):
43
+ type: Literal['weakness']
44
+ description: Literal["Non responsive, does not fly away when approached, lethargy"]
45
+
46
+ class NoChanges(Behavior):
47
+ type: Literal['no changes']
48
+ description: Literal["Animal is acting normally"]
49
+
50
+ # Union of all possible behaviors
51
+ BehaviorType = Union[
52
+ AbnormalBreathing,
53
+ CrashFalling,
54
+ Diarrhea,
55
+ Lameness,
56
+ Neurological,
57
+ OtherAbnormalBehavior,
58
+ UnableToFly,
59
+ Vomiting,
60
+ Weakness,
61
+ NoChanges
62
+ ]
63
+
64
+ # Main class that logs multiple behaviors
65
+ class Behaviors(BaseModel):
66
+ observed_behaviors: List[BehaviorType]
app/circumstances/__init__.py ADDED
File without changes
app/{circumstances.py β†’ circumstances/circumstances.py} RENAMED
@@ -1,6 +1,6 @@
1
  import gradio as gr
2
  import os
3
- from utils_visible import set_visible
4
  from dotenv import load_dotenv
5
  import os
6
  load_dotenv()
@@ -11,17 +11,17 @@ LOGO_PATH = PATH + PATH_ASSETS + "logos"
11
  CAUSE_COL_WIDTH = "50px"
12
 
13
 
14
- def show_causes(choice):
15
  visible = set_visible(choice)
16
- button_collision, button_deliberate_destruction, button_indirect_destruction, button_natural_cause, dropdown, dropdown_level2, openfield_level2, dropdown_extra_level2 = create_causes(visible)
17
  return button_collision, button_deliberate_destruction, button_indirect_destruction, button_natural_cause, dropdown, dropdown_level2, openfield_level2, dropdown_extra_level2
18
 
19
- def create_causes(visible):
20
- button_collision, button_deliberate_destruction, button_indirect_destruction, button_natural_cause = create_causes_buttons(visible)
21
- dropdown, dropdown_level2, openfield_level2, dropdown_extra_level2 = create_causes_dropdown(visible)
22
  return button_collision, button_deliberate_destruction, button_indirect_destruction, button_natural_cause, dropdown, dropdown_level2, openfield_level2, dropdown_extra_level2
23
 
24
- def create_causes_buttons(visible):
25
  with gr.Row() as image_row:
26
  with gr.Column(scale=1, min_width=CAUSE_COL_WIDTH):
27
  button_collision = gr.Button("Collision with a means of transport",
@@ -48,7 +48,7 @@ def create_causes_buttons(visible):
48
  elem_id="buttons-conditions")
49
  return button_collision, button_deliberate_destruction, button_indirect_destruction, button_natural_cause
50
 
51
- def create_causes_dropdown(visible):
52
  with gr.Row() as dropdown_row:
53
  dropdown = gr.Dropdown(choices=[],
54
  label="Choices will appear here...",
 
1
  import gradio as gr
2
  import os
3
+ from utils.utils_visible import set_visible
4
  from dotenv import load_dotenv
5
  import os
6
  load_dotenv()
 
11
  CAUSE_COL_WIDTH = "50px"
12
 
13
 
14
+ def show_circumstances(choice):
15
  visible = set_visible(choice)
16
+ button_collision, button_deliberate_destruction, button_indirect_destruction, button_natural_cause, dropdown, dropdown_level2, openfield_level2, dropdown_extra_level2 = create_circumstances(visible)
17
  return button_collision, button_deliberate_destruction, button_indirect_destruction, button_natural_cause, dropdown, dropdown_level2, openfield_level2, dropdown_extra_level2
18
 
19
+ def create_circumstances(visible):
20
+ button_collision, button_deliberate_destruction, button_indirect_destruction, button_natural_cause = create_circumstances_buttons(visible)
21
+ dropdown, dropdown_level2, openfield_level2, dropdown_extra_level2 = create_circumstances_dropdown(visible)
22
  return button_collision, button_deliberate_destruction, button_indirect_destruction, button_natural_cause, dropdown, dropdown_level2, openfield_level2, dropdown_extra_level2
23
 
24
+ def create_circumstances_buttons(visible):
25
  with gr.Row() as image_row:
26
  with gr.Column(scale=1, min_width=CAUSE_COL_WIDTH):
27
  button_collision = gr.Button("Collision with a means of transport",
 
48
  elem_id="buttons-conditions")
49
  return button_collision, button_deliberate_destruction, button_indirect_destruction, button_natural_cause
50
 
51
+ def create_circumstances_dropdown(visible):
52
  with gr.Row() as dropdown_row:
53
  dropdown = gr.Dropdown(choices=[],
54
  label="Choices will appear here...",
app/{circumstances_dropdowns.py β†’ circumstances/circumstances_dropdowns.py} RENAMED
@@ -1,6 +1,6 @@
1
  import gradio as gr
2
- from utils_config import get_custom_config_dropdowns
3
- from utils_json import add_data_to_individual
4
 
5
  #--------------------------------------------------------- LEVEL 1 DROPDOWNS
6
  def retrieve_config_options(label, dropdown_config):
@@ -15,7 +15,7 @@ def reinitialise_level2():
15
  return dropdown_level2, openfield_level2, dropdown_extra_level2
16
 
17
  def create_dropdown_level1(label):
18
- dropdown_config = get_custom_config_dropdowns("config_dropdown_conditions.json")
19
  options = retrieve_config_options(label, dropdown_config)
20
  dropdown = gr.Dropdown(choices=options, label=label, interactive=True, visible=True)
21
  dropdown_level2, openfield_level2, dropdown_extra_level2 = reinitialise_level2()
@@ -49,7 +49,7 @@ def get_options(value):
49
  open_field = None
50
  extras = None
51
  extras_label = None
52
- dropdown_config = get_custom_config_dropdowns("config_dropdown_conditions.json")
53
  for _, sub_dict in dropdown_config.items():
54
  nested_dict = sub_dict.get(value)
55
  if nested_dict is not None:
 
1
  import gradio as gr
2
+ from utils.utils_config import get_custom_config_dropdowns
3
+ from utils.utils_json import add_data_to_individual
4
 
5
  #--------------------------------------------------------- LEVEL 1 DROPDOWNS
6
  def retrieve_config_options(label, dropdown_config):
 
15
  return dropdown_level2, openfield_level2, dropdown_extra_level2
16
 
17
  def create_dropdown_level1(label):
18
+ dropdown_config = get_custom_config_dropdowns("config_dropdown_circumstances.json")
19
  options = retrieve_config_options(label, dropdown_config)
20
  dropdown = gr.Dropdown(choices=options, label=label, interactive=True, visible=True)
21
  dropdown_level2, openfield_level2, dropdown_extra_level2 = reinitialise_level2()
 
49
  open_field = None
50
  extras = None
51
  extras_label = None
52
+ dropdown_config = get_custom_config_dropdowns("config_dropdown_circumstances.json")
53
  for _, sub_dict in dropdown_config.items():
54
  nested_dict = sub_dict.get(value)
55
  if nested_dict is not None:
app/circumstances/class_circumstance.py ADDED
@@ -0,0 +1,171 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from pydantic import BaseModel, Field
2
+ from typing import Literal, List, Union, Optional
3
+
4
+ # Base class for CircumstanceType with a discriminator field 'type'
5
+ class CircumstanceTypeBase(BaseModel):
6
+ type: str
7
+
8
+ # Collision with means of transport
9
+ class RoadVehicleCollision(CircumstanceTypeBase):
10
+ type: Literal['road_vehicle']
11
+ infrastructure_number: Optional[str] = None
12
+ road_type: Literal['highway', 'main road', 'secondary road', 'local road/path/trail', 'parking lot', 'other', 'unknown']
13
+
14
+ class TrainCollision(CircumstanceTypeBase):
15
+ type: Literal['train']
16
+ infrastructure_number: str
17
+
18
+ class AircraftCollision(CircumstanceTypeBase):
19
+ type: Literal['aircraft']
20
+
21
+ class BoatCollision(CircumstanceTypeBase):
22
+ type: Literal['boat']
23
+
24
+ class OtherTransportCollision(CircumstanceTypeBase):
25
+ type: Literal['other']
26
+
27
+ class UnknownTransportCollision(CircumstanceTypeBase):
28
+ type: Literal['unknown']
29
+
30
+ # Destruction / Deliberately removed
31
+ class HuntingDestruction(CircumstanceTypeBase):
32
+ type: Literal['hunting']
33
+ method: Literal['shooting', 'bow', 'falconry', 'hounds hunting', 'digging up', 'other', 'unknown']
34
+
35
+ class TrapDestruction(CircumstanceTypeBase):
36
+ type: Literal['trap']
37
+ method: Literal['killing trap', 'pole trap', 'trap cage', 'corvids nasse', 'net', 'cage trap', 'fall-trap', 'glue trap', 'insect trap', 'other', 'unknown']
38
+
39
+ class PoisoningDestruction(CircumstanceTypeBase):
40
+ type: Literal['poisoning']
41
+
42
+ class RemovalDestruction(CircumstanceTypeBase):
43
+ type: Literal['removal or direct capture']
44
+ method: Literal['gassing', 'raptor captured at nest', 'brood destruction', 'traffic/trade', 'capture accident', 'scientific sample', 'other', 'unknown']
45
+
46
+ class FishingDestruction(CircumstanceTypeBase):
47
+ type: Literal['fishing']
48
+ method: Literal['drowned/tangled', 'beached with capture indications', 'other', 'unknown']
49
+
50
+ class OtherDestruction(CircumstanceTypeBase):
51
+ type: Literal['other']
52
+
53
+ class UnknownDestruction(CircumstanceTypeBase):
54
+ type: Literal['unknown']
55
+
56
+ # Indirect destruction
57
+ class PylonElectricGridDestruction(CircumstanceTypeBase):
58
+ type: Literal['pylone and electric grid']
59
+ infrastructure: Literal['electric line', 'pole/pylon', 'other', 'unknown']
60
+ cause: Literal['collision', 'electrocution', 'unknown']
61
+
62
+ class WindfarmDestruction(CircumstanceTypeBase):
63
+ type: Literal['windfarm']
64
+
65
+ class OtherCollisionDestruction(CircumstanceTypeBase):
66
+ type: Literal['other collision']
67
+ object: Literal['window', 'building', 'lighthouse', 'cable', 'wire fence/barbed wire', 'other crash', 'unknown']
68
+
69
+ class FallDestruction(CircumstanceTypeBase):
70
+ type: Literal['fall']
71
+ location: Literal['chimney', 'empty pole', 'hole/well', 'other', 'unknown']
72
+
73
+ class DevelopmentWorkDestruction(CircumstanceTypeBase):
74
+ type: Literal['development work']
75
+ work_type: Literal['transport infrastructure', 'building', 'other', 'unknown']
76
+
77
+ class PollutionContaminationDestruction(CircumstanceTypeBase):
78
+ type: Literal['pollution / contamination']
79
+ pollution_type: Literal['oil pollution', 'chemical pollution', 'heavy metals', 'light', 'noise', 'plastic ingestion', 'other', 'unknown']
80
+
81
+ class AgriculturalNetProtectionDestruction(CircumstanceTypeBase):
82
+ type: Literal['agricultural net protection']
83
+
84
+ class VegetalForestWorkDestruction(CircumstanceTypeBase):
85
+ type: Literal['vegetal / forest work']
86
+ work_type: Literal['clearing/mowing/plowing', 'tree felling/pruning', 'other', 'unknown']
87
+
88
+ class OtherIndirectDestruction(CircumstanceTypeBase):
89
+ type: Literal['other']
90
+
91
+ class UnknownIndirectDestruction(CircumstanceTypeBase):
92
+ type: Literal['unknown']
93
+
94
+ # Natural cause
95
+ class Predation(CircumstanceTypeBase):
96
+ type: Literal['predation']
97
+ predator: Literal['cat', 'dog', 'rooster/hen', 'other domestic animal', 'wild birds', 'wild mammal', 'other', 'unknown']
98
+
99
+ class Weather(CircumstanceTypeBase):
100
+ type: Literal['weather']
101
+ condition: Literal['cold wave', 'drought', 'hail', 'lightening', 'storm', 'other', 'unknown']
102
+
103
+ class NaturalDisaster(CircumstanceTypeBase):
104
+ type: Literal['natural disaster']
105
+ disaster: Literal['fire', 'avalanche', 'rock fall', 'mudslide', 'volcanic eruption/ashes', 'other', 'unknown']
106
+
107
+ class NestFall(CircumstanceTypeBase):
108
+ type: Literal['nest fall']
109
+
110
+ class StrandingExhaustion(CircumstanceTypeBase):
111
+ type: Literal['stranding due to exhaustion']
112
+
113
+ class DiseaseParasite(CircumstanceTypeBase):
114
+ type: Literal['disease/parasite']
115
+
116
+ class AccidentalDrowning(CircumstanceTypeBase):
117
+ type: Literal['accidental drowning']
118
+ drowning_location: Literal['drinking trough', 'pool', 'storm pool', 'irrigation pool', 'natural pool', 'flood', 'other container', 'unknown']
119
+
120
+ class OtherNaturalCause(CircumstanceTypeBase):
121
+ type: Literal['other']
122
+
123
+ class UnknownNaturalCause(CircumstanceTypeBase):
124
+ type: Literal['unknown']
125
+
126
+ # Unknown cause
127
+ class UnknownCircumstance(CircumstanceTypeBase):
128
+ type: Literal['unknown']
129
+
130
+ # Union of all possible CircumstanceTypes with 'type' as the discriminator
131
+ CircumstanceType = Union[
132
+ RoadVehicleCollision,
133
+ TrainCollision,
134
+ AircraftCollision,
135
+ BoatCollision,
136
+ OtherTransportCollision,
137
+ UnknownTransportCollision,
138
+ HuntingDestruction,
139
+ TrapDestruction,
140
+ PoisoningDestruction,
141
+ RemovalDestruction,
142
+ FishingDestruction,
143
+ OtherDestruction,
144
+ UnknownDestruction,
145
+ PylonElectricGridDestruction,
146
+ WindfarmDestruction,
147
+ OtherCollisionDestruction,
148
+ FallDestruction,
149
+ DevelopmentWorkDestruction,
150
+ PollutionContaminationDestruction,
151
+ AgriculturalNetProtectionDestruction,
152
+ VegetalForestWorkDestruction,
153
+ OtherIndirectDestruction,
154
+ UnknownIndirectDestruction,
155
+ Predation,
156
+ Weather,
157
+ NaturalDisaster,
158
+ NestFall,
159
+ StrandingExhaustion,
160
+ DiseaseParasite,
161
+ AccidentalDrowning,
162
+ OtherNaturalCause,
163
+ UnknownNaturalCause,
164
+ UnknownCircumstance
165
+ ]
166
+
167
+ # Main Circumstance class
168
+ class Circumstances(BaseModel):
169
+ circumstance: str # e.g., "COLLISION"
170
+ circumstance_radio: str # e.g., "Yes"
171
+ circumstance_type: CircumstanceType = Field(..., discriminator='type')
app/classes.py ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from pydantic import BaseModel, Field
2
+ from typing import Literal, List, Union, Optional
3
+
4
+ from behavior.class_behavior import Behaviors
5
+ from circumstances.class_circumstance import Circumstances
6
+ from physical.class_physical import PhysicalAnomaly
7
+ from follow_up.class_follow_up import FollowUpEvents
8
+ from geolocalisation.class_geolocalisation import Geolocalisation
9
+
10
+ class Wounded(BaseModel):
11
+ circumstances: List[Circumstances]
12
+ behaviors: List[Behaviors]
13
+ physical_anomalies: List[PhysicalAnomaly]
14
+ follow_up_events: List[FollowUpEvents]
15
+
16
+ class Dead(BaseModel):
17
+ circumstances: List[Circumstances]
18
+ physical_anomalies: List[PhysicalAnomaly]
19
+ follow_up_events: List[FollowUpEvents]
20
+
21
+ class Image(BaseModel):
22
+ image: List[float]
23
+
24
+ class Report(BaseModel):
25
+ image: Image
26
+ geolocalisation: Geolocalisation
27
+ wounded_state: bool
28
+ wounded: Optional[Wounded] = None
29
+ dead_state: bool
30
+ dead: Optional[Dead] = None
31
+
32
+ # Example usage
33
+ # json_data = {
34
+ # "circumstance": "COLLISION",
35
+ # "circumstance_radio": "Yes",
36
+ # "circumstance_type": {
37
+ # "type": "Train",
38
+ # "infrastructure_number": "56"
39
+ # }
40
+ # }
41
+ # circumstance_instance = Circumstance(**json_data)
42
+ # circumstance_schema = Circumstance.schema_json(indent=2)
app/dead.py CHANGED
@@ -1,7 +1,7 @@
1
  import gradio as gr
2
- from circumstances import create_causes
3
- from followup_events import create_followup_dropdowns, create_followup_open
4
- from utils_json import add_data_to_individual
5
 
6
  def show_section_dead(visible):
7
  if visible==True:
@@ -12,7 +12,7 @@ def show_section_dead(visible):
12
  gr.Markdown("# Dead Animal")
13
  gr.Markdown("## Please describe the cause of death", label="description")
14
 
15
- button_collision, button_deliberate_destruction, button_indirect_destruction, button_natural_cause, dropdown, dropdown_level2, openfield_level2, dropdown_extra_level2 = create_causes(visible)
16
 
17
  gr.Markdown("## Follow-Up Events", label="Title")
18
  gr.Markdown("Please tell us what you did with the animal.", label="description")
 
1
  import gradio as gr
2
+ from circumstances.circumstances import create_circumstances
3
+ from follow_up.followup_events import create_followup_dropdowns, create_followup_open
4
+ from utils.utils_json import add_data_to_individual
5
 
6
  def show_section_dead(visible):
7
  if visible==True:
 
12
  gr.Markdown("# Dead Animal")
13
  gr.Markdown("## Please describe the cause of death", label="description")
14
 
15
+ button_collision, button_deliberate_destruction, button_indirect_destruction, button_natural_cause, dropdown, dropdown_level2, openfield_level2, dropdown_extra_level2 = create_circumstances(visible)
16
 
17
  gr.Markdown("## Follow-Up Events", label="Title")
18
  gr.Markdown("Please tell us what you did with the animal.", label="description")
app/follow_up/class_follow_up.py ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from pydantic import BaseModel, Field
2
+ from typing import Literal, Union, Optional, List
3
+
4
+ # --- Event follow-up classes ---
5
+
6
+ # Animal collected event
7
+ class AnimalCollectedEvent(BaseModel):
8
+ type: Literal['animal collected']
9
+ option: Literal['Yes', 'No']
10
+
11
+ # Recipient event
12
+ class RecipientEvent(BaseModel):
13
+ type: Literal['recipient']
14
+ option: Literal['Veterinary', 'Care center', 'Local Museum', 'National Museum', 'Other']
15
+
16
+ # Radiography event
17
+ class RadiographyEvent(BaseModel):
18
+ type: Literal['radiography']
19
+ option: Literal['Yes', 'No', 'Unknown']
20
+
21
+ # Given answer event
22
+ class GivenAnswerEvent(BaseModel):
23
+ type: Literal['given answer']
24
+ option: Literal[
25
+ 'Nothing',
26
+ 'Complaint against X',
27
+ 'Complaint',
28
+ 'Police call',
29
+ 'Discussion with the speaker',
30
+ 'Press release',
31
+ 'Unknown'
32
+ ]
33
+
34
+ # Name of recipient/museum (open text field)
35
+ class NameOfRecipientEvent(BaseModel):
36
+ type: Literal['name of recipient / museum']
37
+ name: str # Open text field for entering the name
38
+
39
+ # Collection reference (open text field)
40
+ class CollectionReferenceEvent(BaseModel):
41
+ type: Literal['collection reference']
42
+ reference: str # Open text field for entering the reference
43
+
44
+ # Union of all possible follow-up event types
45
+ FollowUpEventType = Union[
46
+ AnimalCollectedEvent,
47
+ RecipientEvent,
48
+ RadiographyEvent,
49
+ GivenAnswerEvent,
50
+ NameOfRecipientEvent,
51
+ CollectionReferenceEvent
52
+ ]
53
+
54
+ # Main class that logs multiple follow-up events
55
+ class FollowUpEvents(BaseModel):
56
+ follow_up_events: List[FollowUpEventType]
57
+
app/{followup_events.py β†’ follow_up/followup_events.py} RENAMED
@@ -1,6 +1,6 @@
1
  import gradio as gr
2
- from utils_config import get_custom_config_dropdowns
3
- from utils_json import add_data_to_individual
4
 
5
  def create_followup_dropdowns(visible, elem_id):
6
  followup_config = get_custom_config_dropdowns("config_followup.json")
 
1
  import gradio as gr
2
+ from utils.utils_config import get_custom_config_dropdowns
3
+ from utils.utils_json import add_data_to_individual
4
 
5
  def create_followup_dropdowns(visible, elem_id):
6
  followup_config = get_custom_config_dropdowns("config_followup.json")
app/{utils_gallery.py β†’ gallery.py} RENAMED
@@ -2,9 +2,11 @@ import gradio as gr
2
  import pandas as pd
3
  import numpy as np
4
  from dotenv import load_dotenv
5
- from utils_config import load_config
6
- from utils_json import get_json_one_individual, save_to_all_individuals
 
7
  import os
 
8
  load_dotenv()
9
  PATH = os.getcwd() + "/"
10
  PATH_ASSETS = os.getenv('PATH_ASSETS')
 
2
  import pandas as pd
3
  import numpy as np
4
  from dotenv import load_dotenv
5
+
6
+ from utils.utils_config import load_config
7
+ from utils.utils_json import get_json_one_individual, save_to_all_individuals
8
  import os
9
+
10
  load_dotenv()
11
  PATH = os.getcwd() + "/"
12
  PATH_ASSETS = os.getenv('PATH_ASSETS')
app/geolocalisation/__init__.py ADDED
File without changes
app/geolocalisation/class_geolocalisation.py ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from pydantic import BaseModel, Field
2
+ from typing import Literal, List, Union
3
+
4
+ class Longitude(BaseModel):
5
+ type: Literal['longitude']
6
+ value: float
7
+
8
+ class Latitude(BaseModel):
9
+ type: Literal['latitude']
10
+ value: float
11
+
12
+ class Geolocalisation(BaseModel):
13
+ longitude: Longitude
14
+ latitude: Latitude
15
+ name: str
16
+
app/{maps.py β†’ geolocalisation/maps.py} RENAMED
@@ -1,6 +1,6 @@
1
  from geopy.geocoders import Nominatim
2
  import gradio as gr
3
- from utils_json import add_data_to_individual
4
 
5
  def get_location(address):
6
  # try:
 
1
  from geopy.geocoders import Nominatim
2
  import gradio as gr
3
+ from utils.utils_json import add_data_to_individual
4
 
5
  def get_location(address):
6
  # try:
app/main_multianimal.py CHANGED
@@ -1,20 +1,20 @@
1
  import gradio as gr
2
  from gradio_modal import Modal
3
 
4
- from utils_json import *
5
- from utils_gallery import save_individual_to_gallery
6
- from maps import get_location
7
  from functools import partial
8
  from dead import show_section_dead
9
  from wounded import show_section_wounded
10
- from circumstances import show_causes
11
- from circumstances_dropdowns import *
12
- from physical_select_animal import show_physical, find_bounding_box
13
- from physical_checkbox import on_select_body_part, hide_physical
14
- from behavior_checkbox import show_behavior, on_select_behavior
15
- from followup_events import save_fe
16
- from style import *
17
- from theme import theme, css
18
 
19
  with gr.Blocks(theme=theme, css=css) as demo:
20
  create_json_all_individuals()
@@ -155,7 +155,7 @@ with gr.Blocks(theme=theme, css=css) as demo:
155
  dropdown_extra_level2_dead.select(on_select_dropdown_extra_level2)
156
  # ---------------------------------------------------------
157
  # Radio Cause Wounded
158
- radio_cause_wounded.change(fn=show_causes,
159
  inputs=[radio_cause_wounded],
160
  outputs=[button_collision_wounded, button_deliberate_destruction_wounded, button_indirect_destruction_wounded, button_natural_cause_wounded,
161
  dropdown_wounded, dropdown_level2_wounded, openfield_level2_wounded, dropdown_extra_level2_wounded]
@@ -257,7 +257,7 @@ with gr.Blocks(theme=theme, css=css) as demo:
257
  show_modal.click(lambda: Modal(visible=True), None, modal)
258
  show_modal.click(create_json_one_individual)
259
  #submit_button.click(save_and_rest_df, inputs=[df], outputs=[df])
260
- #submit_button.click(save_individual_to_gallery)
261
 
262
 
263
 
 
1
  import gradio as gr
2
  from gradio_modal import Modal
3
 
4
+ from utils.utils_json import *
5
+ from gallery import save_individual_to_gallery
6
+ from geolocalisation.maps import get_location
7
  from functools import partial
8
  from dead import show_section_dead
9
  from wounded import show_section_wounded
10
+ from circumstances.circumstances import show_circumstances
11
+ from circumstances.circumstances_dropdowns import *
12
+ from physical.physical_select_animal import show_physical, find_bounding_box
13
+ from physical.physical_checkbox import on_select_body_part, hide_physical
14
+ from behavior.behavior_checkbox import show_behavior, on_select_behavior
15
+ from follow_up.followup_events import save_fe
16
+ from styling.style import *
17
+ from styling.theme import theme, css
18
 
19
  with gr.Blocks(theme=theme, css=css) as demo:
20
  create_json_all_individuals()
 
155
  dropdown_extra_level2_dead.select(on_select_dropdown_extra_level2)
156
  # ---------------------------------------------------------
157
  # Radio Cause Wounded
158
+ radio_cause_wounded.change(fn=show_circumstances,
159
  inputs=[radio_cause_wounded],
160
  outputs=[button_collision_wounded, button_deliberate_destruction_wounded, button_indirect_destruction_wounded, button_natural_cause_wounded,
161
  dropdown_wounded, dropdown_level2_wounded, openfield_level2_wounded, dropdown_extra_level2_wounded]
 
257
  show_modal.click(lambda: Modal(visible=True), None, modal)
258
  show_modal.click(create_json_one_individual)
259
  #submit_button.click(save_and_rest_df, inputs=[df], outputs=[df])
260
+ submit_button.click(save_individual_to_gallery)
261
 
262
 
263
 
app/physical/__init__.py ADDED
File without changes
app/physical/class_physical.py ADDED
@@ -0,0 +1,78 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from pydantic import BaseModel, Field
2
+ from typing import Literal, List, Union, Optional
3
+
4
+ # Define common anomalies as a Literal type
5
+ CommonAnomalies = Literal[
6
+ 'blackened/burnt skin',
7
+ 'blood',
8
+ 'foreign body',
9
+ 'fracture',
10
+ 'injury',
11
+ 'parasite',
12
+ 'swelling',
13
+ 'warty or tumor-like growth, crusts'
14
+ ]
15
+
16
+ # --- Beak-related Anomalies ---
17
+ class BeakAnomaly(BaseModel):
18
+ type: Literal['beak']
19
+ anomaly_type: Literal[
20
+ 'adhesion',
21
+ 'deformation',
22
+ CommonAnomalies
23
+ ]
24
+
25
+ # --- Body-related Anomalies ---
26
+ class BodyAnomaly(BaseModel):
27
+ type: Literal['body']
28
+ anomaly_type: Literal[
29
+ 'emaciation',
30
+ 'fluffed up',
31
+ 'stained feathers',
32
+ CommonAnomalies
33
+ ]
34
+
35
+ # --- Legs-related Anomalies ---
36
+ class LegAnomaly(BaseModel):
37
+ type: Literal['legs']
38
+ anomaly_type: Literal[
39
+ 'missing limb',
40
+ 'deformation',
41
+ CommonAnomalies
42
+ ]
43
+
44
+ # --- Feathers/Wings/Tail-related Anomalies ---
45
+ class FeathersWingsTailAnomaly(BaseModel):
46
+ type: Literal['feathers/wings/tail']
47
+ anomaly_type: Literal[
48
+ 'fluffed up',
49
+ 'feather abnormalities',
50
+ 'stained feathers',
51
+ 'abnormal wing posture',
52
+ 'missing limb',
53
+ CommonAnomalies
54
+ ]
55
+
56
+ # --- Head-related Anomalies (including eyes) ---
57
+ class HeadAnomaly(BaseModel):
58
+ type: Literal['head']
59
+ anomaly_type: Literal[
60
+ 'ear changes',
61
+ 'eye changes',
62
+ 'tilted head',
63
+ CommonAnomalies
64
+ ]
65
+
66
+
67
+ # Union of all possible anomaly types for specific body parts
68
+ AnomalyType = Union[
69
+ BeakAnomaly,
70
+ BodyAnomaly,
71
+ LegAnomaly,
72
+ FeathersWingsTailAnomaly,
73
+ HeadAnomaly
74
+ ]
75
+
76
+ # Main PhysicalAnomaly class that logs anomalies across different body parts
77
+ class PhysicalAnomaly(BaseModel):
78
+ body_part_anomalies: List[AnomalyType] # List of anomalies across different body parts
app/{physical_boxes_define.py β†’ physical/physical_boxes_define.py} RENAMED
File without changes
app/{physical_boxes_map.py β†’ physical/physical_boxes_map.py} RENAMED
File without changes
app/{physical_checkbox.py β†’ physical/physical_checkbox.py} RENAMED
@@ -1,7 +1,7 @@
1
  import gradio as gr
2
- from utils_config import get_custom_config_dropdowns
3
- from utils_checkbox import create_checkbox
4
- from utils_json import add_data_to_individual
5
  #---------------------------------------------------------
6
  def get_body_parts():
7
  dropdown_config = get_custom_config_dropdowns("config_checkbox_physical.json")
 
1
  import gradio as gr
2
+ from utils.utils_config import get_custom_config_dropdowns
3
+ from utils.utils_checkbox import create_checkbox
4
+ from utils.utils_json import add_data_to_individual
5
  #---------------------------------------------------------
6
  def get_body_parts():
7
  dropdown_config = get_custom_config_dropdowns("config_checkbox_physical.json")
app/{physical_select_animal.py β†’ physical/physical_select_animal.py} RENAMED
@@ -1,12 +1,13 @@
1
  import gradio as gr
2
- # from gradio_image_prompter import ImagePrompter
3
- from typing import List
4
- from shapely.geometry import Point
5
- from physical_checkbox import *
6
- from physical_boxes_define import gdf
7
- from utils_visible import set_visible
8
  from dotenv import load_dotenv
9
  import os
 
 
 
 
 
 
 
10
  load_dotenv()
11
  PATH_ASSETS = os.getenv('PATH_ASSETS')
12
 
 
1
  import gradio as gr
 
 
 
 
 
 
2
  from dotenv import load_dotenv
3
  import os
4
+ from typing import List
5
+ from shapely.geometry import Point
6
+
7
+ 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
 
app/styling/__init__.py ADDED
File without changes
app/{style.py β†’ styling/style.py} RENAMED
File without changes
app/{theme.py β†’ styling/theme.py} RENAMED
File without changes
app/tests.py ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+
3
+ # Example initial image list
4
+ images = [
5
+ "https://via.placeholder.com/150/0000FF",
6
+ "https://via.placeholder.com/150/FF0000",
7
+ "https://via.placeholder.com/150/00FF00"
8
+ ]
9
+
10
+ # Function to remove a selected image from the gallery
11
+ def delete_image(selected_image, image_list):
12
+ if selected_image in image_list:
13
+ image_list.remove(selected_image) # Remove the selected image
14
+ return image_list # Return the updated image list
15
+
16
+ # Gradio app
17
+ with gr.Blocks() as demo:
18
+ gallery = gr.Gallery(value=images, label="Gallery") # Gallery of images
19
+ selected_image = gr.Dropdown(choices=images, label="Select Image to Delete") # Dropdown for selection
20
+ delete_button = gr.Button("Delete Selected Image") # Button to delete
21
+
22
+ # When button is clicked, delete the selected image and update gallery
23
+ delete_button.click(fn=delete_image, inputs=[selected_image, gallery], outputs=gallery)
24
+
25
+ demo.launch(server_name="0.0.0.0", server_port=3232)
app/utils/__init__.py ADDED
File without changes
app/{utils_checkbox.py β†’ utils/utils_checkbox.py} RENAMED
File without changes
app/{utils_config.py β†’ utils/utils_config.py} RENAMED
File without changes
app/{utils_json.py β†’ utils/utils_json.py} RENAMED
File without changes
app/{utils_visible.py β†’ utils/utils_visible.py} RENAMED
File without changes
app/wounded.py CHANGED
@@ -1,10 +1,10 @@
1
  import gradio as gr
2
- from circumstances import create_causes
3
- from physical_select_animal import create_bird_anatomy
4
- from physical_checkbox import process_body_parts
5
- from behavior_checkbox import create_behavior_checkbox
6
- from followup_events import create_followup_dropdowns, create_followup_open
7
- from utils_json import add_data_to_individual
8
 
9
  def show_section_wounded(visible):
10
  if visible==True:
@@ -16,7 +16,7 @@ def show_section_wounded(visible):
16
 
17
  gr.Markdown("## Do you know what conditions caused this?", label="description")
18
  radio_cause = gr.Radio(["Yes", "No"], value=None, show_label=False, interactive=True)
19
- button_collision, button_deliberate_destruction, button_indirect_destruction, button_natural_cause, dropdown, dropdown_level2, openfield_level2, dropdown_extra_level2 = create_causes(visible=False)
20
 
21
  gr.Markdown("## Is the bird displaying behavioural changes?" , label="description")
22
  radio_behaviour = gr.Radio(["Yes", "No"], value=None, show_label=False, interactive=True)
 
1
  import gradio as gr
2
+ from circumstances.circumstances import create_circumstances
3
+ from physical.physical_select_animal import create_bird_anatomy
4
+ from physical.physical_checkbox import process_body_parts
5
+ from behavior.behavior_checkbox import create_behavior_checkbox
6
+ from follow_up.followup_events import create_followup_dropdowns, create_followup_open
7
+ from utils.utils_json import add_data_to_individual
8
 
9
  def show_section_wounded(visible):
10
  if visible==True:
 
16
 
17
  gr.Markdown("## Do you know what conditions caused this?", label="description")
18
  radio_cause = gr.Radio(["Yes", "No"], value=None, show_label=False, interactive=True)
19
+ button_collision, button_deliberate_destruction, button_indirect_destruction, button_natural_cause, dropdown, dropdown_level2, openfield_level2, dropdown_extra_level2 = create_circumstances(visible=False)
20
 
21
  gr.Markdown("## Is the bird displaying behavioural changes?" , label="description")
22
  radio_behaviour = gr.Radio(["Yes", "No"], value=None, show_label=False, interactive=True)