fix: using gallery
Browse files- app/main_multianimal.py +4 -2
- app/{utils_df.py → utils_gallery.py} +19 -18
app/main_multianimal.py
CHANGED
@@ -2,7 +2,7 @@ import gradio as gr
|
|
2 |
from gradio_modal import Modal
|
3 |
|
4 |
from utils_json import *
|
5 |
-
from
|
6 |
from maps import get_location
|
7 |
from functools import partial
|
8 |
from dead import show_section_dead
|
@@ -26,6 +26,7 @@ with gr.Blocks(theme=theme, css=css) as demo:
|
|
26 |
label="Gallery of Records", elem_id="gallery",
|
27 |
columns=[1], rows=[1],
|
28 |
object_fit="contain", height="auto", interactive=False)
|
|
|
29 |
with Modal(visible=False) as modal:
|
30 |
# ---------------------------------------------------------
|
31 |
# Intro Text
|
@@ -213,7 +214,8 @@ with gr.Blocks(theme=theme, css=css) as demo:
|
|
213 |
# outputs=[df])
|
214 |
button_df.click(save_individual_to_gallery,
|
215 |
inputs=[gallery],
|
216 |
-
outputs=[gallery]
|
|
|
217 |
button_df.click(lambda: Modal(visible=False), None, modal)
|
218 |
|
219 |
# ---------------------------------------------------------
|
|
|
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
|
|
|
26 |
label="Gallery of Records", elem_id="gallery",
|
27 |
columns=[1], rows=[1],
|
28 |
object_fit="contain", height="auto", interactive=False)
|
29 |
+
|
30 |
with Modal(visible=False) as modal:
|
31 |
# ---------------------------------------------------------
|
32 |
# Intro Text
|
|
|
214 |
# outputs=[df])
|
215 |
button_df.click(save_individual_to_gallery,
|
216 |
inputs=[gallery],
|
217 |
+
outputs=[gallery]
|
218 |
+
)
|
219 |
button_df.click(lambda: Modal(visible=False), None, modal)
|
220 |
|
221 |
# ---------------------------------------------------------
|
app/{utils_df.py → utils_gallery.py}
RENAMED
@@ -34,9 +34,10 @@ def match_data_to_fields(fields, one_individual):
|
|
34 |
new_row[key] = "NA"
|
35 |
return new_row
|
36 |
|
|
|
|
|
37 |
def process_animals(all_animals):
|
38 |
processed_animals = []
|
39 |
-
print(len(all_animals))
|
40 |
for _, animal in all_animals.items():
|
41 |
image = np.array(animal["image"])
|
42 |
caption = []
|
@@ -52,23 +53,23 @@ def process_animals(all_animals):
|
|
52 |
caption.extend([" | Wounded: " + animal["wounded"]])
|
53 |
elif key=="dead" and val=="True":
|
54 |
caption.extend([" | Dead: " + animal["dead"]])
|
55 |
-
elif key=="circumstance":
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
elif key=="behavior":
|
63 |
-
|
64 |
-
elif "physical_changes" in key:
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
caption_str = " ".join(caption)
|
73 |
animal = (image, caption_str)
|
74 |
processed_animals.append(animal)
|
|
|
34 |
new_row[key] = "NA"
|
35 |
return new_row
|
36 |
|
37 |
+
|
38 |
+
|
39 |
def process_animals(all_animals):
|
40 |
processed_animals = []
|
|
|
41 |
for _, animal in all_animals.items():
|
42 |
image = np.array(animal["image"])
|
43 |
caption = []
|
|
|
53 |
caption.extend([" | Wounded: " + animal["wounded"]])
|
54 |
elif key=="dead" and val=="True":
|
55 |
caption.extend([" | Dead: " + animal["dead"]])
|
56 |
+
# elif key=="circumstance":
|
57 |
+
# caption.extend([" | Circumstances: " ,
|
58 |
+
# animal["circumstance"],
|
59 |
+
# animal["circumstance_dropdown_level1"],
|
60 |
+
# animal["circumstance_dropdown_level2"],
|
61 |
+
# animal["circumstance_openfield_level2"],
|
62 |
+
# animal["circumstance_dropdown_extra_level2"]])
|
63 |
+
# elif key=="behavior":
|
64 |
+
# caption.extend([" | Behavior: ", animal[key]])
|
65 |
+
# elif "physical_changes" in key:
|
66 |
+
# if not(" | Physical Changes: " in caption) :
|
67 |
+
# caption.extend([" | Physical Changes: ",
|
68 |
+
# "Beak: " + animal["physical_changes_beak"],
|
69 |
+
# "Body: " + animal["physical_changes_body"],
|
70 |
+
# "Head: " + animal["physical_changes_head"],
|
71 |
+
# "Feathers: " + animal["physical_changes_feathers"],
|
72 |
+
# "Legs: " + animal["physical_changes_legs"]])
|
73 |
caption_str = " ".join(caption)
|
74 |
animal = (image, caption_str)
|
75 |
processed_animals.append(animal)
|