DmitryRyumin commited on
Commit
f612514
1 Parent(s): f0fbbb8
.gradio/certificate.pem ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ -----BEGIN CERTIFICATE-----
2
+ MIIFazCCA1OgAwIBAgIRAIIQz7DSQONZRGPgu2OCiwAwDQYJKoZIhvcNAQELBQAw
3
+ TzELMAkGA1UEBhMCVVMxKTAnBgNVBAoTIEludGVybmV0IFNlY3VyaXR5IFJlc2Vh
4
+ cmNoIEdyb3VwMRUwEwYDVQQDEwxJU1JHIFJvb3QgWDEwHhcNMTUwNjA0MTEwNDM4
5
+ WhcNMzUwNjA0MTEwNDM4WjBPMQswCQYDVQQGEwJVUzEpMCcGA1UEChMgSW50ZXJu
6
+ ZXQgU2VjdXJpdHkgUmVzZWFyY2ggR3JvdXAxFTATBgNVBAMTDElTUkcgUm9vdCBY
7
+ MTCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBAK3oJHP0FDfzm54rVygc
8
+ h77ct984kIxuPOZXoHj3dcKi/vVqbvYATyjb3miGbESTtrFj/RQSa78f0uoxmyF+
9
+ 0TM8ukj13Xnfs7j/EvEhmkvBioZxaUpmZmyPfjxwv60pIgbz5MDmgK7iS4+3mX6U
10
+ A5/TR5d8mUgjU+g4rk8Kb4Mu0UlXjIB0ttov0DiNewNwIRt18jA8+o+u3dpjq+sW
11
+ T8KOEUt+zwvo/7V3LvSye0rgTBIlDHCNAymg4VMk7BPZ7hm/ELNKjD+Jo2FR3qyH
12
+ B5T0Y3HsLuJvW5iB4YlcNHlsdu87kGJ55tukmi8mxdAQ4Q7e2RCOFvu396j3x+UC
13
+ B5iPNgiV5+I3lg02dZ77DnKxHZu8A/lJBdiB3QW0KtZB6awBdpUKD9jf1b0SHzUv
14
+ KBds0pjBqAlkd25HN7rOrFleaJ1/ctaJxQZBKT5ZPt0m9STJEadao0xAH0ahmbWn
15
+ OlFuhjuefXKnEgV4We0+UXgVCwOPjdAvBbI+e0ocS3MFEvzG6uBQE3xDk3SzynTn
16
+ jh8BCNAw1FtxNrQHusEwMFxIt4I7mKZ9YIqioymCzLq9gwQbooMDQaHWBfEbwrbw
17
+ qHyGO0aoSCqI3Haadr8faqU9GY/rOPNk3sgrDQoo//fb4hVC1CLQJ13hef4Y53CI
18
+ rU7m2Ys6xt0nUW7/vGT1M0NPAgMBAAGjQjBAMA4GA1UdDwEB/wQEAwIBBjAPBgNV
19
+ HRMBAf8EBTADAQH/MB0GA1UdDgQWBBR5tFnme7bl5AFzgAiIyBpY9umbbjANBgkq
20
+ hkiG9w0BAQsFAAOCAgEAVR9YqbyyqFDQDLHYGmkgJykIrGF1XIpu+ILlaS/V9lZL
21
+ ubhzEFnTIZd+50xx+7LSYK05qAvqFyFWhfFQDlnrzuBZ6brJFe+GnY+EgPbk6ZGQ
22
+ 3BebYhtF8GaV0nxvwuo77x/Py9auJ/GpsMiu/X1+mvoiBOv/2X/qkSsisRcOj/KK
23
+ NFtY2PwByVS5uCbMiogziUwthDyC3+6WVwW6LLv3xLfHTjuCvjHIInNzktHCgKQ5
24
+ ORAzI4JMPJ+GslWYHb4phowim57iaztXOoJwTdwJx4nLCgdNbOhdjsnvzqvHu7Ur
25
+ TkXWStAmzOVyyghqpZXjFaH3pO3JLF+l+/+sKAIuvtd7u+Nxe5AW0wdeRlN8NwdC
26
+ jNPElpzVmbUq4JUagEiuTDkHzsxHpFKVK7q4+63SM1N95R1NbdWhscdCb+ZAJzVc
27
+ oyi3B43njTOQ5yOf+1CceWxG1bQVs5ZufpsMljq4Ui0/1lvh+wjChP4kqKOJ2qxq
28
+ 4RgqsahDYVvTH9w7jXbyLeiNdd8XM2w9U/t7y0Ff/9yi0GE44Za4rF2LN9d11TPA
29
+ mRGunUHBcnWEvgJBQl9nJEiU0Zsnvgc/ubhPgXRR4Xq37Z0j4r7g1SgEEzwxA57d
30
+ emyPxgcYxn/eR44/KJ4EBs+lVDR3veyJm+kXQ99b21/+jh5Xos1AnX5iItreGCc=
31
+ -----END CERTIFICATE-----
README.md CHANGED
@@ -4,7 +4,7 @@ emoji: 😀🤓😎😉😤
4
  colorFrom: gray
5
  colorTo: red
6
  sdk: gradio
7
- sdk_version: 5.5.0
8
  app_file: app.py
9
  pinned: false
10
  license: mit
 
4
  colorFrom: gray
5
  colorTo: red
6
  sdk: gradio
7
+ sdk_version: 5.6.0
8
  app_file: app.py
9
  pinned: false
10
  license: mit
app.css CHANGED
@@ -14,9 +14,8 @@ div.app-flex-container {
14
  gap: 6px;
15
  }
16
 
17
- div.video-container {
18
- height: 350px;
19
- max-height: 350px;
20
  }
21
 
22
  div.video-column-container {
@@ -28,11 +27,17 @@ div.video-sorted-container {
28
  max-height: 350px;
29
  }
30
 
 
31
  div.files-container {
32
  height: 350px;
33
  max-height: 350px;
34
  }
35
 
 
 
 
 
 
36
  div.files-container tr {
37
  padding-right: 20px;
38
  }
@@ -42,6 +47,8 @@ div.video-sorted-container div.icon-buttons > button {
42
  display: none;
43
  }
44
 
 
 
45
  div.files-container:hover label[data-testid="block-label"],
46
  div.video-container:hover label[data-testid="block-label"],
47
  div.video-sorted-container:hover label[data-testid="block-label"] {
@@ -58,11 +65,14 @@ div.dataframe div.table-wrap {
58
  height: auto !important;
59
  }
60
 
 
61
  div.files-container div.file-preview-holder {
62
  overflow-y: scroll;
63
  height: 100%;
64
  }
65
 
 
 
66
  div.files-container label[data-testid="block-label"] {
67
  position: absolute;
68
  }
 
14
  gap: 6px;
15
  }
16
 
17
+ div.media-container {
18
+ align-items: stretch;
 
19
  }
20
 
21
  div.video-column-container {
 
27
  max-height: 350px;
28
  }
29
 
30
+ div.webcam,
31
  div.files-container {
32
  height: 350px;
33
  max-height: 350px;
34
  }
35
 
36
+ div.webcam div[data-testid="video"] > div.wrap,
37
+ div.webcam div[data-testid="video"] > div.upload-container {
38
+ height: 310px;
39
+ }
40
+
41
  div.files-container tr {
42
  padding-right: 20px;
43
  }
 
47
  display: none;
48
  }
49
 
50
+ div.webcam:hover label[data-testid="block-label"],
51
+ div.video-container:hover label[data-testid="block-label"],
52
  div.files-container:hover label[data-testid="block-label"],
53
  div.video-container:hover label[data-testid="block-label"],
54
  div.video-sorted-container:hover label[data-testid="block-label"] {
 
65
  height: auto !important;
66
  }
67
 
68
+ div.video-container div.file-preview-holder,
69
  div.files-container div.file-preview-holder {
70
  overflow-y: scroll;
71
  height: 100%;
72
  }
73
 
74
+ div.webcam label[data-testid="block-label"],
75
+ div.video-container label[data-testid="block-label"],
76
  div.files-container label[data-testid="block-label"] {
77
  position: absolute;
78
  }
app.py CHANGED
@@ -12,12 +12,15 @@ from app.config import CONFIG_NAME, config_data, load_tab_creators
12
  from app.event_handlers.event_handlers import setup_app_event_handlers
13
  from app import tabs
14
  from app.components import dropdown_create_ui
 
15
 
16
  gr.set_static_paths(paths=[config_data.StaticPaths_IMAGES])
17
 
18
 
19
  def create_gradio_app() -> gr.Blocks:
20
- with gr.Blocks(css=config_data.AppSettings_CSS_PATH) as gradio_app:
 
 
21
  with gr.Column(
22
  visible=True,
23
  render=True,
@@ -39,6 +42,7 @@ def create_gradio_app() -> gr.Blocks:
39
  visible=True,
40
  show_download_button=False,
41
  elem_classes="country_flags",
 
42
  )
43
 
44
  languages = dropdown_create_ui(
@@ -81,4 +85,14 @@ def create_gradio_app() -> gr.Blocks:
81
 
82
 
83
  if __name__ == "__main__":
84
- create_gradio_app().queue(api_open=False).launch(share=False)
 
 
 
 
 
 
 
 
 
 
 
12
  from app.event_handlers.event_handlers import setup_app_event_handlers
13
  from app import tabs
14
  from app.components import dropdown_create_ui
15
+ from app.port import is_port_in_use, free_ports
16
 
17
  gr.set_static_paths(paths=[config_data.StaticPaths_IMAGES])
18
 
19
 
20
  def create_gradio_app() -> gr.Blocks:
21
+ with gr.Blocks(
22
+ theme=gr.themes.Default(), css_paths=config_data.AppSettings_CSS_PATH
23
+ ) as gradio_app:
24
  with gr.Column(
25
  visible=True,
26
  render=True,
 
42
  visible=True,
43
  show_download_button=False,
44
  elem_classes="country_flags",
45
+ show_fullscreen_button=False,
46
  )
47
 
48
  languages = dropdown_create_ui(
 
85
 
86
 
87
  if __name__ == "__main__":
88
+ ports_to_check = [config_data.AppSettings_PORT]
89
+
90
+ for port in filter(None, ports_to_check):
91
+ if is_port_in_use(config_data.AppSettings_SERVER_NAME, port):
92
+ free_ports(port)
93
+
94
+ create_gradio_app().queue(api_open=False).launch(
95
+ share=False,
96
+ server_name=config_data.AppSettings_SERVER_NAME,
97
+ server_port=config_data.AppSettings_PORT,
98
+ )
app/authors.py CHANGED
@@ -76,7 +76,7 @@ AUTHORS = """
76
  <a href="https://github.com/DmitryRyumin" style="display: inline-block;">
77
  <img src="https://github-stats-alpha.vercel.app/api?username=DmitryRyumin&cc=3081F7&tc=FFFFFF&ic=FFFFFF&bc=FFFFFF" alt="" />
78
  </a>
79
- <div style="display: flex; flex-wrap: wrap;">
80
  <img src="https://custom-icon-badges.demolab.com/badge/dynamic/json?style=flat-square&logo=fire&logoColor=fff&color=orange&label=GitHub%20streak&query=%24.currentStreak.length&suffix=%20days&url=https%3A%2F%2Fstreak-stats.demolab.com%2F%3Fuser%3Ddmitryryumin%26type%3Djson" alt="" style="margin-right: 6px; margin-bottom: 6px;" />
81
  <img src="https://komarev.com/ghpvc/?username=DmitryRyumin&style=flat-square" alt="" style="margin-bottom: 6px;" />
82
  </div>
 
76
  <a href="https://github.com/DmitryRyumin" style="display: inline-block;">
77
  <img src="https://github-stats-alpha.vercel.app/api?username=DmitryRyumin&cc=3081F7&tc=FFFFFF&ic=FFFFFF&bc=FFFFFF" alt="" />
78
  </a>
79
+ <div style="display: flex; flex-wrap: wrap; align-items: flex-start;">
80
  <img src="https://custom-icon-badges.demolab.com/badge/dynamic/json?style=flat-square&logo=fire&logoColor=fff&color=orange&label=GitHub%20streak&query=%24.currentStreak.length&suffix=%20days&url=https%3A%2F%2Fstreak-stats.demolab.com%2F%3Fuser%3Ddmitryryumin%26type%3Djson" alt="" style="margin-right: 6px; margin-bottom: 6px;" />
81
  <img src="https://komarev.com/ghpvc/?username=DmitryRyumin&style=flat-square" alt="" style="margin-bottom: 6px;" />
82
  </div>
app/components.py CHANGED
@@ -53,7 +53,7 @@ def video_create_ui(
53
  show_label: bool = True,
54
  interactive: bool = False,
55
  visible: bool = True,
56
- elem_classes: Optional[str] = "files-container",
57
  ) -> gr.Video:
58
  if file_name is not None:
59
  label += f" ({file_name})"
 
53
  show_label: bool = True,
54
  interactive: bool = False,
55
  visible: bool = True,
56
+ elem_classes: Optional[str] = "video-container",
57
  ) -> gr.Video:
58
  if file_name is not None:
59
  label += f" ({file_name})"
app/event_handlers/calculate_practical_tasks.py CHANGED
@@ -166,7 +166,9 @@ def create_person_metadata(person_id, files, video_metadata):
166
 
167
 
168
  def event_handler_calculate_practical_task_blocks(
 
169
  files,
 
170
  practical_subtasks,
171
  pt_scores,
172
  dropdown_mbti,
@@ -188,6 +190,9 @@ def event_handler_calculate_practical_task_blocks(
188
  number_agreeableness,
189
  number_non_neuroticism,
190
  ):
 
 
 
191
  if practical_subtasks.lower() == "16 personality types of mbti":
192
  df_correlation_coefficients = read_csv_file(config_data.Links_MBTI)
193
 
 
166
 
167
 
168
  def event_handler_calculate_practical_task_blocks(
169
+ type_modes,
170
  files,
171
+ video,
172
  practical_subtasks,
173
  pt_scores,
174
  dropdown_mbti,
 
190
  number_agreeableness,
191
  number_non_neuroticism,
192
  ):
193
+ if type_modes == config_data.Settings_TYPE_MODES[1]:
194
+ files = [video]
195
+
196
  if practical_subtasks.lower() == "16 personality types of mbti":
197
  df_correlation_coefficients = read_csv_file(config_data.Links_MBTI)
198
 
app/event_handlers/calculate_pt_scores_blocks.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.oceanai_init import b5
@@ -26,23 +27,37 @@ from app.components import (
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
37
- )
38
 
39
- first_practical_task = next(iter(supported_practical_tasks))
 
 
 
 
 
 
 
 
 
 
 
40
 
41
- if len(b5.df_files_) == 0:
42
- gr.Warning(config_data.OtherMessages_CALCULATE_PT_SCORES_ERR)
 
 
43
 
44
  return (
45
- html_message(config_data.OtherMessages_CALCULATE_PT_SCORES_ERR, False),
 
 
46
  dataframe(visible=False),
47
  files_create_ui(
48
  None,
@@ -59,23 +74,24 @@ def event_handler_calculate_pt_scores_blocks(language, files, evt_data: gr.Event
59
  radio_create_ui(
60
  first_practical_task,
61
  config_data.Labels_PRACTICAL_TASKS_LABEL,
62
- list(map(str, supported_practical_tasks.keys())),
63
- config_data.InformationMessages_PRACTICAL_TASKS_INFO,
64
  True,
65
  True,
66
  ),
67
  radio_create_ui(
68
- supported_practical_tasks[first_practical_task][0],
69
- config_data.Labels_PRACTICAL_SUBTASKS_LABEL,
70
- supported_practical_tasks[first_practical_task],
71
- config_data.InformationMessages_PRACTICAL_SUBTASKS_INFO,
72
  True,
73
  True,
74
  ),
75
  gr.JSON(
76
  value={
77
- str(task): supported_practical_tasks.get(task, [None])[0]
78
- for task in supported_practical_tasks.keys()
 
79
  },
80
  visible=False,
81
  render=True,
@@ -172,24 +188,25 @@ def event_handler_calculate_pt_scores_blocks(language, files, evt_data: gr.Event
172
  gr.Column(visible=True),
173
  radio_create_ui(
174
  first_practical_task,
175
- "Practical tasks",
176
- list(map(str, supported_practical_tasks.keys())),
177
- config_data.InformationMessages_PRACTICAL_TASKS_INFO,
178
  True,
179
  True,
180
  ),
181
  radio_create_ui(
182
- supported_practical_tasks[first_practical_task][0],
183
- "Practical subtasks",
184
- supported_practical_tasks[first_practical_task],
185
- config_data.InformationMessages_PRACTICAL_SUBTASKS_INFO,
186
  True,
187
  True,
188
  ),
189
  gr.JSON(
190
  value={
191
- str(task): supported_practical_tasks.get(task, [None])[0]
192
- for task in supported_practical_tasks.keys()
 
193
  },
194
  visible=False,
195
  render=True,
 
6
  """
7
 
8
  import gradio as gr
9
+ import pandas as pd
10
 
11
  # Importing necessary components for the Gradio app
12
  from app.oceanai_init import b5
 
27
  )
28
 
29
 
30
+ def event_handler_calculate_pt_scores_blocks(
31
+ language, type_modes, files, video, evt_data: gr.EventData
32
+ ):
33
  _ = evt_data.target.__class__.__name__
34
 
35
  lang_id, _ = get_language_settings(language)
36
 
37
  out = False
 
 
 
38
 
39
+ try:
40
+ b5.get_avt_predictions_gradio(
41
+ paths=(
42
+ files if type_modes == config_data.Settings_TYPE_MODES[0] else [video]
43
+ ),
44
+ url_accuracy="",
45
+ accuracy=False,
46
+ lang="en",
47
+ out=out,
48
+ )
49
+ except TypeError:
50
+ out = True
51
 
52
+ first_practical_task = next(iter(supported_practical_tasks[lang_id]))
53
+
54
+ if out or len(b5.df_files_) == 0:
55
+ gr.Warning(config_data.OtherMessages_CALCULATE_PT_SCORES_ERR[lang_id])
56
 
57
  return (
58
+ html_message(
59
+ config_data.OtherMessages_CALCULATE_PT_SCORES_ERR[lang_id], False
60
+ ),
61
  dataframe(visible=False),
62
  files_create_ui(
63
  None,
 
74
  radio_create_ui(
75
  first_practical_task,
76
  config_data.Labels_PRACTICAL_TASKS_LABEL,
77
+ list(map(str, supported_practical_tasks[lang_id].keys())),
78
+ config_data.InformationMessages_PRACTICAL_TASKS_INFO[lang_id],
79
  True,
80
  True,
81
  ),
82
  radio_create_ui(
83
+ supported_practical_tasks[lang_id][first_practical_task][0],
84
+ config_data.Labels_PRACTICAL_SUBTASKS_LABEL[lang_id],
85
+ supported_practical_tasks[lang_id][first_practical_task],
86
+ config_data.InformationMessages_PRACTICAL_SUBTASKS_INFO[lang_id],
87
  True,
88
  True,
89
  ),
90
  gr.JSON(
91
  value={
92
+ str(task): supported_practical_tasks[index].get(task, [None])[0]
93
+ for index in range(len(supported_practical_tasks))
94
+ for task in supported_practical_tasks[index].keys()
95
  },
96
  visible=False,
97
  render=True,
 
188
  gr.Column(visible=True),
189
  radio_create_ui(
190
  first_practical_task,
191
+ config_data.Labels_PRACTICAL_TASKS_LABEL[lang_id],
192
+ list(map(str, supported_practical_tasks[lang_id].keys())),
193
+ config_data.InformationMessages_PRACTICAL_TASKS_INFO[lang_id],
194
  True,
195
  True,
196
  ),
197
  radio_create_ui(
198
+ supported_practical_tasks[lang_id][first_practical_task][0],
199
+ config_data.Labels_PRACTICAL_SUBTASKS_LABEL[lang_id],
200
+ supported_practical_tasks[lang_id][first_practical_task],
201
+ config_data.InformationMessages_PRACTICAL_SUBTASKS_INFO[lang_id],
202
  True,
203
  True,
204
  ),
205
  gr.JSON(
206
  value={
207
+ str(task): supported_practical_tasks[index].get(task, [None])[0]
208
+ for index in range(len(supported_practical_tasks))
209
+ for task in supported_practical_tasks[index].keys()
210
  },
211
  visible=False,
212
  render=True,
app/event_handlers/clear_blocks.py CHANGED
@@ -25,20 +25,38 @@ from app.components import (
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],
@@ -71,24 +89,25 @@ def event_handler_clear_blocks(language):
71
  gr.Column(visible=False),
72
  radio_create_ui(
73
  first_practical_task,
74
- "Practical tasks",
75
- list(map(str, supported_practical_tasks.keys())),
76
- config_data.InformationMessages_PRACTICAL_TASKS_INFO,
77
  True,
78
  True,
79
  ),
80
  radio_create_ui(
81
- supported_practical_tasks[first_practical_task][0],
82
- "Practical subtasks",
83
- supported_practical_tasks[first_practical_task],
84
- config_data.InformationMessages_PRACTICAL_SUBTASKS_INFO,
85
  True,
86
  True,
87
  ),
88
  gr.JSON(
89
  value={
90
- str(task): supported_practical_tasks.get(task, [None])[0]
91
- for task in supported_practical_tasks.keys()
 
92
  },
93
  visible=False,
94
  render=True,
 
25
  from app.utils import get_language_settings
26
 
27
 
28
+ def event_handler_clear_blocks(language, type_modes):
29
  lang_id, _ = get_language_settings(language)
30
 
31
+ first_practical_task = next(iter(supported_practical_tasks[lang_id]))
32
 
33
+ if type_modes == config_data.Settings_TYPE_MODES[0]:
34
+ files_ui = files_create_ui(
35
+ label="{} ({})".format(
36
+ config_data.OtherMessages_VIDEO_FILES[
37
+ config_data.AppSettings_DEFAULT_LANG_ID
38
+ ],
39
+ ", ".join(config_data.Settings_SUPPORTED_VIDEO_EXT),
40
+ ),
41
+ file_types=[f".{ext}" for ext in config_data.Settings_SUPPORTED_VIDEO_EXT],
42
+ )
43
+ webcam = gr.Video(interactive=False, visible=False)
44
+ elif type_modes == config_data.Settings_TYPE_MODES[1]:
45
+ files_ui = files_create_ui(
46
  label="{} ({})".format(
47
  config_data.OtherMessages_VIDEO_FILES[lang_id],
48
  ", ".join(config_data.Settings_SUPPORTED_VIDEO_EXT),
49
  ),
50
  file_types=[f".{ext}" for ext in config_data.Settings_SUPPORTED_VIDEO_EXT],
51
+ interactive=False,
52
+ visible=False,
53
+ )
54
+ webcam = gr.Video(interactive=True, visible=True)
55
+
56
+ return (
57
+ html_message(config_data.InformationMessages_NOTI_VIDEOS[lang_id], False),
58
+ files_ui,
59
+ webcam,
60
  video_create_ui(),
61
  button(
62
  config_data.OtherMessages_CALCULATE_PT_SCORES[lang_id],
 
89
  gr.Column(visible=False),
90
  radio_create_ui(
91
  first_practical_task,
92
+ config_data.Labels_PRACTICAL_TASKS_LABEL[lang_id],
93
+ list(map(str, supported_practical_tasks[lang_id].keys())),
94
+ config_data.InformationMessages_PRACTICAL_TASKS_INFO[lang_id],
95
  True,
96
  True,
97
  ),
98
  radio_create_ui(
99
+ supported_practical_tasks[lang_id][first_practical_task][0],
100
+ config_data.Labels_PRACTICAL_SUBTASKS_LABEL[lang_id],
101
+ supported_practical_tasks[lang_id][first_practical_task],
102
+ config_data.InformationMessages_PRACTICAL_SUBTASKS_INFO[lang_id],
103
  True,
104
  True,
105
  ),
106
  gr.JSON(
107
  value={
108
+ str(task): supported_practical_tasks[index].get(task, [None])[0]
109
+ for index in range(len(supported_practical_tasks))
110
+ for task in supported_practical_tasks[index].keys()
111
  },
112
  visible=False,
113
  render=True,
app/event_handlers/dropdown_candidates.py CHANGED
@@ -8,7 +8,7 @@ License: MIT License
8
  # Importing necessary components for the Gradio app
9
  from app.config import config_data
10
  from app.utils import read_csv_file, extract_profession_weights
11
- from app.components import number_create_ui, dropdown_create_ui
12
 
13
 
14
  def event_handler_dropdown_candidates(practical_subtasks, dropdown_candidates):
 
8
  # Importing necessary components for the Gradio app
9
  from app.config import config_data
10
  from app.utils import read_csv_file, extract_profession_weights
11
+ from app.components import number_create_ui
12
 
13
 
14
  def event_handler_dropdown_candidates(practical_subtasks, dropdown_candidates):
app/event_handlers/event_handlers.py CHANGED
@@ -9,11 +9,13 @@ import gradio as gr
9
 
10
  # Importing necessary components for the Gradio app
11
  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
  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
19
  from app.event_handlers.calculate_pt_scores_blocks import (
@@ -33,6 +35,9 @@ def setup_app_event_handlers(
33
  step_1,
34
  notifications,
35
  files,
 
 
 
36
  video,
37
  examples,
38
  calculate_pt_scores,
@@ -101,7 +106,16 @@ def setup_app_event_handlers(
101
  # Events
102
  languages.select(
103
  fn=event_handler_languages,
104
- inputs=[languages, files, video, pt_scores, csv_pt_scores],
 
 
 
 
 
 
 
 
 
105
  outputs=[
106
  description,
107
  step_1,
@@ -112,6 +126,8 @@ def setup_app_event_handlers(
112
  tab3,
113
  tab4,
114
  files,
 
 
115
  video,
116
  examples,
117
  calculate_pt_scores,
@@ -120,6 +136,76 @@ def setup_app_event_handlers(
120
  pt_scores,
121
  csv_pt_scores,
122
  step_2,
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
123
  ],
124
  queue=True,
125
  )
@@ -141,13 +227,17 @@ def setup_app_event_handlers(
141
  [video],
142
  queue=True,
143
  )
 
 
 
 
 
 
 
144
  gr.on(
145
  triggers=[calculate_pt_scores.click],
146
  fn=event_handler_calculate_pt_scores_blocks,
147
- inputs=[
148
- languages,
149
- files,
150
- ],
151
  outputs=[
152
  notifications,
153
  pt_scores,
@@ -208,18 +298,78 @@ def setup_app_event_handlers(
208
  )
209
  examples.click(
210
  fn=event_handler_examples_blocks,
211
- inputs=[],
212
  outputs=[
 
213
  files,
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
214
  ],
215
  queue=True,
216
  )
217
  clear_app.click(
218
  fn=event_handler_clear_blocks,
219
- inputs=[languages],
220
  outputs=[
221
  notifications,
222
  files,
 
223
  video,
224
  calculate_pt_scores,
225
  clear_app,
@@ -280,7 +430,7 @@ def setup_app_event_handlers(
280
  )
281
  practical_tasks.change(
282
  event_handler_practical_tasks,
283
- [practical_tasks, practical_subtasks_selected],
284
  [practical_subtasks],
285
  queue=True,
286
  )
@@ -327,7 +477,9 @@ def setup_app_event_handlers(
327
  calculate_practical_task.click(
328
  fn=event_handler_calculate_practical_task_blocks,
329
  inputs=[
 
330
  files,
 
331
  practical_subtasks,
332
  pt_scores,
333
  dropdown_mbti,
 
9
 
10
  # Importing necessary components for the Gradio app
11
  from app.event_handlers.languages import event_handler_languages
12
+ from app.event_handlers.switching_modes import event_handler_switching_modes
13
  from app.event_handlers.files import (
14
  event_handler_files,
15
  event_handler_files_select,
16
  event_handler_files_delete,
17
  )
18
+ from app.event_handlers.webcam import event_handler_webcam
19
  from app.event_handlers.examples_blocks import event_handler_examples_blocks
20
  from app.event_handlers.clear_blocks import event_handler_clear_blocks
21
  from app.event_handlers.calculate_pt_scores_blocks import (
 
35
  step_1,
36
  notifications,
37
  files,
38
+ webcam,
39
+ switching_modes,
40
+ type_modes,
41
  video,
42
  examples,
43
  calculate_pt_scores,
 
106
  # Events
107
  languages.select(
108
  fn=event_handler_languages,
109
+ inputs=[
110
+ languages,
111
+ files,
112
+ video,
113
+ type_modes,
114
+ pt_scores,
115
+ csv_pt_scores,
116
+ practical_tasks,
117
+ practical_subtasks,
118
+ ],
119
  outputs=[
120
  description,
121
  step_1,
 
126
  tab3,
127
  tab4,
128
  files,
129
+ webcam,
130
+ switching_modes,
131
  video,
132
  examples,
133
  calculate_pt_scores,
 
136
  pt_scores,
137
  csv_pt_scores,
138
  step_2,
139
+ practical_tasks_column,
140
+ practical_tasks,
141
+ practical_subtasks,
142
+ ],
143
+ queue=True,
144
+ )
145
+ switching_modes.click(
146
+ fn=event_handler_switching_modes,
147
+ inputs=[languages, type_modes],
148
+ outputs=[
149
+ notifications,
150
+ files,
151
+ webcam,
152
+ switching_modes,
153
+ type_modes,
154
+ video,
155
+ calculate_pt_scores,
156
+ clear_app,
157
+ pt_scores,
158
+ csv_pt_scores,
159
+ step_2,
160
+ practical_tasks_column,
161
+ practical_tasks,
162
+ practical_subtasks,
163
+ practical_subtasks_selected,
164
+ settings_practical_tasks,
165
+ dropdown_mbti,
166
+ threshold_mbti,
167
+ threshold_professional_skills,
168
+ dropdown_professional_skills,
169
+ target_score_ope,
170
+ target_score_con,
171
+ target_score_ext,
172
+ target_score_agr,
173
+ target_score_nneu,
174
+ equal_coefficient,
175
+ number_priority,
176
+ number_importance_traits,
177
+ threshold_consumer_preferences,
178
+ dropdown_candidates,
179
+ number_openness,
180
+ number_conscientiousness,
181
+ number_extraversion,
182
+ number_agreeableness,
183
+ number_non_neuroticism,
184
+ sorted_videos,
185
+ sorted_videos_column,
186
+ practical_task_sorted,
187
+ csv_practical_task_sorted,
188
+ mbti_accordion,
189
+ mbti_description,
190
+ mbti_description_data,
191
+ video_sorted_column,
192
+ video_sorted,
193
+ metadata,
194
+ metadata_1,
195
+ name_row,
196
+ name_logo,
197
+ name,
198
+ surname_row,
199
+ surname_logo,
200
+ surname,
201
+ metadata_2,
202
+ email_row,
203
+ email_logo,
204
+ email,
205
+ phone_row,
206
+ phone_logo,
207
+ phone,
208
+ in_development,
209
  ],
210
  queue=True,
211
  )
 
227
  [video],
228
  queue=True,
229
  )
230
+ gr.on(
231
+ triggers=[webcam.upload, webcam.stop_recording],
232
+ fn=event_handler_webcam,
233
+ inputs=[languages, webcam, pt_scores],
234
+ outputs=[notifications, video, webcam, calculate_pt_scores, clear_app],
235
+ queue=True,
236
+ )
237
  gr.on(
238
  triggers=[calculate_pt_scores.click],
239
  fn=event_handler_calculate_pt_scores_blocks,
240
+ inputs=[languages, type_modes, files, video],
 
 
 
241
  outputs=[
242
  notifications,
243
  pt_scores,
 
298
  )
299
  examples.click(
300
  fn=event_handler_examples_blocks,
301
+ inputs=[languages],
302
  outputs=[
303
+ notifications,
304
  files,
305
+ webcam,
306
+ switching_modes,
307
+ type_modes,
308
+ video,
309
+ calculate_pt_scores,
310
+ clear_app,
311
+ pt_scores,
312
+ csv_pt_scores,
313
+ step_2,
314
+ practical_tasks_column,
315
+ practical_tasks,
316
+ practical_subtasks,
317
+ practical_subtasks_selected,
318
+ settings_practical_tasks,
319
+ dropdown_mbti,
320
+ threshold_mbti,
321
+ threshold_professional_skills,
322
+ dropdown_professional_skills,
323
+ target_score_ope,
324
+ target_score_con,
325
+ target_score_ext,
326
+ target_score_agr,
327
+ target_score_nneu,
328
+ equal_coefficient,
329
+ number_priority,
330
+ number_importance_traits,
331
+ threshold_consumer_preferences,
332
+ dropdown_candidates,
333
+ number_openness,
334
+ number_conscientiousness,
335
+ number_extraversion,
336
+ number_agreeableness,
337
+ number_non_neuroticism,
338
+ sorted_videos,
339
+ sorted_videos_column,
340
+ practical_task_sorted,
341
+ csv_practical_task_sorted,
342
+ mbti_accordion,
343
+ mbti_description,
344
+ mbti_description_data,
345
+ video_sorted_column,
346
+ video_sorted,
347
+ metadata,
348
+ metadata_1,
349
+ name_row,
350
+ name_logo,
351
+ name,
352
+ surname_row,
353
+ surname_logo,
354
+ surname,
355
+ metadata_2,
356
+ email_row,
357
+ email_logo,
358
+ email,
359
+ phone_row,
360
+ phone_logo,
361
+ phone,
362
+ in_development,
363
  ],
364
  queue=True,
365
  )
366
  clear_app.click(
367
  fn=event_handler_clear_blocks,
368
+ inputs=[languages, type_modes],
369
  outputs=[
370
  notifications,
371
  files,
372
+ webcam,
373
  video,
374
  calculate_pt_scores,
375
  clear_app,
 
430
  )
431
  practical_tasks.change(
432
  event_handler_practical_tasks,
433
+ [languages, practical_tasks, practical_subtasks_selected],
434
  [practical_subtasks],
435
  queue=True,
436
  )
 
477
  calculate_practical_task.click(
478
  fn=event_handler_calculate_practical_task_blocks,
479
  inputs=[
480
+ type_modes,
481
  files,
482
+ video,
483
  practical_subtasks,
484
  pt_scores,
485
  dropdown_mbti,
app/event_handlers/examples_blocks.py CHANGED
@@ -6,25 +6,177 @@ License: MIT License
6
  """
7
 
8
  import re
 
9
  from pathlib import Path
10
 
11
  # Importing necessary components for the Gradio app
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12
 
13
- # import hashlib
14
- # import time
15
 
16
- # for _ in range(6):
17
- # current_time = time.time()
18
- # time_bytes = str(current_time).encode("utf-8")
19
- # hash_object = hashlib.sha256(time_bytes)
20
- # hex_digest = hash_object.hexdigest()
21
- # print(hex_digest[:15])
22
 
 
23
 
24
- def event_handler_examples_blocks():
25
  videos_dir = Path("videos")
26
  video_files = sorted(
27
  (str(p) for p in videos_dir.glob("*.mp4")),
28
  key=lambda x: int(re.search(r"\d+", Path(x).stem).group()),
29
  )
30
- return video_files
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6
  """
7
 
8
  import re
9
+ import gradio as gr
10
  from pathlib import Path
11
 
12
  # Importing necessary components for the Gradio app
13
+ from app.config import config_data
14
+ from app.description_steps import STEP_2
15
+ from app.practical_tasks import supported_practical_tasks
16
+ from app.components import (
17
+ html_message,
18
+ files_create_ui,
19
+ video_create_ui,
20
+ button,
21
+ dataframe,
22
+ radio_create_ui,
23
+ number_create_ui,
24
+ dropdown_create_ui,
25
+ textbox_create_ui,
26
+ )
27
+ from app.utils import get_language_settings
28
 
 
 
29
 
30
+ def event_handler_examples_blocks(language):
31
+ lang_id, _ = get_language_settings(language)
 
 
 
 
32
 
33
+ first_practical_task = next(iter(supported_practical_tasks[lang_id]))
34
 
 
35
  videos_dir = Path("videos")
36
  video_files = sorted(
37
  (str(p) for p in videos_dir.glob("*.mp4")),
38
  key=lambda x: int(re.search(r"\d+", Path(x).stem).group()),
39
  )
40
+
41
+ files_ui = files_create_ui(
42
+ value=video_files,
43
+ label="{} ({})".format(
44
+ config_data.OtherMessages_VIDEO_FILES[lang_id],
45
+ ", ".join(config_data.Settings_SUPPORTED_VIDEO_EXT),
46
+ ),
47
+ file_types=[f".{ext}" for ext in config_data.Settings_SUPPORTED_VIDEO_EXT],
48
+ )
49
+ webcam = gr.Video(interactive=False, visible=False)
50
+ switching_modes = button(
51
+ config_data.OtherMessages_SWITCHEHG_MODES_ONLINE[lang_id],
52
+ True,
53
+ 1,
54
+ "./images/webcam.ico",
55
+ True,
56
+ "switching_modes",
57
+ )
58
+ type_modes_ui = gr.Radio(
59
+ choices=config_data.Settings_TYPE_MODES,
60
+ value=config_data.Settings_TYPE_MODES[0],
61
+ )
62
+
63
+ return (
64
+ html_message(config_data.InformationMessages_NOTI_VIDEOS[lang_id], False),
65
+ files_ui,
66
+ webcam,
67
+ switching_modes,
68
+ type_modes_ui,
69
+ video_create_ui(
70
+ value=video_files[0],
71
+ label=config_data.OtherMessages_VIDEO_PLAYER[lang_id],
72
+ file_name=Path(Path(video_files[0]).name).name,
73
+ ),
74
+ button(
75
+ config_data.OtherMessages_CALCULATE_PT_SCORES[lang_id],
76
+ False,
77
+ 3,
78
+ "./images/calculate_pt_scores.ico",
79
+ True,
80
+ "calculate_oceanai",
81
+ ),
82
+ button(
83
+ config_data.OtherMessages_CLEAR_APP[lang_id],
84
+ False,
85
+ 1,
86
+ "./images/clear.ico",
87
+ True,
88
+ "clear_oceanai",
89
+ ),
90
+ dataframe(visible=False),
91
+ files_create_ui(
92
+ None,
93
+ "single",
94
+ [".csv"],
95
+ config_data.OtherMessages_EXPORT_PT_SCORES[lang_id],
96
+ True,
97
+ False,
98
+ False,
99
+ "csv-container",
100
+ ),
101
+ gr.HTML(value=STEP_2[lang_id], visible=False),
102
+ gr.Column(visible=False),
103
+ radio_create_ui(
104
+ first_practical_task,
105
+ config_data.Labels_PRACTICAL_TASKS_LABEL[lang_id],
106
+ list(map(str, supported_practical_tasks[lang_id].keys())),
107
+ config_data.InformationMessages_PRACTICAL_TASKS_INFO[lang_id],
108
+ True,
109
+ True,
110
+ ),
111
+ radio_create_ui(
112
+ supported_practical_tasks[lang_id][first_practical_task][0],
113
+ config_data.Labels_PRACTICAL_SUBTASKS_LABEL[lang_id],
114
+ supported_practical_tasks[lang_id][first_practical_task],
115
+ config_data.InformationMessages_PRACTICAL_SUBTASKS_INFO[lang_id],
116
+ True,
117
+ True,
118
+ ),
119
+ gr.JSON(
120
+ value={
121
+ str(task): supported_practical_tasks[index].get(task, [None])[0]
122
+ for index in range(len(supported_practical_tasks))
123
+ for task in supported_practical_tasks[index].keys()
124
+ },
125
+ visible=False,
126
+ render=True,
127
+ ),
128
+ gr.Column(visible=False),
129
+ dropdown_create_ui(visible=False),
130
+ number_create_ui(visible=False),
131
+ number_create_ui(visible=False),
132
+ dropdown_create_ui(visible=False),
133
+ number_create_ui(visible=False),
134
+ number_create_ui(visible=False),
135
+ number_create_ui(visible=False),
136
+ number_create_ui(visible=False),
137
+ number_create_ui(visible=False),
138
+ number_create_ui(visible=False),
139
+ number_create_ui(visible=False),
140
+ number_create_ui(visible=False),
141
+ number_create_ui(visible=False),
142
+ dropdown_create_ui(visible=False),
143
+ number_create_ui(visible=False),
144
+ number_create_ui(visible=False),
145
+ number_create_ui(visible=False),
146
+ number_create_ui(visible=False),
147
+ number_create_ui(visible=False),
148
+ gr.Row(visible=False),
149
+ gr.Column(visible=False),
150
+ dataframe(visible=False),
151
+ files_create_ui(
152
+ None,
153
+ "single",
154
+ [".csv"],
155
+ config_data.OtherMessages_EXPORT_PS,
156
+ True,
157
+ False,
158
+ False,
159
+ "csv-container",
160
+ ),
161
+ gr.Accordion(visible=False),
162
+ gr.HTML(visible=False),
163
+ dataframe(visible=False),
164
+ gr.Column(visible=False),
165
+ video_create_ui(visible=False),
166
+ gr.Column(visible=False),
167
+ gr.Row(visible=False),
168
+ gr.Row(visible=False),
169
+ gr.Image(visible=False),
170
+ textbox_create_ui(visible=False),
171
+ gr.Row(visible=False),
172
+ gr.Image(visible=False),
173
+ textbox_create_ui(visible=False),
174
+ gr.Row(visible=False),
175
+ gr.Row(visible=False),
176
+ gr.Image(visible=False),
177
+ textbox_create_ui(visible=False),
178
+ gr.Row(visible=False),
179
+ gr.Image(visible=False),
180
+ textbox_create_ui(visible=False),
181
+ html_message(config_data.InformationMessages_NOTI_IN_DEV, False, False),
182
+ )
app/event_handlers/files.py CHANGED
@@ -1,7 +1,7 @@
1
  """
2
- File: search.py
3
  Author: Elena Ryumina and Dmitry Ryumin
4
- Description: Event handler for searching and filtering papers in the Gradio app.
5
  License: MIT License
6
  """
7
 
 
1
  """
2
+ File: files.py
3
  Author: Elena Ryumina and Dmitry Ryumin
4
+ Description: Event handler for files.
5
  License: MIT License
6
  """
7
 
app/event_handlers/languages.py CHANGED
@@ -19,12 +19,63 @@ from app.components import (
19
  button,
20
  html_message,
21
  dataframe,
 
22
  )
23
  from app.utils import get_language_settings
 
24
 
25
 
26
- def event_handler_languages(languages, files, video, pt_scores, csv_pt_scores):
 
 
 
 
 
 
 
 
 
27
  lang_id, choices = get_language_settings(languages)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
28
 
29
  if not video:
30
  video = video_create_ui(label=config_data.OtherMessages_VIDEO_PLAYER[lang_id])
@@ -57,6 +108,10 @@ def event_handler_languages(languages, files, video, pt_scores, csv_pt_scores):
57
  value=STEP_2[lang_id], visible=True if pt_scores.shape[1] >= 7 else False
58
  )
59
 
 
 
 
 
60
  if pt_scores.shape[1] >= 7:
61
  pt_scores = dataframe(
62
  headers=(config_data.Dataframes_PT_SCORES[lang_id]),
@@ -66,6 +121,22 @@ def event_handler_languages(languages, files, video, pt_scores, csv_pt_scores):
66
  else:
67
  pt_scores = dataframe(visible=False)
68
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
69
  return (
70
  gr.Markdown(value=DESCRIPTIONS[lang_id]),
71
  gr.HTML(value=STEP_1[lang_id]),
@@ -85,14 +156,9 @@ def event_handler_languages(languages, files, video, pt_scores, csv_pt_scores):
85
  gr.Tab(config_data.Labels_ABOUT_APP_LABEL[lang_id]),
86
  gr.Tab(config_data.Labels_ABOUT_AUTHORS_LABEL[lang_id]),
87
  gr.Tab(config_data.Labels_REQUIREMENTS_LABEL[lang_id]),
88
- files_create_ui(
89
- value=files,
90
- label="{} ({})".format(
91
- config_data.OtherMessages_VIDEO_FILES[lang_id],
92
- ", ".join(config_data.Settings_SUPPORTED_VIDEO_EXT),
93
- ),
94
- file_types=[f".{ext}" for ext in config_data.Settings_SUPPORTED_VIDEO_EXT],
95
- ),
96
  video,
97
  button(
98
  config_data.OtherMessages_EXAMPLES_APP[lang_id],
@@ -122,4 +188,21 @@ def event_handler_languages(languages, files, video, pt_scores, csv_pt_scores):
122
  pt_scores,
123
  csv_pt_scores,
124
  step_2,
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
125
  )
 
19
  button,
20
  html_message,
21
  dataframe,
22
+ radio_create_ui,
23
  )
24
  from app.utils import get_language_settings
25
+ from app.practical_tasks import supported_practical_tasks
26
 
27
 
28
+ def event_handler_languages(
29
+ languages,
30
+ files,
31
+ video,
32
+ type_modes,
33
+ pt_scores,
34
+ csv_pt_scores,
35
+ practical_tasks,
36
+ practical_subtasks,
37
+ ):
38
  lang_id, choices = get_language_settings(languages)
39
+ lang_id_inverse = {0: 1, 1: 0}.get(lang_id, None)
40
+
41
+ if type_modes == config_data.Settings_TYPE_MODES[0]:
42
+ files_ui = files_create_ui(
43
+ label="{} ({})".format(
44
+ config_data.OtherMessages_VIDEO_FILES[
45
+ config_data.AppSettings_DEFAULT_LANG_ID
46
+ ],
47
+ ", ".join(config_data.Settings_SUPPORTED_VIDEO_EXT),
48
+ ),
49
+ file_types=[f".{ext}" for ext in config_data.Settings_SUPPORTED_VIDEO_EXT],
50
+ )
51
+ webcam = gr.Video(interactive=False, visible=False)
52
+ switching_modes = button(
53
+ config_data.OtherMessages_SWITCHEHG_MODES_ONLINE[lang_id],
54
+ True,
55
+ 1,
56
+ "./images/webcam.ico",
57
+ True,
58
+ "switching_modes",
59
+ )
60
+ elif type_modes == config_data.Settings_TYPE_MODES[1]:
61
+ files_ui = files_create_ui(
62
+ label="{} ({})".format(
63
+ config_data.OtherMessages_VIDEO_FILES[lang_id],
64
+ ", ".join(config_data.Settings_SUPPORTED_VIDEO_EXT),
65
+ ),
66
+ file_types=[f".{ext}" for ext in config_data.Settings_SUPPORTED_VIDEO_EXT],
67
+ interactive=False,
68
+ visible=False,
69
+ )
70
+ webcam = gr.Video(interactive=True, visible=True)
71
+ switching_modes = button(
72
+ config_data.OtherMessages_SWITCHEHG_MODES_OFFLINE[lang_id],
73
+ True,
74
+ 1,
75
+ "./images/videos.ico",
76
+ True,
77
+ "switching_modes",
78
+ )
79
 
80
  if not video:
81
  video = video_create_ui(label=config_data.OtherMessages_VIDEO_PLAYER[lang_id])
 
108
  value=STEP_2[lang_id], visible=True if pt_scores.shape[1] >= 7 else False
109
  )
110
 
111
+ practical_tasks_column = gr.Column(
112
+ visible=True if pt_scores.shape[1] >= 7 else False
113
+ )
114
+
115
  if pt_scores.shape[1] >= 7:
116
  pt_scores = dataframe(
117
  headers=(config_data.Dataframes_PT_SCORES[lang_id]),
 
121
  else:
122
  pt_scores = dataframe(visible=False)
123
 
124
+ current_lang_tasks = list(map(str, supported_practical_tasks[lang_id].keys()))
125
+ inverse_lang_tasks = list(
126
+ map(str, supported_practical_tasks[lang_id_inverse].keys())
127
+ )
128
+
129
+ if practical_tasks in inverse_lang_tasks:
130
+ practical_task = current_lang_tasks[inverse_lang_tasks.index(practical_tasks)]
131
+ else:
132
+ practical_task = next(iter(supported_practical_tasks[lang_id]))
133
+
134
+ print(current_lang_tasks, "\n")
135
+ print(inverse_lang_tasks, "\n")
136
+ print(practical_tasks, "\n")
137
+ print(supported_practical_tasks, "\n")
138
+ print(practical_subtasks, "\n")
139
+
140
  return (
141
  gr.Markdown(value=DESCRIPTIONS[lang_id]),
142
  gr.HTML(value=STEP_1[lang_id]),
 
156
  gr.Tab(config_data.Labels_ABOUT_APP_LABEL[lang_id]),
157
  gr.Tab(config_data.Labels_ABOUT_AUTHORS_LABEL[lang_id]),
158
  gr.Tab(config_data.Labels_REQUIREMENTS_LABEL[lang_id]),
159
+ files_ui,
160
+ webcam,
161
+ switching_modes,
 
 
 
 
 
162
  video,
163
  button(
164
  config_data.OtherMessages_EXAMPLES_APP[lang_id],
 
188
  pt_scores,
189
  csv_pt_scores,
190
  step_2,
191
+ practical_tasks_column,
192
+ radio_create_ui(
193
+ practical_task,
194
+ config_data.Labels_PRACTICAL_TASKS_LABEL[lang_id],
195
+ current_lang_tasks,
196
+ config_data.InformationMessages_PRACTICAL_TASKS_INFO[lang_id],
197
+ True,
198
+ True,
199
+ ),
200
+ radio_create_ui(
201
+ supported_practical_tasks[lang_id][practical_task][0],
202
+ config_data.Labels_PRACTICAL_SUBTASKS_LABEL[lang_id],
203
+ supported_practical_tasks[lang_id][practical_task],
204
+ config_data.InformationMessages_PRACTICAL_SUBTASKS_INFO[lang_id],
205
+ True,
206
+ True,
207
+ ),
208
  )
app/event_handlers/practical_tasks.py CHANGED
@@ -9,14 +9,19 @@ License: MIT License
9
  from app.config import config_data
10
  from app.practical_tasks import supported_practical_tasks
11
  from app.components import radio_create_ui
 
12
 
13
 
14
- def event_handler_practical_tasks(practical_tasks, practical_subtasks_selected):
 
 
 
 
15
  return radio_create_ui(
16
  practical_subtasks_selected[practical_tasks],
17
- config_data.Labels_PRACTICAL_SUBTASKS_LABEL,
18
- supported_practical_tasks[practical_tasks],
19
- config_data.InformationMessages_PRACTICAL_SUBTASKS_INFO,
20
  True,
21
  True,
22
  )
 
9
  from app.config import config_data
10
  from app.practical_tasks import supported_practical_tasks
11
  from app.components import radio_create_ui
12
+ from app.utils import get_language_settings
13
 
14
 
15
+ def event_handler_practical_tasks(
16
+ language, practical_tasks, practical_subtasks_selected
17
+ ):
18
+ lang_id, _ = get_language_settings(language)
19
+
20
  return radio_create_ui(
21
  practical_subtasks_selected[practical_tasks],
22
+ config_data.Labels_PRACTICAL_SUBTASKS_LABEL[lang_id],
23
+ supported_practical_tasks[lang_id][practical_tasks],
24
+ config_data.InformationMessages_PRACTICAL_SUBTASKS_INFO[lang_id],
25
  True,
26
  True,
27
  )
app/event_handlers/switching_modes.py ADDED
@@ -0,0 +1,193 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ File: switching_modes.py
3
+ Author: Elena Ryumina and Dmitry Ryumin
4
+ Description: Event handler for switching modes.
5
+ License: MIT License
6
+ """
7
+
8
+ import gradio as gr
9
+
10
+ # Importing necessary components for the Gradio app
11
+ from app.config import config_data
12
+ from app.description_steps import STEP_2
13
+ from app.practical_tasks import supported_practical_tasks
14
+ from app.components import (
15
+ html_message,
16
+ files_create_ui,
17
+ video_create_ui,
18
+ button,
19
+ dataframe,
20
+ radio_create_ui,
21
+ number_create_ui,
22
+ dropdown_create_ui,
23
+ textbox_create_ui,
24
+ )
25
+ from app.utils import get_language_settings
26
+
27
+
28
+ def event_handler_switching_modes(language, type_modes):
29
+ lang_id, _ = get_language_settings(language)
30
+
31
+ first_practical_task = next(iter(supported_practical_tasks[lang_id]))
32
+
33
+ if type_modes == config_data.Settings_TYPE_MODES[0]:
34
+ files_ui = files_create_ui(
35
+ label="{} ({})".format(
36
+ config_data.OtherMessages_VIDEO_FILES[lang_id],
37
+ ", ".join(config_data.Settings_SUPPORTED_VIDEO_EXT),
38
+ ),
39
+ file_types=[f".{ext}" for ext in config_data.Settings_SUPPORTED_VIDEO_EXT],
40
+ interactive=False,
41
+ visible=False,
42
+ )
43
+ webcam = gr.Video(interactive=True, visible=True)
44
+ switching_modes = button(
45
+ config_data.OtherMessages_SWITCHEHG_MODES_OFFLINE[lang_id],
46
+ True,
47
+ 1,
48
+ "./images/videos.ico",
49
+ True,
50
+ "switching_modes",
51
+ )
52
+ type_modes_ui = gr.Radio(
53
+ choices=config_data.Settings_TYPE_MODES,
54
+ value=config_data.Settings_TYPE_MODES[1],
55
+ )
56
+ elif type_modes == config_data.Settings_TYPE_MODES[1]:
57
+ files_ui = files_create_ui(
58
+ label="{} ({})".format(
59
+ config_data.OtherMessages_VIDEO_FILES[lang_id],
60
+ ", ".join(config_data.Settings_SUPPORTED_VIDEO_EXT),
61
+ ),
62
+ file_types=[f".{ext}" for ext in config_data.Settings_SUPPORTED_VIDEO_EXT],
63
+ )
64
+ webcam = gr.Video(interactive=False, visible=False)
65
+ switching_modes = button(
66
+ config_data.OtherMessages_SWITCHEHG_MODES_ONLINE[lang_id],
67
+ True,
68
+ 1,
69
+ "./images/webcam.ico",
70
+ True,
71
+ "switching_modes",
72
+ )
73
+ type_modes_ui = gr.Radio(
74
+ choices=config_data.Settings_TYPE_MODES,
75
+ value=config_data.Settings_TYPE_MODES[0],
76
+ )
77
+
78
+ return (
79
+ html_message(config_data.InformationMessages_NOTI_VIDEOS[lang_id], False),
80
+ files_ui,
81
+ webcam,
82
+ switching_modes,
83
+ type_modes_ui,
84
+ video_create_ui(),
85
+ button(
86
+ config_data.OtherMessages_CALCULATE_PT_SCORES[lang_id],
87
+ False,
88
+ 3,
89
+ "./images/calculate_pt_scores.ico",
90
+ True,
91
+ "calculate_oceanai",
92
+ ),
93
+ button(
94
+ config_data.OtherMessages_CLEAR_APP[lang_id],
95
+ False,
96
+ 1,
97
+ "./images/clear.ico",
98
+ True,
99
+ "clear_oceanai",
100
+ ),
101
+ dataframe(visible=False),
102
+ files_create_ui(
103
+ None,
104
+ "single",
105
+ [".csv"],
106
+ config_data.OtherMessages_EXPORT_PT_SCORES[lang_id],
107
+ True,
108
+ False,
109
+ False,
110
+ "csv-container",
111
+ ),
112
+ gr.HTML(value=STEP_2[lang_id], visible=False),
113
+ gr.Column(visible=False),
114
+ radio_create_ui(
115
+ first_practical_task,
116
+ config_data.Labels_PRACTICAL_TASKS_LABEL[lang_id],
117
+ list(map(str, supported_practical_tasks[lang_id].keys())),
118
+ config_data.InformationMessages_PRACTICAL_TASKS_INFO[lang_id],
119
+ True,
120
+ True,
121
+ ),
122
+ radio_create_ui(
123
+ supported_practical_tasks[lang_id][first_practical_task][0],
124
+ config_data.Labels_PRACTICAL_SUBTASKS_LABEL[lang_id],
125
+ supported_practical_tasks[lang_id][first_practical_task],
126
+ config_data.InformationMessages_PRACTICAL_SUBTASKS_INFO[lang_id],
127
+ True,
128
+ True,
129
+ ),
130
+ gr.JSON(
131
+ value={
132
+ str(task): supported_practical_tasks[index].get(task, [None])[0]
133
+ for index in range(len(supported_practical_tasks))
134
+ for task in supported_practical_tasks[index].keys()
135
+ },
136
+ visible=False,
137
+ render=True,
138
+ ),
139
+ gr.Column(visible=False),
140
+ dropdown_create_ui(visible=False),
141
+ number_create_ui(visible=False),
142
+ number_create_ui(visible=False),
143
+ dropdown_create_ui(visible=False),
144
+ number_create_ui(visible=False),
145
+ number_create_ui(visible=False),
146
+ number_create_ui(visible=False),
147
+ number_create_ui(visible=False),
148
+ number_create_ui(visible=False),
149
+ number_create_ui(visible=False),
150
+ number_create_ui(visible=False),
151
+ number_create_ui(visible=False),
152
+ number_create_ui(visible=False),
153
+ dropdown_create_ui(visible=False),
154
+ number_create_ui(visible=False),
155
+ number_create_ui(visible=False),
156
+ number_create_ui(visible=False),
157
+ number_create_ui(visible=False),
158
+ number_create_ui(visible=False),
159
+ gr.Row(visible=False),
160
+ gr.Column(visible=False),
161
+ dataframe(visible=False),
162
+ files_create_ui(
163
+ None,
164
+ "single",
165
+ [".csv"],
166
+ config_data.OtherMessages_EXPORT_PS,
167
+ True,
168
+ False,
169
+ False,
170
+ "csv-container",
171
+ ),
172
+ gr.Accordion(visible=False),
173
+ gr.HTML(visible=False),
174
+ dataframe(visible=False),
175
+ gr.Column(visible=False),
176
+ video_create_ui(visible=False),
177
+ gr.Column(visible=False),
178
+ gr.Row(visible=False),
179
+ gr.Row(visible=False),
180
+ gr.Image(visible=False),
181
+ textbox_create_ui(visible=False),
182
+ gr.Row(visible=False),
183
+ gr.Image(visible=False),
184
+ textbox_create_ui(visible=False),
185
+ gr.Row(visible=False),
186
+ gr.Row(visible=False),
187
+ gr.Image(visible=False),
188
+ textbox_create_ui(visible=False),
189
+ gr.Row(visible=False),
190
+ gr.Image(visible=False),
191
+ textbox_create_ui(visible=False),
192
+ html_message(config_data.InformationMessages_NOTI_IN_DEV, False, False),
193
+ )
app/event_handlers/webcam.py ADDED
@@ -0,0 +1,74 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ File: webcam.py
3
+ Author: Elena Ryumina and Dmitry Ryumin
4
+ Description: Event handler for webcam.
5
+ License: MIT License
6
+ """
7
+
8
+ import gradio as gr
9
+ from pathlib import Path
10
+
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, webm2mp4
15
+
16
+
17
+ def event_handler_webcam(language, webcam, pt_scores):
18
+ lang_id, _ = get_language_settings(language)
19
+
20
+ if not webcam:
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
+ gr.Video(value=None),
25
+ button(
26
+ config_data.OtherMessages_CALCULATE_PT_SCORES[lang_id],
27
+ False,
28
+ 3,
29
+ "./images/calculate_pt_scores.ico",
30
+ True,
31
+ "calculate_oceanai",
32
+ ),
33
+ button(
34
+ config_data.OtherMessages_CLEAR_APP[lang_id],
35
+ False,
36
+ 1,
37
+ "./images/clear.ico",
38
+ True,
39
+ "clear_oceanai",
40
+ ),
41
+ )
42
+
43
+ if webcam.split(".")[-1] == "webm":
44
+ webcam = webm2mp4(webcam)
45
+
46
+ return (
47
+ html_message(
48
+ config_data.OtherMessages_NOTI_CALCULATE[lang_id],
49
+ True,
50
+ False if pt_scores.shape[1] >= 7 else True,
51
+ ),
52
+ video_create_ui(
53
+ value=webcam,
54
+ label=config_data.OtherMessages_VIDEO_PLAYER[lang_id],
55
+ file_name=Path(Path(webcam).name).name,
56
+ ),
57
+ gr.Video(value=None),
58
+ button(
59
+ config_data.OtherMessages_CALCULATE_PT_SCORES[lang_id],
60
+ True,
61
+ 3,
62
+ "./images/calculate_pt_scores.ico",
63
+ True,
64
+ "calculate_oceanai",
65
+ ),
66
+ button(
67
+ config_data.OtherMessages_CLEAR_APP[lang_id],
68
+ True,
69
+ 1,
70
+ "./images/clear.ico",
71
+ True,
72
+ "clear_oceanai",
73
+ ),
74
+ )
app/port.py ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ File: port.py
3
+ Author: Elena Ryumina and Dmitry Ryumin
4
+ Description: Utility functions to check and free ports by terminating processes holding them.
5
+ License: MIT License
6
+ """
7
+
8
+ import socket
9
+ import psutil
10
+ from typing import Iterable, Union
11
+
12
+
13
+ def is_port_in_use(host: str, port: int) -> bool:
14
+ try:
15
+ with socket.create_connection((host, port), timeout=1):
16
+ return True
17
+ except (ConnectionRefusedError, OSError):
18
+ return False
19
+
20
+
21
+ def free_ports(ports: Union[int, Iterable[int]]) -> None:
22
+ ports_to_free = {ports} if isinstance(ports, int) else set(ports)
23
+
24
+ for proc in psutil.process_iter(attrs=["pid", "name"]):
25
+ try:
26
+ connections = proc.net_connections(kind="inet")
27
+ for conn in connections:
28
+ if conn.laddr.port in ports_to_free:
29
+ proc.terminate()
30
+ proc.wait()
31
+ ports_to_free.discard(conn.laddr.port)
32
+ if not ports_to_free:
33
+ return
34
+ except (psutil.NoSuchProcess, psutil.AccessDenied, psutil.ZombieProcess):
35
+ continue
app/practical_tasks.py CHANGED
@@ -11,17 +11,27 @@ from typing import Dict, List
11
  # Importing necessary components for the Gradio app
12
 
13
 
14
- def load_practical_tasks_data(file_path: str) -> List:
15
- with open(file_path, "r") as file:
16
- return yaml.safe_load(file) or []
17
 
 
 
 
 
18
 
19
- def transform_practical_tasks_data(data: List) -> Dict:
20
- output_dict = {item["task"]: item["subtasks"] for item in data}
21
 
22
- return output_dict
23
 
 
 
24
 
25
- yaml_file_path = "./practical_tasks.yaml"
26
- practical_tasks_data = load_practical_tasks_data(yaml_file_path)
 
 
 
 
 
 
 
27
  supported_practical_tasks = transform_practical_tasks_data(practical_tasks_data)
 
11
  # Importing necessary components for the Gradio app
12
 
13
 
14
+ def load_practical_tasks_data(file_paths: List[str]) -> List[Dict]:
15
+ all_tasks_data = []
 
16
 
17
+ for file_path in file_paths:
18
+ with open(file_path, "r") as file:
19
+ data = yaml.safe_load(file) or []
20
+ all_tasks_data.append(data)
21
 
22
+ return all_tasks_data
 
23
 
 
24
 
25
+ def transform_practical_tasks_data(data: List[Dict]) -> List[Dict]:
26
+ output_list = []
27
 
28
+ for task_data in data:
29
+ output_dict = {item["task"]: item["subtasks"] for item in task_data}
30
+ output_list.append(output_dict)
31
+
32
+ return output_list
33
+
34
+
35
+ yaml_file_paths = ["./practical_tasks_en.yaml", "./practical_tasks_ru.yaml"]
36
+ practical_tasks_data = load_practical_tasks_data(yaml_file_paths)
37
  supported_practical_tasks = transform_practical_tasks_data(practical_tasks_data)
app/tabs.py CHANGED
@@ -37,16 +37,59 @@ def app_tab():
37
 
38
  step_1 = gr.HTML(value=STEP_1[config_data.AppSettings_DEFAULT_LANG_ID])
39
 
40
- with gr.Row():
41
- files = files_create_ui(
42
- label="{} ({})".format(
43
- config_data.OtherMessages_VIDEO_FILES[
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
44
  config_data.AppSettings_DEFAULT_LANG_ID
45
  ],
46
- ", ".join(config_data.Settings_SUPPORTED_VIDEO_EXT),
47
- ),
48
- file_types=[f".{ext}" for ext in config_data.Settings_SUPPORTED_VIDEO_EXT],
49
- )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
50
 
51
  video = video_create_ui()
52
 
@@ -108,23 +151,42 @@ def app_tab():
108
  value=STEP_2[config_data.AppSettings_DEFAULT_LANG_ID], visible=False
109
  )
110
 
111
- first_practical_task = next(iter(supported_practical_tasks))
 
 
112
 
113
  with gr.Column(scale=1, visible=False, render=True) as practical_tasks_column:
114
  practical_tasks = radio_create_ui(
115
  first_practical_task,
116
  config_data.Labels_PRACTICAL_TASKS_LABEL,
117
- list(map(str, supported_practical_tasks.keys())),
118
- config_data.InformationMessages_PRACTICAL_TASKS_INFO,
 
 
 
 
 
 
 
 
 
119
  True,
120
  True,
121
  )
122
 
123
  practical_subtasks = radio_create_ui(
124
- supported_practical_tasks[first_practical_task][0],
125
- config_data.Labels_PRACTICAL_SUBTASKS_LABEL,
126
- supported_practical_tasks[first_practical_task],
127
- config_data.InformationMessages_PRACTICAL_SUBTASKS_INFO,
 
 
 
 
 
 
 
 
128
  True,
129
  True,
130
  )
@@ -481,6 +543,7 @@ def app_tab():
481
  visible=False,
482
  show_download_button=False,
483
  elem_classes="metadata_name-logo",
 
484
  )
485
 
486
  name = textbox_create_ui(
@@ -512,6 +575,7 @@ def app_tab():
512
  visible=False,
513
  show_download_button=False,
514
  elem_classes="metadata_surname-logo",
 
515
  )
516
 
517
  surname = textbox_create_ui(
@@ -545,6 +609,7 @@ def app_tab():
545
  visible=False,
546
  show_download_button=False,
547
  elem_classes="metadata_email-logo",
 
548
  )
549
 
550
  email = textbox_create_ui(
@@ -576,6 +641,7 @@ def app_tab():
576
  visible=False,
577
  show_download_button=False,
578
  elem_classes="metadata_phone-logo",
 
579
  )
580
 
581
  phone = textbox_create_ui(
@@ -595,8 +661,9 @@ def app_tab():
595
 
596
  practical_subtasks_selected = gr.JSON(
597
  value={
598
- str(task): supported_practical_tasks.get(task, [None])[0]
599
- for task in supported_practical_tasks.keys()
 
600
  },
601
  visible=False,
602
  render=True,
@@ -611,6 +678,9 @@ def app_tab():
611
  step_1,
612
  notifications,
613
  files,
 
 
 
614
  video,
615
  examples,
616
  calculate_pt_scores,
 
37
 
38
  step_1 = gr.HTML(value=STEP_1[config_data.AppSettings_DEFAULT_LANG_ID])
39
 
40
+ with gr.Row(elem_classes="media-container"):
41
+ with gr.Column():
42
+ files = files_create_ui(
43
+ label="{} ({})".format(
44
+ config_data.OtherMessages_VIDEO_FILES[
45
+ config_data.AppSettings_DEFAULT_LANG_ID
46
+ ],
47
+ ", ".join(config_data.Settings_SUPPORTED_VIDEO_EXT),
48
+ ),
49
+ file_types=[
50
+ f".{ext}" for ext in config_data.Settings_SUPPORTED_VIDEO_EXT
51
+ ],
52
+ )
53
+
54
+ webcam = gr.Video(
55
+ label="{} ({})".format(
56
+ config_data.OtherMessages_VIDEO_FILES[
57
+ config_data.AppSettings_DEFAULT_LANG_ID
58
+ ],
59
+ ", ".join(config_data.Settings_SUPPORTED_VIDEO_EXT),
60
+ ),
61
+ show_label=True,
62
+ interactive=False,
63
+ visible=False,
64
+ mirror_webcam=False,
65
+ include_audio=True,
66
+ elem_classes="webcam",
67
+ autoplay=False,
68
+ )
69
+
70
+ switching_modes = button(
71
+ config_data.OtherMessages_SWITCHEHG_MODES_ONLINE[
72
  config_data.AppSettings_DEFAULT_LANG_ID
73
  ],
74
+ True,
75
+ 1,
76
+ "./images/webcam.ico",
77
+ True,
78
+ "switching_modes",
79
+ )
80
+
81
+ type_modes = gr.Radio(
82
+ choices=config_data.Settings_TYPE_MODES,
83
+ value=config_data.Settings_TYPE_MODES[0],
84
+ label=None,
85
+ info=None,
86
+ show_label=False,
87
+ container=False,
88
+ interactive=False,
89
+ visible=False,
90
+ render=True,
91
+ elem_classes="type_modes",
92
+ )
93
 
94
  video = video_create_ui()
95
 
 
151
  value=STEP_2[config_data.AppSettings_DEFAULT_LANG_ID], visible=False
152
  )
153
 
154
+ first_practical_task = next(
155
+ iter(supported_practical_tasks[config_data.AppSettings_DEFAULT_LANG_ID])
156
+ )
157
 
158
  with gr.Column(scale=1, visible=False, render=True) as practical_tasks_column:
159
  practical_tasks = radio_create_ui(
160
  first_practical_task,
161
  config_data.Labels_PRACTICAL_TASKS_LABEL,
162
+ list(
163
+ map(
164
+ str,
165
+ supported_practical_tasks[
166
+ config_data.AppSettings_DEFAULT_LANG_ID
167
+ ].keys(),
168
+ )
169
+ ),
170
+ config_data.InformationMessages_PRACTICAL_TASKS_INFO[
171
+ config_data.AppSettings_DEFAULT_LANG_ID
172
+ ],
173
  True,
174
  True,
175
  )
176
 
177
  practical_subtasks = radio_create_ui(
178
+ supported_practical_tasks[config_data.AppSettings_DEFAULT_LANG_ID][
179
+ first_practical_task
180
+ ][0],
181
+ config_data.Labels_PRACTICAL_SUBTASKS_LABEL[
182
+ config_data.AppSettings_DEFAULT_LANG_ID
183
+ ],
184
+ supported_practical_tasks[config_data.AppSettings_DEFAULT_LANG_ID][
185
+ first_practical_task
186
+ ],
187
+ config_data.InformationMessages_PRACTICAL_SUBTASKS_INFO[
188
+ config_data.AppSettings_DEFAULT_LANG_ID
189
+ ],
190
  True,
191
  True,
192
  )
 
543
  visible=False,
544
  show_download_button=False,
545
  elem_classes="metadata_name-logo",
546
+ show_fullscreen_button=False,
547
  )
548
 
549
  name = textbox_create_ui(
 
575
  visible=False,
576
  show_download_button=False,
577
  elem_classes="metadata_surname-logo",
578
+ show_fullscreen_button=False,
579
  )
580
 
581
  surname = textbox_create_ui(
 
609
  visible=False,
610
  show_download_button=False,
611
  elem_classes="metadata_email-logo",
612
+ show_fullscreen_button=False,
613
  )
614
 
615
  email = textbox_create_ui(
 
641
  visible=False,
642
  show_download_button=False,
643
  elem_classes="metadata_phone-logo",
644
+ show_fullscreen_button=False,
645
  )
646
 
647
  phone = textbox_create_ui(
 
661
 
662
  practical_subtasks_selected = gr.JSON(
663
  value={
664
+ str(task): supported_practical_tasks[index].get(task, [None])[0]
665
+ for index in range(len(supported_practical_tasks))
666
+ for task in supported_practical_tasks[index].keys()
667
  },
668
  visible=False,
669
  render=True,
 
678
  step_1,
679
  notifications,
680
  files,
681
+ webcam,
682
+ switching_modes,
683
+ type_modes,
684
  video,
685
  examples,
686
  calculate_pt_scores,
app/utils.py CHANGED
@@ -6,6 +6,8 @@ License: MIT License
6
  """
7
 
8
  import pandas as pd
 
 
9
 
10
  # Importing necessary components for the Gradio app
11
  from app.config import config_data
@@ -84,3 +86,27 @@ def extract_profession_weights(df, dropdown_candidates):
84
  weights_professions = list(map(int, weights_professions))
85
 
86
  return weights_professions, interactive_professions
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6
  """
7
 
8
  import pandas as pd
9
+ import subprocess
10
+ from pathlib import Path
11
 
12
  # Importing necessary components for the Gradio app
13
  from app.config import config_data
 
86
  weights_professions = list(map(int, weights_professions))
87
 
88
  return weights_professions, interactive_professions
89
+
90
+
91
+ def webm2mp4(input_file):
92
+ input_path = Path(input_file)
93
+ output_path = input_path.with_suffix(".mp4")
94
+
95
+ if not output_path.exists():
96
+ subprocess.run(
97
+ [
98
+ "ffmpeg",
99
+ "-i",
100
+ str(input_path),
101
+ "-c:v",
102
+ "copy",
103
+ "-c:a",
104
+ "aac",
105
+ "-strict",
106
+ "experimental",
107
+ str(output_path),
108
+ ],
109
+ check=True,
110
+ )
111
+
112
+ return str(output_path)
config.toml CHANGED
@@ -1,5 +1,7 @@
1
  [AppSettings]
2
- APP_VERSION = "0.9.2"
 
 
3
  CSS_PATH = "app.css"
4
  DEFAULT_LANG_ID = 0
5
 
@@ -9,8 +11,8 @@ DESCRIPTIONS = [
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"
15
  DROPDOWN_MBTI_INFO = "What personality type indicator are you interested in?"
16
  DROPDOWN_PROFESSIONAL_SKILLS_INFO = "What professional skill are you interested in?"
@@ -31,8 +33,14 @@ STEP_2 = [
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", "Примеры"]
@@ -45,14 +53,16 @@ EXPORT_WT = "Export ranking effective work teams results to a CSV file"
45
  EXPORT_CP = "Export consumer preferences for industrial goods results to a CSV file"
46
  EXPORT_MBTI = "Export ranking personality type results to a CSV file"
47
  NOTI_CALCULATE = ["You can calculate Big Five personality traits scores", "Вы можете рассчитать показатели Большой пятерки персональных качеств личности человека"]
 
 
48
 
49
  [Labels]
50
  APP_LABEL = ["⭐ App", "⭐ Приложение"]
51
  ABOUT_APP_LABEL = ["💡 About the App", "💡 О приложении"]
52
  ABOUT_AUTHORS_LABEL = ["🎭 About the Authors", "🎭 Об авторах"]
53
  REQUIREMENTS_LABEL = ["📋 Requirements", "📋 Зависимости"]
54
- PRACTICAL_TASKS_LABEL = "Practical tasks"
55
- PRACTICAL_SUBTASKS_LABEL = "Practical subtasks"
56
  THRESHOLD_MBTI_LABEL = "Polarity traits threshold"
57
  THRESHOLD_PROFESSIONAL_SKILLS_LABEL = "Polarity traits threshold"
58
  TARGET_SCORE_OPE_LABEL = "Openness target score"
@@ -140,6 +150,7 @@ DROPDOWN_MBTI = [
140
  DROPDOWN_MBTI_DEL_COLS = ["EI", "SN", "TF", "JP", "Match"]
141
  SHOW_VIDEO_METADATA = true
142
  SUPPORTED_VIDEO_EXT = ["mp4", "mov", "avi", "flv"]
 
143
 
144
  [Values]
145
  TARGET_SCORES = [0.527886, 0.522337, 0.458468, 0.51761, 0.444649]
 
1
  [AppSettings]
2
+ APP_VERSION = "0.10.0"
3
+ SERVER_NAME = "127.0.0.1"
4
+ PORT = 7860
5
  CSS_PATH = "app.css"
6
  DEFAULT_LANG_ID = 0
7
 
 
11
  "- библиотека с открытым исходным кодом для оценивания большой пятерки качеств личности человека и автоматизации HR-процессов",
12
  ]
13
  NOTI_VIDEOS = ["Select the video(s)", "Выберите видео"]
14
+ PRACTICAL_TASKS_INFO = ["Choose a practical task", "Выберите практическую задачу"]
15
+ PRACTICAL_SUBTASKS_INFO = ["Choose a practical subtask", "Выберите практическую подзадачу"]
16
  NOTI_IN_DEV = "In development"
17
  DROPDOWN_MBTI_INFO = "What personality type indicator are you interested in?"
18
  DROPDOWN_PROFESSIONAL_SKILLS_INFO = "What professional skill are you interested in?"
 
33
  [OtherMessages]
34
  VIDEO_FILES = ["Video Files", "Видеофайлы"]
35
  VIDEO_PLAYER = ["Video Player", "Видео проигрыватель"]
36
+ CALCULATE_PT_SCORES = [
37
+ "Calculation of Big Five personality traits scores",
38
+ "Вычисление показателей Большой пятерки персональных качеств личности человека"
39
+ ]
40
+ CALCULATE_PT_SCORES_ERR = [
41
+ "Personality traits scores have not been calculated. Ensure that there are uncovered face and speech of person in the video",
42
+ "Оценки персональных качеств личностей человека не были вычислены. Убедитесь, что в видео присутствует не перекрытое лицо и речь человека"
43
+ ]
44
  CALCULATE_PRACTICAL_TASK = "Solving practical task"
45
  CLEAR_APP = ["Clear", "Сброс"]
46
  EXAMPLES_APP = ["Examples", "Примеры"]
 
53
  EXPORT_CP = "Export consumer preferences for industrial goods results to a CSV file"
54
  EXPORT_MBTI = "Export ranking personality type results to a CSV file"
55
  NOTI_CALCULATE = ["You can calculate Big Five personality traits scores", "Вы можете рассчитать показатели Большой пятерки персональных качеств личности человека"]
56
+ SWITCHEHG_MODES_ONLINE = ["Webcam", "Веб камера"]
57
+ SWITCHEHG_MODES_OFFLINE = ["Video Files", "Видеофайлы"]
58
 
59
  [Labels]
60
  APP_LABEL = ["⭐ App", "⭐ Приложение"]
61
  ABOUT_APP_LABEL = ["💡 About the App", "💡 О приложении"]
62
  ABOUT_AUTHORS_LABEL = ["🎭 About the Authors", "🎭 Об авторах"]
63
  REQUIREMENTS_LABEL = ["📋 Requirements", "📋 Зависимости"]
64
+ PRACTICAL_TASKS_LABEL = ["Practical tasks", "Практические задачи"]
65
+ PRACTICAL_SUBTASKS_LABEL = ["Practical subtasks", "Практические подзадачи"]
66
  THRESHOLD_MBTI_LABEL = "Polarity traits threshold"
67
  THRESHOLD_PROFESSIONAL_SKILLS_LABEL = "Polarity traits threshold"
68
  TARGET_SCORE_OPE_LABEL = "Openness target score"
 
150
  DROPDOWN_MBTI_DEL_COLS = ["EI", "SN", "TF", "JP", "Match"]
151
  SHOW_VIDEO_METADATA = true
152
  SUPPORTED_VIDEO_EXT = ["mp4", "mov", "avi", "flv"]
153
+ TYPE_MODES = ["Files", "Web"]
154
 
155
  [Values]
156
  TARGET_SCORES = [0.527886, 0.522337, 0.458468, 0.51761, 0.444649]
images/videos.ico ADDED
images/webcam.ico ADDED
practical_tasks.yaml → practical_tasks_en.yaml RENAMED
File without changes
practical_tasks_ru.yaml ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ - task: "Ранжирование потенциальных кандидатов по профессиональным обязанностям"
2
+ subtasks:
3
+ - "16 персональных типов личности MBTI"
4
+ - "Профессиональные группы"
5
+ - "Профессиональные навыки"
6
+ - task: "Формирование эффективных рабочих коллективов"
7
+ subtasks:
8
+ - "Поиск подходящего младшего коллеги"
9
+ - "Поиск подходящего старшего коллеги"
10
+ - task: "Прогнозирование потребительских предпочтений в отношении промышленных товаров"
11
+ subtasks:
12
+ - "Характеристики автомобиля"
13
+ - "Категории приложений для мобильных устройств"
14
+ - "Стиль одежды"
requirements.txt CHANGED
@@ -1,5 +1,6 @@
1
- gradio==5.5.0
2
- PyYAML==6.0.1
3
  toml==0.10.2
4
- oceanai==1.0.0a43
5
- tf-keras
 
 
1
+ gradio==5.6.0
2
+ PyYAML==6.0.2
3
  toml==0.10.2
4
+ oceanai==1.0.0a46
5
+ torch==2.2.2
6
+ psutil==6.1.0