Spaces:
Running
Running
File size: 5,507 Bytes
f51c1fd d0f716d f51c1fd d0f716d 4aa0743 f51c1fd 42c4f80 f51c1fd 42c4f80 f51c1fd 42c4f80 f51c1fd 42c4f80 d0f716d 4aa0743 d0f716d 4aa0743 d0f716d 4aa0743 b0f25b3 d0f716d 42c4f80 d0f716d 4aa0743 d0f716d 4aa0743 b0f25b3 4aa0743 d0f716d 42c4f80 f51c1fd |
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 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 |
"""
File: tabs.py
Author: Elena Ryumina and Dmitry Ryumin
Description: Gradio app tabs - Contains the definition of various tabs for the Gradio app interface.
License: MIT License
"""
import gradio as gr
# Importing necessary components for the Gradio app
from app.description import DESCRIPTION
from app.authors import AUTHORS
from app.config import config_data
from app.practical_tasks import supported_practical_tasks
from app.components import (
html_message,
files_create_ui,
video_create_ui,
button,
dataframe,
radio_create_ui,
threshold_create_ui,
dropdown_create_ui,
)
def app_tab():
gr.Markdown(value=DESCRIPTION)
with gr.Row():
files = files_create_ui()
video = video_create_ui()
with gr.Row():
examples = button(
config_data.OtherMessages_EXAMPLES_APP, True, 1, True, "examples_oceanai"
)
calculate_pt_scores = button(
config_data.OtherMessages_CALCULATE_PT_SCORES,
False,
3,
True,
"calculate_oceanai",
)
clear_app = button(
config_data.OtherMessages_CLEAR_APP, False, 1, True, "clear_oceanai"
)
notifications = html_message(config_data.InformationMessages_NOTI_VIDEOS, False)
pt_scores = dataframe(visible=False)
csv_pt_scores = files_create_ui(
None,
"single",
[".csv"],
config_data.OtherMessages_EXPORT_PT_SCORES,
True,
False,
False,
"csv-container",
)
first_practical_task = next(iter(supported_practical_tasks))
with gr.Column(scale=1, visible=False, render=True) as practical_tasks_column:
practical_tasks = radio_create_ui(
first_practical_task,
config_data.Labels_PRACTICAL_TASKS_LABEL,
list(map(str, supported_practical_tasks.keys())),
config_data.InformationMessages_PRACTICAL_TASKS_INFO,
True,
True,
)
practical_subtasks = radio_create_ui(
supported_practical_tasks[first_practical_task][0],
config_data.Labels_PRACTICAL_SUBTASKS_LABEL,
supported_practical_tasks[first_practical_task],
config_data.InformationMessages_PRACTICAL_SUBTASKS_INFO,
True,
True,
)
with gr.Row(
visible=False,
render=True,
variant="default",
elem_classes="settings-container",
) as settings_practical_tasks:
threshold_professional_skills = threshold_create_ui(
value=0.5,
minimum=0.0,
maximum=1.0,
step=0.01,
label=config_data.Labels_THRESHOLD_PROFESSIONAL_SKILLS_LABEL,
info=config_data.InformationMessages_THRESHOLD_PROFESSIONAL_SKILLS_INFO,
show_label=True,
interactive=True,
visible=False,
render=True,
elem_classes="number-container",
)
dropdown_professional_skills = dropdown_create_ui(
label=f"Professional skills ({len(config_data.Settings_DROPDOWN_PROFESSIONAL_SKILLS)})",
info=config_data.InformationMessages_DROPDOWN_PROFESSIONAL_SKILLS_INFO,
choices=config_data.Settings_DROPDOWN_PROFESSIONAL_SKILLS,
value=config_data.Settings_DROPDOWN_PROFESSIONAL_SKILLS[0],
visible=False,
elem_classes="dropdown-container",
)
calculate_practical_task = button(
config_data.OtherMessages_CALCULATE_PRACTICAL_TASK,
True,
1,
False,
"calculate_practical_task",
)
with gr.Row(
visible=False,
render=True,
variant="default",
) as sorted_videos:
with gr.Column(scale=1, visible=False, render=True) as sorted_videos_column:
practical_task_sorted = dataframe(visible=False)
csv_practical_task_sorted = files_create_ui(
None,
"single",
[".csv"],
config_data.OtherMessages_EXPORT_PS,
True,
False,
False,
"csv-container",
)
video_sorted = video_create_ui(visible=False)
practical_subtasks_selected = gr.JSON(
value={
str(task): supported_practical_tasks.get(task, [None])[0]
for task in supported_practical_tasks.keys()
},
visible=False,
render=True,
)
in_development = html_message(
config_data.InformationMessages_NOTI_IN_DEV, False, False
)
return (
notifications,
files,
video,
examples,
calculate_pt_scores,
clear_app,
pt_scores,
csv_pt_scores,
practical_tasks,
practical_subtasks,
settings_practical_tasks,
threshold_professional_skills,
dropdown_professional_skills,
calculate_practical_task,
practical_subtasks_selected,
practical_tasks_column,
sorted_videos,
sorted_videos_column,
practical_task_sorted,
csv_practical_task_sorted,
video_sorted,
in_development,
)
def about_authors_tab():
return gr.Markdown(value=AUTHORS)
|