OCEANAI / app /tabs.py
ElenaRyumina's picture
v0.3.0 (#3)
d0f716d verified
raw
history blame
3.29 kB
"""
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,
)
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,
)
calculate_practical_task = button(
config_data.OtherMessages_CALCULATE_PRACTICAL_TASK,
True,
1,
True,
"calculate_practical_task",
)
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,
calculate_practical_task,
practical_subtasks_selected,
practical_tasks_column,
in_development,
)
def about_authors_tab():
return gr.Markdown(value=AUTHORS)