Spaces:
Running
Running
File size: 3,566 Bytes
aa2aec1 6d7dc58 aa2aec1 6d7dc58 aa2aec1 6d7dc58 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 |
"""
File: practical_task_sorted.py
Author: Elena Ryumina and Dmitry Ryumin
Description: Event handler for the practical task sorted to the Gradio app.
License: MIT License
"""
import gradio as gr
from pathlib import Path
# Importing necessary components for the Gradio app
from app.video_metadata import video_metadata
from app.components import video_create_ui, textbox_create_ui
def event_handler_practical_task_sorted(
files, practical_task_sorted, evt_data: gr.SelectData
):
person_id = int(practical_task_sorted.iloc[evt_data.index[0]]["Person ID"]) - 1
if evt_data.index[0] == 0:
label = "Best"
else:
label = ""
label += " Person ID"
if Path(files[person_id]).name in video_metadata:
person_metadata_list = video_metadata[Path(files[person_id]).name]
person_metadata = (
gr.Column(visible=True),
gr.Row(visible=True),
gr.Row(visible=True),
gr.Image(visible=True),
textbox_create_ui(
person_metadata_list[0],
"text",
"First name",
None,
None,
1,
True,
False,
True,
False,
1,
False,
),
gr.Row(visible=True),
gr.Image(visible=True),
textbox_create_ui(
person_metadata_list[1],
"text",
"Last name",
None,
None,
1,
True,
False,
True,
False,
1,
False,
),
gr.Row(visible=True),
gr.Row(visible=True),
gr.Image(visible=True),
textbox_create_ui(
person_metadata_list[2],
"email",
"Email",
None,
None,
1,
True,
False,
True,
False,
1,
False,
),
gr.Row(visible=True),
gr.Image(visible=True),
textbox_create_ui(
person_metadata_list[3],
"text",
"Phone number",
None,
None,
1,
True,
False,
True,
False,
1,
False,
),
)
else:
person_metadata = (
gr.Column(visible=False),
gr.Row(visible=False),
gr.Row(visible=False),
gr.Image(visible=False),
textbox_create_ui(visible=False),
gr.Row(visible=False),
gr.Image(visible=False),
textbox_create_ui(visible=False),
gr.Row(visible=False),
gr.Row(visible=False),
gr.Image(visible=False),
textbox_create_ui(visible=False),
gr.Row(visible=False),
gr.Image(visible=False),
textbox_create_ui(visible=False),
)
existing_tuple = (
gr.Column(visible=True),
video_create_ui(
value=files[person_id],
file_name=Path(files[person_id]).name,
label=f"{label} - " + str(person_id + 1),
visible=True,
elem_classes="video-sorted-container",
),
)
return existing_tuple + person_metadata
|