Spaces:
Running
Running
File size: 3,361 Bytes
f51c1fd b0f25b3 20b6a53 aa2aec1 b0f25b3 f51c1fd 42c4f80 b0f25b3 f51c1fd b0f25b3 f51c1fd 42c4f80 d0f716d b0f25b3 aa2aec1 20b6a53 aa2aec1 20b6a53 b0f25b3 aa2aec1 b0f25b3 aa2aec1 b0f25b3 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 |
"""
File: clear_blocks.py
Author: Elena Ryumina and Dmitry Ryumin
Description: Event handler for clearing Gradio app blocks and components.
License: MIT License
"""
import gradio as gr
# Importing necessary components for the Gradio app
from app.oceanai_init import b5
from app.config import config_data
from app.practical_tasks import supported_practical_tasks
from app.components import (
html_message,
button,
dataframe,
files_create_ui,
radio_create_ui,
number_create_ui,
dropdown_create_ui,
video_create_ui,
)
def event_handler_calculate_pt_scores_blocks(files, evt_data: gr.EventData):
_ = evt_data.target.__class__.__name__
out = False
b5.get_avt_predictions_gradio(
paths=files, url_accuracy="", accuracy=False, lang="en", out=out
)
b5.df_files_.to_csv(config_data.Filenames_PT_SCORES)
first_practical_task = next(iter(supported_practical_tasks))
df_files = b5.df_files_.copy()
df_files.reset_index(inplace=True)
return (
html_message(config_data.InformationMessages_NOTI_VIDEOS, False, False),
dataframe(
headers=df_files.columns.tolist(),
values=df_files.values.tolist(),
visible=True,
),
files_create_ui(
config_data.Filenames_PT_SCORES,
"single",
[".csv"],
config_data.OtherMessages_EXPORT_PT_SCORES,
True,
False,
True,
"csv-container",
),
gr.Column(visible=True),
radio_create_ui(
first_practical_task,
"Practical tasks",
list(map(str, supported_practical_tasks.keys())),
config_data.InformationMessages_PRACTICAL_TASKS_INFO,
True,
True,
),
radio_create_ui(
supported_practical_tasks[first_practical_task][0],
"Practical subtasks",
supported_practical_tasks[first_practical_task],
config_data.InformationMessages_PRACTICAL_SUBTASKS_INFO,
True,
True,
),
gr.JSON(
value={
str(task): supported_practical_tasks.get(task, [None])[0]
for task in supported_practical_tasks.keys()
},
visible=False,
render=True,
),
gr.Column(visible=False),
number_create_ui(visible=False),
dropdown_create_ui(visible=False),
number_create_ui(visible=False),
number_create_ui(visible=False),
number_create_ui(visible=False),
number_create_ui(visible=False),
number_create_ui(visible=False),
number_create_ui(visible=False),
button(
config_data.OtherMessages_CALCULATE_PRACTICAL_TASK,
True,
1,
True,
"calculate_practical_task",
),
gr.Row(visible=False),
gr.Column(visible=False),
dataframe(visible=False),
files_create_ui(
None,
"single",
[".csv"],
config_data.OtherMessages_EXPORT_PS,
True,
False,
False,
"csv-container",
),
video_create_ui(visible=False),
html_message(config_data.InformationMessages_NOTI_IN_DEV, False, False),
)
|