feat: all dropdowns for dead and wounded
Browse filesFiles changed (6)
- app/__init__.pyAdded
- app/dead.pyAdded+12
- app/dropdowns.pyAdded+32
- app/main.py+24-79
- app/top_section.pyAdded+30
- app/wounded.pyAdded+13
123456789101112import gradio as grfrom top_section import create_top_section, create_dropdown
def show_section_dead(visible): with gr.Column(visible=visible) as section_dead: gr.Markdown("# Dead") gr.Markdown("Please describe the cause of death") image_row, button_collision, button_deliberate_destruction, button_indirect_destruction, button_natural_cause = create_top_section(visible) dropdown_row, dropdown = create_dropdown(visible)
return section_dead, button_collision, button_deliberate_destruction, button_indirect_destruction, button_natural_cause, dropdown1234567891011121314151617181920212223242526272829303132import gradio as gr
def dropdown_collision(): return gr.Dropdown(choices=["Road vehicle", "Train", "Aircraft", "Boat", "Other", "Unknown"], label="Collision with a means of transport", interactive=True)
def dropdown_deliberate_destruction(): return gr.Dropdown(choices=["Hunting", "Trap", "Poisoning", "Removal or direct capture", "Fishing", "Other", "Unkown"], label="Destruction / Deliberatly removed", interactive=True)
def dropdown_indirect_destruction(): return gr.Dropdown(choices=["pylone and electric grid", "windfarm", "other collision", "fall", "development work", "pollution / contamination", "agricultural net protection", "vegetal / forest work", "other", "unknown" ], label="Indirect destruction", interactive=True)
def dropdown_natural_cause(): return gr.Dropdown(choices=["predation", "weather", "natural disaster", "nest fall", "stranding due to exhaustion", "disease/parasite", "accidental drowning", "other", "unknown" ], label="Indirect destruction", interactive=True) 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737413 unmodified lines888990919293949596979899100101102103104105106107108109110111import gradio as grfrom functools import partialdef truck_dropdown():return gr.Dropdown(choices=["Road vehicle", "Train", "Aircraft", "Boat", "Other", "Unknown"], label="Collision with a means of transport", interactive=True)def truckb_dropdown():return gr.Dropdown(choices=["Hunting", "Trap", "Poisoning", "Removal or direct capture", "Fishing", "Other", "Unkown"], label="Destruction / Deliberatly removed", interactive=True)def show_section_dead(visible):with gr.Column(visible=visible) as section_dead:gr.Markdown("# Dead")gr.Markdown("Please describe the cause of death")with gr.Row():with gr.Column(scale=1, min_width="100px"):img1 = gr.Image(value='./assets/van.png', show_download_button=False, show_label=False)butt1 = gr.Button("Collision with a means of transport", visible=visible)with gr.Column(scale=1, min_width="100px"):img1 = gr.Image(value='./assets/destruction.png', show_download_button=False, show_label=False)butt2 = gr.Button("Destruction / Deliberatly removed", visible=visible)with gr.Row():with gr.Column(scale=1, min_width="100px"):img3 = gr.Image(value='./assets/indirect.png', show_download_button=False, show_label=False)butt3 = gr.Button("Indirect destruction", visible=visible)with gr.Column(scale=1, min_width="100px"):img4 = gr.Image(value='./assets/natural.png', show_download_button=False, show_label=False)butt4 = gr.Button("Natural cause", visible=visible)with gr.Row():dropdown = gr.Dropdown(choices=[], label="Dropdown", interactive=True, visible=visible)return section_dead, butt1, butt2, butt3, butt4, dropdowndef show_section_wounded(visible):#with gr.Tab("Wounded Information"):with gr.Column(visible=visible) as wounded_section:gr.Markdown("# Please describe the cause of wound")with gr.Row():with gr.Column(scale=1, min_width="100px"):img1 = gr.Image(value='./assets/van.png', show_download_button=False, show_label=False)butt1 = gr.Button("Collision with a means of transport")with gr.Column(scale=1, min_width="100px"):img1 = gr.Image(value='./assets/destruction.png', show_download_button=False, show_label=False)butt2 = gr.Button("Destruction / Deliberatly removed")with gr.Row():with gr.Column(scale=1, min_width="100px"):img3 = gr.Image(value='./assets/indirect.png', show_download_button=False, show_label=False)butt3 = gr.Button("Indirect destruction")with gr.Column(scale=1, min_width="100px"):img4 = gr.Image(value='./assets/natural.png', show_download_button=False, show_label=False)butt4 = gr.Button("Natural cause")with gr.Row():dropdown = gr.Dropdown(choices=[], label="Dropdown", interactive=True)# Change variables and namesreturn wounded_sectionwith gr.Blocks() as demo:with gr.Row():13 unmodified linesbutt_wounded = gr.Button("Wounded")# Initiate sectionssection_dead, butt1, butt2, butt3, butt4, dropdown = show_section_dead(False)section_wounded = show_section_wounded(False)# Dead Button Logicpartial_show_section_dead = partial(show_section_dead, True)partial_hide_section_wounded = partial(show_section_wounded, False)butt_dead.click(partial_show_section_dead, inputs=None, outputs=[section_dead, butt1, butt2, butt3, butt4, dropdown])butt_dead.click(partial_hide_section_wounded, inputs=None, outputs=section_wounded)# Wounded Button Logicpartial_show_section_wounded = partial(show_section_wounded, True)partial_hide_section_dead = partial(show_section_dead, False)butt_wounded.click(partial_show_section_wounded, inputs=None, outputs=section_wounded)butt_wounded.click(partial_hide_section_dead, inputs=None, outputs=[section_dead, butt1, butt2, butt3, butt4, dropdown])butt1.click(truck_dropdown, outputs=dropdown)butt2.click(truckb_dropdown, outputs=dropdown)# section_dead.with gr.Column(scale=1):subbutt = gr.Button("Submit")1234567813 unmodified lines2223242526272829303132333435363738394041424344454647484950515253545556import gradio as grfrom functools import partialfrom dead import show_section_deadfrom wounded import show_section_woundedfrom dropdowns import *with gr.Blocks() as demo:with gr.Row():13 unmodified linesbutt_wounded = gr.Button("Wounded")# Initiate sectionssection_dead, button_collision, button_deliberate_destruction, button_indirect_destruction, button_natural_cause, dropdown = show_section_dead(False)section_wounded, button_collision, button_deliberate_destruction, button_indirect_destruction, button_natural_cause, dropdown = show_section_wounded(False)# Dead Button Logicpartial_show_section_dead = partial(show_section_dead, True)partial_hide_section_wounded = partial(show_section_wounded, False)butt_dead.click(partial_show_section_dead, inputs=None, outputs=[section_dead,button_collision, button_deliberate_destruction, button_indirect_destruction, button_natural_cause,dropdown])butt_dead.click(partial_hide_section_wounded, inputs=None, outputs=[section_wounded,button_collision, button_deliberate_destruction, button_indirect_destruction, button_natural_cause,dropdown])# Wounded Button Logicpartial_show_section_wounded = partial(show_section_wounded, True)partial_hide_section_dead = partial(show_section_dead, False)butt_wounded.click(partial_show_section_wounded, inputs=None, outputs=[section_wounded,button_collision, button_deliberate_destruction, button_indirect_destruction, button_natural_cause,dropdown])butt_wounded.click(partial_hide_section_dead, inputs=None, outputs=[section_dead,button_collision, button_deliberate_destruction, button_indirect_destruction, button_natural_cause,dropdown])# Dropdownsbutton_collision.click(dropdown_collision, outputs=dropdown)button_deliberate_destruction.click(dropdown_deliberate_destruction, outputs=dropdown)button_indirect_destruction.click(dropdown_indirect_destruction, outputs=dropdown)button_natural_cause.click(dropdown_natural_cause, outputs=dropdown)with gr.Column(scale=1):subbutt = gr.Button("Submit")
123456789101112131415161718192021222324252627282930import gradio as gr
def create_top_section(visible): with gr.Row() as image_row: with gr.Column(scale=1, min_width="50px"): img1 = gr.Image(value='app/assets/van.png', show_download_button=False, show_label=False) button_collision = gr.Button("Collision with a means of transport", visible=visible) with gr.Column(scale=1, min_width="50px"): img2 = gr.Image(value='app/assets/destruction.png', show_download_button=False, show_label=False) button_deliberate_destruction = gr.Button("Destruction / Deliberatly removed", visible=visible)
#with gr.Row(): with gr.Column(scale=1, min_width="50px"): img3 = gr.Image(value='app/assets/indirect.png', show_download_button=False, show_label=False) button_indirect_destruction = gr.Button("Indirect destruction", visible=visible)
with gr.Column(scale=1, min_width="50px"): img4 = gr.Image(value='app/assets/natural.png', show_download_button=False, show_label=False) button_natural_cause = gr.Button("Natural cause", visible=visible) return image_row, button_collision, button_deliberate_destruction, button_indirect_destruction, button_natural_cause
def create_dropdown(visible): with gr.Row() as dropdown_row: dropdown = gr.Dropdown(choices=[], label="Dropdown", interactive=True, visible=visible) return dropdown_row, dropdown
12345678910111213import gradio as grfrom top_section import create_top_section, create_dropdown
def show_section_wounded(visible): #with gr.Tab("Wounded Information"): with gr.Column(visible=visible) as wounded_section: gr.Markdown("# Please describe the cause of wound")
image_row, button_collision, button_deliberate_destruction, button_indirect_destruction, button_natural_cause = create_top_section(visible) dropdown_row, dropdown = create_dropdown(visible)
# Change variables and names return wounded_section, button_collision, button_deliberate_destruction, button_indirect_destruction, button_natural_cause, dropdownapp/__init__.pyAdded
app/dead.pyAdded+12
app/dropdowns.pyAdded+32
app/main.py+24-79
app/top_section.pyAdded+30
app/wounded.pyAdded+13