Spaces:
Running
Running
v0.9.0
#19
by
DmitryRyumin
- opened
- app.css +1 -0
- app/components.py +6 -2
- app/description.py +2 -2
- app/event_handlers/calculate_pt_scores_blocks.py +7 -3
- app/event_handlers/clear_blocks.py +8 -5
- app/event_handlers/event_handlers.py +21 -4
- app/event_handlers/files.py +42 -11
- app/event_handlers/languages.py +47 -9
- app/tabs.py +15 -4
- app/utils.py +20 -0
- config.toml +8 -6
app.css
CHANGED
@@ -161,6 +161,7 @@ div.languages-container > div.country_flags button {
|
|
161 |
}
|
162 |
|
163 |
div.languages-container > div.country_flags div.image-container {
|
|
|
164 |
width: fit-content;
|
165 |
}
|
166 |
|
|
|
161 |
}
|
162 |
|
163 |
div.languages-container > div.country_flags div.image-container {
|
164 |
+
display: contents;
|
165 |
width: fit-content;
|
166 |
}
|
167 |
|
app/components.py
CHANGED
@@ -24,7 +24,9 @@ def files_create_ui(
|
|
24 |
value: Union[str, List[str], Callable, None] = None,
|
25 |
file_count: str = "multiple",
|
26 |
file_types: List = ["video"],
|
27 |
-
label: str = config_data.OtherMessages_VIDEO_FILES
|
|
|
|
|
28 |
show_label: bool = True,
|
29 |
interactive: bool = True,
|
30 |
visible: bool = True,
|
@@ -44,7 +46,9 @@ def files_create_ui(
|
|
44 |
|
45 |
def video_create_ui(
|
46 |
value: Optional[str] = None,
|
47 |
-
label: str =
|
|
|
|
|
48 |
file_name: Optional[str] = None,
|
49 |
show_label: bool = True,
|
50 |
interactive: bool = False,
|
|
|
24 |
value: Union[str, List[str], Callable, None] = None,
|
25 |
file_count: str = "multiple",
|
26 |
file_types: List = ["video"],
|
27 |
+
label: str = config_data.OtherMessages_VIDEO_FILES[
|
28 |
+
config_data.AppSettings_DEFAULT_LANG_ID
|
29 |
+
],
|
30 |
show_label: bool = True,
|
31 |
interactive: bool = True,
|
32 |
visible: bool = True,
|
|
|
46 |
|
47 |
def video_create_ui(
|
48 |
value: Optional[str] = None,
|
49 |
+
label: str = config_data.OtherMessages_VIDEO_PLAYER[
|
50 |
+
config_data.AppSettings_DEFAULT_LANG_ID
|
51 |
+
],
|
52 |
file_name: Optional[str] = None,
|
53 |
show_label: bool = True,
|
54 |
interactive: bool = False,
|
app/description.py
CHANGED
@@ -21,11 +21,11 @@ DESCRIPTIONS = [
|
|
21 |
TEMPLATE.format(
|
22 |
description=config_data.InformationMessages_DESCRIPTIONS[0],
|
23 |
version=config_data.AppSettings_APP_VERSION,
|
24 |
-
version_label=
|
25 |
),
|
26 |
TEMPLATE.format(
|
27 |
description=config_data.InformationMessages_DESCRIPTIONS[1],
|
28 |
version=config_data.AppSettings_APP_VERSION,
|
29 |
-
version_label=
|
30 |
),
|
31 |
]
|
|
|
21 |
TEMPLATE.format(
|
22 |
description=config_data.InformationMessages_DESCRIPTIONS[0],
|
23 |
version=config_data.AppSettings_APP_VERSION,
|
24 |
+
version_label=config_data.Labels_APP_VERSION[0],
|
25 |
),
|
26 |
TEMPLATE.format(
|
27 |
description=config_data.InformationMessages_DESCRIPTIONS[1],
|
28 |
version=config_data.AppSettings_APP_VERSION,
|
29 |
+
version_label=config_data.Labels_APP_VERSION[1],
|
30 |
),
|
31 |
]
|
app/event_handlers/calculate_pt_scores_blocks.py
CHANGED
@@ -11,7 +11,7 @@ import gradio as gr
|
|
11 |
from app.oceanai_init import b5
|
12 |
from app.config import config_data
|
13 |
from app.description_steps import STEP_2
|
14 |
-
from app.utils import read_csv_file, extract_profession_weights
|
15 |
from app.practical_tasks import supported_practical_tasks
|
16 |
from app.components import (
|
17 |
html_message,
|
@@ -26,9 +26,11 @@ from app.components import (
|
|
26 |
)
|
27 |
|
28 |
|
29 |
-
def event_handler_calculate_pt_scores_blocks(files, evt_data: gr.EventData):
|
30 |
_ = evt_data.target.__class__.__name__
|
31 |
|
|
|
|
|
32 |
out = False
|
33 |
b5.get_avt_predictions_gradio(
|
34 |
paths=files, url_accuracy="", accuracy=False, lang="en", out=out
|
@@ -154,7 +156,9 @@ def event_handler_calculate_pt_scores_blocks(files, evt_data: gr.EventData):
|
|
154 |
)
|
155 |
|
156 |
return (
|
157 |
-
html_message(
|
|
|
|
|
158 |
dataframe(
|
159 |
headers=df_files.columns.tolist(),
|
160 |
values=df_files.values.tolist(),
|
|
|
11 |
from app.oceanai_init import b5
|
12 |
from app.config import config_data
|
13 |
from app.description_steps import STEP_2
|
14 |
+
from app.utils import read_csv_file, extract_profession_weights, get_language_settings
|
15 |
from app.practical_tasks import supported_practical_tasks
|
16 |
from app.components import (
|
17 |
html_message,
|
|
|
26 |
)
|
27 |
|
28 |
|
29 |
+
def event_handler_calculate_pt_scores_blocks(language, files, evt_data: gr.EventData):
|
30 |
_ = evt_data.target.__class__.__name__
|
31 |
|
32 |
+
lang_id, _ = get_language_settings(language)
|
33 |
+
|
34 |
out = False
|
35 |
b5.get_avt_predictions_gradio(
|
36 |
paths=files, url_accuracy="", accuracy=False, lang="en", out=out
|
|
|
156 |
)
|
157 |
|
158 |
return (
|
159 |
+
html_message(
|
160 |
+
config_data.InformationMessages_NOTI_VIDEOS[lang_id], False, False
|
161 |
+
),
|
162 |
dataframe(
|
163 |
headers=df_files.columns.tolist(),
|
164 |
values=df_files.values.tolist(),
|
app/event_handlers/clear_blocks.py
CHANGED
@@ -22,23 +22,26 @@ from app.components import (
|
|
22 |
dropdown_create_ui,
|
23 |
textbox_create_ui,
|
24 |
)
|
|
|
25 |
|
26 |
|
27 |
-
def event_handler_clear_blocks():
|
|
|
|
|
28 |
first_practical_task = next(iter(supported_practical_tasks))
|
29 |
|
30 |
return (
|
31 |
-
html_message(config_data.InformationMessages_NOTI_VIDEOS, False),
|
32 |
files_create_ui(
|
33 |
label="{} ({})".format(
|
34 |
-
config_data.OtherMessages_VIDEO_FILES,
|
35 |
", ".join(config_data.Settings_SUPPORTED_VIDEO_EXT),
|
36 |
),
|
37 |
file_types=[f".{ext}" for ext in config_data.Settings_SUPPORTED_VIDEO_EXT],
|
38 |
),
|
39 |
video_create_ui(),
|
40 |
button(
|
41 |
-
config_data.OtherMessages_CALCULATE_PT_SCORES,
|
42 |
False,
|
43 |
3,
|
44 |
"./images/calculate_pt_scores.ico",
|
@@ -46,7 +49,7 @@ def event_handler_clear_blocks():
|
|
46 |
"calculate_oceanai",
|
47 |
),
|
48 |
button(
|
49 |
-
config_data.OtherMessages_CLEAR_APP,
|
50 |
False,
|
51 |
1,
|
52 |
"./images/clear.ico",
|
|
|
22 |
dropdown_create_ui,
|
23 |
textbox_create_ui,
|
24 |
)
|
25 |
+
from app.utils import get_language_settings
|
26 |
|
27 |
|
28 |
+
def event_handler_clear_blocks(language):
|
29 |
+
lang_id, _ = get_language_settings(language)
|
30 |
+
|
31 |
first_practical_task = next(iter(supported_practical_tasks))
|
32 |
|
33 |
return (
|
34 |
+
html_message(config_data.InformationMessages_NOTI_VIDEOS[lang_id], False),
|
35 |
files_create_ui(
|
36 |
label="{} ({})".format(
|
37 |
+
config_data.OtherMessages_VIDEO_FILES[lang_id],
|
38 |
", ".join(config_data.Settings_SUPPORTED_VIDEO_EXT),
|
39 |
),
|
40 |
file_types=[f".{ext}" for ext in config_data.Settings_SUPPORTED_VIDEO_EXT],
|
41 |
),
|
42 |
video_create_ui(),
|
43 |
button(
|
44 |
+
config_data.OtherMessages_CALCULATE_PT_SCORES[lang_id],
|
45 |
False,
|
46 |
3,
|
47 |
"./images/calculate_pt_scores.ico",
|
|
|
49 |
"calculate_oceanai",
|
50 |
),
|
51 |
button(
|
52 |
+
config_data.OtherMessages_CLEAR_APP[lang_id],
|
53 |
False,
|
54 |
1,
|
55 |
"./images/clear.ico",
|
app/event_handlers/event_handlers.py
CHANGED
@@ -12,6 +12,7 @@ from app.event_handlers.languages import event_handler_languages
|
|
12 |
from app.event_handlers.files import (
|
13 |
event_handler_files,
|
14 |
event_handler_files_select,
|
|
|
15 |
)
|
16 |
from app.event_handlers.examples_blocks import event_handler_examples_blocks
|
17 |
from app.event_handlers.clear_blocks import event_handler_clear_blocks
|
@@ -100,7 +101,7 @@ def setup_app_event_handlers(
|
|
100 |
# Events
|
101 |
languages.select(
|
102 |
fn=event_handler_languages,
|
103 |
-
inputs=[languages, files],
|
104 |
outputs=[
|
105 |
description,
|
106 |
step_1,
|
@@ -111,18 +112,33 @@ def setup_app_event_handlers(
|
|
111 |
tab3,
|
112 |
tab4,
|
113 |
files,
|
|
|
|
|
|
|
|
|
|
|
114 |
],
|
115 |
queue=True,
|
116 |
)
|
117 |
files.change(
|
118 |
event_handler_files,
|
119 |
-
[
|
|
|
|
|
|
|
|
|
120 |
[notifications, video, calculate_pt_scores, clear_app],
|
121 |
queue=True,
|
122 |
)
|
123 |
files.select(
|
124 |
event_handler_files_select,
|
125 |
-
[files],
|
|
|
|
|
|
|
|
|
|
|
|
|
126 |
[video],
|
127 |
queue=True,
|
128 |
)
|
@@ -130,6 +146,7 @@ def setup_app_event_handlers(
|
|
130 |
triggers=[calculate_pt_scores.click],
|
131 |
fn=event_handler_calculate_pt_scores_blocks,
|
132 |
inputs=[
|
|
|
133 |
files,
|
134 |
],
|
135 |
outputs=[
|
@@ -200,7 +217,7 @@ def setup_app_event_handlers(
|
|
200 |
)
|
201 |
clear_app.click(
|
202 |
fn=event_handler_clear_blocks,
|
203 |
-
inputs=[],
|
204 |
outputs=[
|
205 |
notifications,
|
206 |
files,
|
|
|
12 |
from app.event_handlers.files import (
|
13 |
event_handler_files,
|
14 |
event_handler_files_select,
|
15 |
+
event_handler_files_delete,
|
16 |
)
|
17 |
from app.event_handlers.examples_blocks import event_handler_examples_blocks
|
18 |
from app.event_handlers.clear_blocks import event_handler_clear_blocks
|
|
|
101 |
# Events
|
102 |
languages.select(
|
103 |
fn=event_handler_languages,
|
104 |
+
inputs=[languages, files, video],
|
105 |
outputs=[
|
106 |
description,
|
107 |
step_1,
|
|
|
112 |
tab3,
|
113 |
tab4,
|
114 |
files,
|
115 |
+
video,
|
116 |
+
examples,
|
117 |
+
calculate_pt_scores,
|
118 |
+
clear_app,
|
119 |
+
notifications,
|
120 |
],
|
121 |
queue=True,
|
122 |
)
|
123 |
files.change(
|
124 |
event_handler_files,
|
125 |
+
[
|
126 |
+
languages,
|
127 |
+
files,
|
128 |
+
video,
|
129 |
+
],
|
130 |
[notifications, video, calculate_pt_scores, clear_app],
|
131 |
queue=True,
|
132 |
)
|
133 |
files.select(
|
134 |
event_handler_files_select,
|
135 |
+
[languages, files],
|
136 |
+
[video],
|
137 |
+
queue=True,
|
138 |
+
)
|
139 |
+
files.delete(
|
140 |
+
event_handler_files_delete,
|
141 |
+
[languages, files, video],
|
142 |
[video],
|
143 |
queue=True,
|
144 |
)
|
|
|
146 |
triggers=[calculate_pt_scores.click],
|
147 |
fn=event_handler_calculate_pt_scores_blocks,
|
148 |
inputs=[
|
149 |
+
languages,
|
150 |
files,
|
151 |
],
|
152 |
outputs=[
|
|
|
217 |
)
|
218 |
clear_app.click(
|
219 |
fn=event_handler_clear_blocks,
|
220 |
+
inputs=[languages],
|
221 |
outputs=[
|
222 |
notifications,
|
223 |
files,
|
app/event_handlers/files.py
CHANGED
@@ -11,15 +11,18 @@ from pathlib import Path
|
|
11 |
# Importing necessary components for the Gradio app
|
12 |
from app.config import config_data
|
13 |
from app.components import html_message, video_create_ui, button
|
|
|
14 |
|
15 |
|
16 |
-
def event_handler_files(files):
|
|
|
|
|
17 |
if not files:
|
18 |
return (
|
19 |
-
html_message(config_data.InformationMessages_NOTI_VIDEOS, False),
|
20 |
-
video_create_ui(),
|
21 |
button(
|
22 |
-
config_data.OtherMessages_CALCULATE_PT_SCORES,
|
23 |
False,
|
24 |
3,
|
25 |
"./images/calculate_pt_scores.ico",
|
@@ -27,7 +30,7 @@ def event_handler_files(files):
|
|
27 |
"calculate_oceanai",
|
28 |
),
|
29 |
button(
|
30 |
-
config_data.OtherMessages_CLEAR_APP,
|
31 |
False,
|
32 |
1,
|
33 |
"./images/clear.ico",
|
@@ -36,11 +39,18 @@ def event_handler_files(files):
|
|
36 |
),
|
37 |
)
|
38 |
|
|
|
|
|
|
|
39 |
return (
|
40 |
-
html_message(config_data.OtherMessages_NOTI_CALCULATE, True),
|
41 |
-
video_create_ui(
|
|
|
|
|
|
|
|
|
42 |
button(
|
43 |
-
config_data.OtherMessages_CALCULATE_PT_SCORES,
|
44 |
True,
|
45 |
3,
|
46 |
"./images/calculate_pt_scores.ico",
|
@@ -48,7 +58,7 @@ def event_handler_files(files):
|
|
48 |
"calculate_oceanai",
|
49 |
),
|
50 |
button(
|
51 |
-
config_data.OtherMessages_CLEAR_APP,
|
52 |
True,
|
53 |
1,
|
54 |
"./images/clear.ico",
|
@@ -58,5 +68,26 @@ def event_handler_files(files):
|
|
58 |
)
|
59 |
|
60 |
|
61 |
-
def event_handler_files_select(files, evt: gr.SelectData):
|
62 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
11 |
# Importing necessary components for the Gradio app
|
12 |
from app.config import config_data
|
13 |
from app.components import html_message, video_create_ui, button
|
14 |
+
from app.utils import get_language_settings
|
15 |
|
16 |
|
17 |
+
def event_handler_files(language, files, video):
|
18 |
+
lang_id, _ = get_language_settings(language)
|
19 |
+
|
20 |
if not files:
|
21 |
return (
|
22 |
+
html_message(config_data.InformationMessages_NOTI_VIDEOS[lang_id], False),
|
23 |
+
video_create_ui(label=config_data.OtherMessages_VIDEO_PLAYER[lang_id]),
|
24 |
button(
|
25 |
+
config_data.OtherMessages_CALCULATE_PT_SCORES[lang_id],
|
26 |
False,
|
27 |
3,
|
28 |
"./images/calculate_pt_scores.ico",
|
|
|
30 |
"calculate_oceanai",
|
31 |
),
|
32 |
button(
|
33 |
+
config_data.OtherMessages_CLEAR_APP[lang_id],
|
34 |
False,
|
35 |
1,
|
36 |
"./images/clear.ico",
|
|
|
39 |
),
|
40 |
)
|
41 |
|
42 |
+
if video not in files:
|
43 |
+
video = files[0]
|
44 |
+
|
45 |
return (
|
46 |
+
html_message(config_data.OtherMessages_NOTI_CALCULATE[lang_id], True),
|
47 |
+
video_create_ui(
|
48 |
+
value=video,
|
49 |
+
label=config_data.OtherMessages_VIDEO_PLAYER[lang_id],
|
50 |
+
file_name=Path(Path(video).name).name,
|
51 |
+
),
|
52 |
button(
|
53 |
+
config_data.OtherMessages_CALCULATE_PT_SCORES[lang_id],
|
54 |
True,
|
55 |
3,
|
56 |
"./images/calculate_pt_scores.ico",
|
|
|
58 |
"calculate_oceanai",
|
59 |
),
|
60 |
button(
|
61 |
+
config_data.OtherMessages_CLEAR_APP[lang_id],
|
62 |
True,
|
63 |
1,
|
64 |
"./images/clear.ico",
|
|
|
68 |
)
|
69 |
|
70 |
|
71 |
+
def event_handler_files_select(language, files, evt: gr.SelectData):
|
72 |
+
lang_id, _ = get_language_settings(language)
|
73 |
+
|
74 |
+
return video_create_ui(
|
75 |
+
value=files[evt.index],
|
76 |
+
label=config_data.OtherMessages_VIDEO_PLAYER[lang_id],
|
77 |
+
file_name=evt.value,
|
78 |
+
)
|
79 |
+
|
80 |
+
|
81 |
+
def event_handler_files_delete(language, files, video, evt: gr.DeletedFileData):
|
82 |
+
global block_event_handler_files
|
83 |
+
|
84 |
+
lang_id, _ = get_language_settings(language)
|
85 |
+
|
86 |
+
if video == evt.file.path:
|
87 |
+
video = files[0]
|
88 |
+
|
89 |
+
return video_create_ui(
|
90 |
+
value=video,
|
91 |
+
label=config_data.OtherMessages_VIDEO_PLAYER[lang_id],
|
92 |
+
file_name=Path(Path(video).name).name,
|
93 |
+
)
|
app/event_handlers/languages.py
CHANGED
@@ -6,6 +6,7 @@ License: MIT License
|
|
6 |
"""
|
7 |
|
8 |
import gradio as gr
|
|
|
9 |
|
10 |
# Importing necessary components for the Gradio app
|
11 |
from app.description import DESCRIPTIONS
|
@@ -13,20 +14,31 @@ from app.description_steps import STEP_1
|
|
13 |
from app.config import config_data
|
14 |
from app.components import (
|
15 |
files_create_ui,
|
|
|
16 |
dropdown_create_ui,
|
|
|
|
|
17 |
)
|
|
|
18 |
|
19 |
|
20 |
-
def event_handler_languages(languages, files):
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
|
|
27 |
else:
|
28 |
-
|
29 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
30 |
|
31 |
return (
|
32 |
gr.Markdown(value=DESCRIPTIONS[lang_id]),
|
@@ -55,4 +67,30 @@ def event_handler_languages(languages, files):
|
|
55 |
),
|
56 |
file_types=[f".{ext}" for ext in config_data.Settings_SUPPORTED_VIDEO_EXT],
|
57 |
),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
58 |
)
|
|
|
6 |
"""
|
7 |
|
8 |
import gradio as gr
|
9 |
+
from pathlib import Path
|
10 |
|
11 |
# Importing necessary components for the Gradio app
|
12 |
from app.description import DESCRIPTIONS
|
|
|
14 |
from app.config import config_data
|
15 |
from app.components import (
|
16 |
files_create_ui,
|
17 |
+
video_create_ui,
|
18 |
dropdown_create_ui,
|
19 |
+
button,
|
20 |
+
html_message,
|
21 |
)
|
22 |
+
from app.utils import get_language_settings
|
23 |
|
24 |
|
25 |
+
def event_handler_languages(languages, files, video):
|
26 |
+
lang_id, choices = get_language_settings(languages)
|
27 |
+
|
28 |
+
if not video:
|
29 |
+
video = video_create_ui(label=config_data.OtherMessages_VIDEO_PLAYER[lang_id])
|
30 |
+
noti_videos = html_message(
|
31 |
+
config_data.InformationMessages_NOTI_VIDEOS[lang_id], False
|
32 |
+
)
|
33 |
else:
|
34 |
+
video = video_create_ui(
|
35 |
+
value=video,
|
36 |
+
label=config_data.OtherMessages_VIDEO_PLAYER[lang_id],
|
37 |
+
file_name=Path(video).name,
|
38 |
+
)
|
39 |
+
noti_videos = html_message(
|
40 |
+
config_data.OtherMessages_NOTI_CALCULATE[lang_id], True
|
41 |
+
)
|
42 |
|
43 |
return (
|
44 |
gr.Markdown(value=DESCRIPTIONS[lang_id]),
|
|
|
67 |
),
|
68 |
file_types=[f".{ext}" for ext in config_data.Settings_SUPPORTED_VIDEO_EXT],
|
69 |
),
|
70 |
+
video,
|
71 |
+
button(
|
72 |
+
config_data.OtherMessages_EXAMPLES_APP[lang_id],
|
73 |
+
True,
|
74 |
+
1,
|
75 |
+
"./images/examples.ico",
|
76 |
+
True,
|
77 |
+
"examples_oceanai",
|
78 |
+
),
|
79 |
+
button(
|
80 |
+
config_data.OtherMessages_CALCULATE_PT_SCORES[lang_id],
|
81 |
+
True if files else False,
|
82 |
+
3,
|
83 |
+
"./images/calculate_pt_scores.ico",
|
84 |
+
True,
|
85 |
+
"calculate_oceanai",
|
86 |
+
),
|
87 |
+
button(
|
88 |
+
config_data.OtherMessages_CLEAR_APP[lang_id],
|
89 |
+
True if files else False,
|
90 |
+
1,
|
91 |
+
"./images/clear.ico",
|
92 |
+
True,
|
93 |
+
"clear_oceanai",
|
94 |
+
),
|
95 |
+
noti_videos,
|
96 |
)
|
app/tabs.py
CHANGED
@@ -52,7 +52,9 @@ def app_tab():
|
|
52 |
|
53 |
with gr.Row():
|
54 |
examples = button(
|
55 |
-
config_data.OtherMessages_EXAMPLES_APP
|
|
|
|
|
56 |
True,
|
57 |
1,
|
58 |
"./images/examples.ico",
|
@@ -60,7 +62,9 @@ def app_tab():
|
|
60 |
"examples_oceanai",
|
61 |
)
|
62 |
calculate_pt_scores = button(
|
63 |
-
config_data.OtherMessages_CALCULATE_PT_SCORES
|
|
|
|
|
64 |
False,
|
65 |
3,
|
66 |
"./images/calculate_pt_scores.ico",
|
@@ -68,7 +72,9 @@ def app_tab():
|
|
68 |
"calculate_oceanai",
|
69 |
)
|
70 |
clear_app = button(
|
71 |
-
config_data.OtherMessages_CLEAR_APP
|
|
|
|
|
72 |
False,
|
73 |
1,
|
74 |
"./images/clear.ico",
|
@@ -76,7 +82,12 @@ def app_tab():
|
|
76 |
"clear_oceanai",
|
77 |
)
|
78 |
|
79 |
-
notifications = html_message(
|
|
|
|
|
|
|
|
|
|
|
80 |
|
81 |
pt_scores = dataframe(visible=False)
|
82 |
|
|
|
52 |
|
53 |
with gr.Row():
|
54 |
examples = button(
|
55 |
+
config_data.OtherMessages_EXAMPLES_APP[
|
56 |
+
config_data.AppSettings_DEFAULT_LANG_ID
|
57 |
+
],
|
58 |
True,
|
59 |
1,
|
60 |
"./images/examples.ico",
|
|
|
62 |
"examples_oceanai",
|
63 |
)
|
64 |
calculate_pt_scores = button(
|
65 |
+
config_data.OtherMessages_CALCULATE_PT_SCORES[
|
66 |
+
config_data.AppSettings_DEFAULT_LANG_ID
|
67 |
+
],
|
68 |
False,
|
69 |
3,
|
70 |
"./images/calculate_pt_scores.ico",
|
|
|
72 |
"calculate_oceanai",
|
73 |
)
|
74 |
clear_app = button(
|
75 |
+
config_data.OtherMessages_CLEAR_APP[
|
76 |
+
config_data.AppSettings_DEFAULT_LANG_ID
|
77 |
+
],
|
78 |
False,
|
79 |
1,
|
80 |
"./images/clear.ico",
|
|
|
82 |
"clear_oceanai",
|
83 |
)
|
84 |
|
85 |
+
notifications = html_message(
|
86 |
+
config_data.InformationMessages_NOTI_VIDEOS[
|
87 |
+
config_data.AppSettings_DEFAULT_LANG_ID
|
88 |
+
],
|
89 |
+
False,
|
90 |
+
)
|
91 |
|
92 |
pt_scores = dataframe(visible=False)
|
93 |
|
app/utils.py
CHANGED
@@ -7,6 +7,26 @@ License: MIT License
|
|
7 |
|
8 |
import pandas as pd
|
9 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
10 |
|
11 |
def preprocess_scores_df(df, name):
|
12 |
df.index.name = name
|
|
|
7 |
|
8 |
import pandas as pd
|
9 |
|
10 |
+
# Importing necessary components for the Gradio app
|
11 |
+
from app.config import config_data
|
12 |
+
|
13 |
+
|
14 |
+
def get_language_settings(language):
|
15 |
+
language_mappings = {
|
16 |
+
"english": (0, config_data.Settings_LANGUAGES_EN),
|
17 |
+
"английский": (0, config_data.Settings_LANGUAGES_EN),
|
18 |
+
"russian": (1, config_data.Settings_LANGUAGES_RU),
|
19 |
+
"русский": (1, config_data.Settings_LANGUAGES_RU),
|
20 |
+
}
|
21 |
+
|
22 |
+
normalized_language = language.lower()
|
23 |
+
|
24 |
+
lang_id, choices = language_mappings.get(
|
25 |
+
normalized_language, (0, config_data.Settings_LANGUAGES_EN)
|
26 |
+
)
|
27 |
+
|
28 |
+
return lang_id, choices
|
29 |
+
|
30 |
|
31 |
def preprocess_scores_df(df, name):
|
32 |
df.index.name = name
|
config.toml
CHANGED
@@ -1,5 +1,5 @@
|
|
1 |
[AppSettings]
|
2 |
-
APP_VERSION = "0.
|
3 |
CSS_PATH = "app.css"
|
4 |
DEFAULT_LANG_ID = 0
|
5 |
|
@@ -8,7 +8,7 @@ DESCRIPTIONS = [
|
|
8 |
"is an open-source framework for Big Five personality traits assessment and HR-processes automatization",
|
9 |
"- библиотека с открытым исходным кодом для оценивания большой пятерки качеств личности человека и автоматизации HR-процессов",
|
10 |
]
|
11 |
-
NOTI_VIDEOS = "Select the video(s)"
|
12 |
PRACTICAL_TASKS_INFO = "Choose a practical task"
|
13 |
PRACTICAL_SUBTASKS_INFO = "Choose a practical subtask"
|
14 |
NOTI_IN_DEV = "In development"
|
@@ -30,18 +30,19 @@ STEP_2 = [
|
|
30 |
|
31 |
[OtherMessages]
|
32 |
VIDEO_FILES = ["Video Files", "Видеофайлы"]
|
33 |
-
|
|
|
34 |
CALCULATE_PT_SCORES_ERR = "Personality traits scores have not been calculated. Try uploading a different file(s)"
|
35 |
CALCULATE_PRACTICAL_TASK = "Solving practical task"
|
36 |
-
CLEAR_APP = "Clear"
|
37 |
-
EXAMPLES_APP = "Examples"
|
38 |
EXPORT_PT_SCORES = "Export Big Five personality traits to a CSV file"
|
39 |
EXPORT_PG = "Export ranking professional groups results to a CSV file"
|
40 |
EXPORT_PS = "Export ranking professional skill results to a CSV file"
|
41 |
EXPORT_WT = "Export ranking effective work teams results to a CSV file"
|
42 |
EXPORT_CP = "Export consumer preferences for industrial goods results to a CSV file"
|
43 |
EXPORT_MBTI = "Export ranking personality type results to a CSV file"
|
44 |
-
NOTI_CALCULATE = "You can calculate Big Five personality traits scores"
|
45 |
|
46 |
[Labels]
|
47 |
APP_LABEL = ["⭐ App", "⭐ Приложение"]
|
@@ -68,6 +69,7 @@ NUMBER_IMPORTANCE_NNEU_LABEL = "Non-Neuroticism weight"
|
|
68 |
THRESHOLD_CONSUMER_PREFERENCES_LABEL = "Polarity traits threshold"
|
69 |
LANGUAGES_LABEL = "Languages"
|
70 |
NOTE_MBTI_LABEL = "Note: What are Personality Types of MBTI?"
|
|
|
71 |
|
72 |
[TabCreators]
|
73 |
"⭐ App" = "app_tab"
|
|
|
1 |
[AppSettings]
|
2 |
+
APP_VERSION = "0.9.0"
|
3 |
CSS_PATH = "app.css"
|
4 |
DEFAULT_LANG_ID = 0
|
5 |
|
|
|
8 |
"is an open-source framework for Big Five personality traits assessment and HR-processes automatization",
|
9 |
"- библиотека с открытым исходным кодом для оценивания большой пятерки качеств личности человека и автоматизации HR-процессов",
|
10 |
]
|
11 |
+
NOTI_VIDEOS = ["Select the video(s)", "Выберите видео"]
|
12 |
PRACTICAL_TASKS_INFO = "Choose a practical task"
|
13 |
PRACTICAL_SUBTASKS_INFO = "Choose a practical subtask"
|
14 |
NOTI_IN_DEV = "In development"
|
|
|
30 |
|
31 |
[OtherMessages]
|
32 |
VIDEO_FILES = ["Video Files", "Видеофайлы"]
|
33 |
+
VIDEO_PLAYER = ["Video Player", "Видео проигрыватель"]
|
34 |
+
CALCULATE_PT_SCORES = ["Calculation of Big Five personality traits scores", "Вычисление показателей Большой пятерки персональных качеств личности человека"]
|
35 |
CALCULATE_PT_SCORES_ERR = "Personality traits scores have not been calculated. Try uploading a different file(s)"
|
36 |
CALCULATE_PRACTICAL_TASK = "Solving practical task"
|
37 |
+
CLEAR_APP = ["Clear", "Сброс"]
|
38 |
+
EXAMPLES_APP = ["Examples", "Примеры"]
|
39 |
EXPORT_PT_SCORES = "Export Big Five personality traits to a CSV file"
|
40 |
EXPORT_PG = "Export ranking professional groups results to a CSV file"
|
41 |
EXPORT_PS = "Export ranking professional skill results to a CSV file"
|
42 |
EXPORT_WT = "Export ranking effective work teams results to a CSV file"
|
43 |
EXPORT_CP = "Export consumer preferences for industrial goods results to a CSV file"
|
44 |
EXPORT_MBTI = "Export ranking personality type results to a CSV file"
|
45 |
+
NOTI_CALCULATE = ["You can calculate Big Five personality traits scores", "Вы можете рассчитать показатели Большой пятерки персональных качеств личности человека"]
|
46 |
|
47 |
[Labels]
|
48 |
APP_LABEL = ["⭐ App", "⭐ Приложение"]
|
|
|
69 |
THRESHOLD_CONSUMER_PREFERENCES_LABEL = "Polarity traits threshold"
|
70 |
LANGUAGES_LABEL = "Languages"
|
71 |
NOTE_MBTI_LABEL = "Note: What are Personality Types of MBTI?"
|
72 |
+
APP_VERSION = ["Version", "Версия"]
|
73 |
|
74 |
[TabCreators]
|
75 |
"⭐ App" = "app_tab"
|