ElenaRyumina DmitryRyumin commited on
Commit
42c4f80
β€’
1 Parent(s): d25e239

- Summary (69f6759227a857c3a1ddc012f3f7b896fb7d7ad3)


Co-authored-by: Dmitry Ryumin <[email protected]>

.gitignore CHANGED
@@ -169,4 +169,5 @@ dmypy.json
169
 
170
  # Custom
171
  logs/
172
- models/
 
 
169
 
170
  # Custom
171
  logs/
172
+ models/
173
+ *.csv
README.md CHANGED
@@ -1,6 +1,6 @@
1
  ---
2
  title: OCEANAI
3
- emoji: πŸ€©πŸ”πŸ”₯
4
  colorFrom: gray
5
  colorTo: red
6
  sdk: gradio
 
1
  ---
2
  title: OCEANAI
3
+ emoji: πŸ˜€πŸ€“πŸ˜ŽπŸ˜‰πŸ˜€
4
  colorFrom: gray
5
  colorTo: red
6
  sdk: gradio
app.css CHANGED
@@ -15,13 +15,15 @@ div.files-container {
15
  max-height: 350px;
16
  }
17
 
 
 
18
  div.files-container div.file-preview-holder {
19
  overflow-y: scroll;
20
  height: 100%;
21
  }
22
 
23
  div.files-container label[data-testid="block-label"] {
24
- position: absolute;
25
  }
26
 
27
  .calculate_oceanai {
@@ -39,7 +41,7 @@ div.files-container label[data-testid="block-label"] {
39
  transition: all 0.3s ease;
40
  }
41
 
42
- .clear_oceanai {
43
  display: inline-block;
44
  padding: 10px 20px;
45
  font-size: 16px;
@@ -51,7 +53,9 @@ div.files-container label[data-testid="block-label"] {
51
  transition: all 0.3s ease;
52
  }
53
 
54
- .calculate_oceanai[disabled], .clear_oceanai[disabled] {
 
 
55
  cursor: not-allowed;
56
  opacity: 0.6;
57
  }
@@ -62,6 +66,8 @@ div.files-container label[data-testid="block-label"] {
62
  color: var(--button-primary-text-color-hover);
63
  }
64
 
65
- .calculate_oceanai:active:not([disabled]), .clear_oceanai:active:not([disabled]) {
 
 
66
  transform: scale(0.98);
67
  }
 
15
  max-height: 350px;
16
  }
17
 
18
+ div.csv-container {}
19
+
20
  div.files-container div.file-preview-holder {
21
  overflow-y: scroll;
22
  height: 100%;
23
  }
24
 
25
  div.files-container label[data-testid="block-label"] {
26
+ position: absolute;
27
  }
28
 
29
  .calculate_oceanai {
 
41
  transition: all 0.3s ease;
42
  }
43
 
44
+ .examples_oceanai, .clear_oceanai {
45
  display: inline-block;
46
  padding: 10px 20px;
47
  font-size: 16px;
 
53
  transition: all 0.3s ease;
54
  }
55
 
56
+ .calculate_oceanai[disabled],
57
+ .examples_oceanai[disabled],
58
+ .clear_oceanai[disabled] {
59
  cursor: not-allowed;
60
  opacity: 0.6;
61
  }
 
66
  color: var(--button-primary-text-color-hover);
67
  }
68
 
69
+ .calculate_oceanai:active:not([disabled]),
70
+ .examples_oceanai:active:not([disabled]),
71
+ .clear_oceanai:active:not([disabled]) {
72
  transform: scale(0.98);
73
  }
app/components.py CHANGED
@@ -87,8 +87,13 @@ def button(
87
  value: str = "",
88
  interactive: bool = True,
89
  scale: int = 3,
 
90
  elem_classes: Optional[str] = None,
91
  ) -> gr.Button:
92
  return gr.Button(
93
- value=value, interactive=interactive, scale=scale, elem_classes=elem_classes
 
 
 
 
94
  )
 
87
  value: str = "",
88
  interactive: bool = True,
89
  scale: int = 3,
90
+ visible: bool = True,
91
  elem_classes: Optional[str] = None,
92
  ) -> gr.Button:
93
  return gr.Button(
94
+ value=value,
95
+ interactive=interactive,
96
+ scale=scale,
97
+ visible=visible,
98
+ elem_classes=elem_classes,
99
  )
app/description.py CHANGED
@@ -9,7 +9,7 @@ License: MIT License
9
  from app.config import config_data
10
 
11
  DESCRIPTION = f"""\
12
- # OCEANAI
13
 
14
  <div class="app-flex-container">
15
  <img src="https://img.shields.io/badge/version-v{config_data.AppSettings_APP_VERSION}-rc0" alt="Version">
 
9
  from app.config import config_data
10
 
11
  DESCRIPTION = f"""\
12
+ <h1><a href="https://github.com/aimclub/OCEANAI" target="_blank">OCEAN-AI</a> is an open-source library to Big Five personality traits assessment and automate HR-processes.</h1>
13
 
14
  <div class="app-flex-container">
15
  <img src="https://img.shields.io/badge/version-v{config_data.AppSettings_APP_VERSION}-rc0" alt="Version">
app/event_handlers/calculate_pt_scores_blocks.py CHANGED
@@ -10,7 +10,7 @@ import gradio as gr
10
  # Importing necessary components for the Gradio app
11
  from app.oceanai_init import b5
12
  from app.config import config_data
13
- from app.components import html_message, dataframe
14
 
15
 
16
  def event_handler_calculate_pt_scores_blocks(files, evt_data: gr.EventData):
@@ -21,6 +21,8 @@ def event_handler_calculate_pt_scores_blocks(files, evt_data: gr.EventData):
21
  paths=files, url_accuracy="", accuracy=False, lang="en", out=out
22
  )
23
 
 
 
24
  return (
25
  html_message(config_data.InformationMessages_NOTI_VIDEOS, False, False),
26
  dataframe(
@@ -28,4 +30,14 @@ def event_handler_calculate_pt_scores_blocks(files, evt_data: gr.EventData):
28
  values=b5.df_files_.values.tolist(),
29
  visible=True,
30
  ),
 
 
 
 
 
 
 
 
 
 
31
  )
 
10
  # Importing necessary components for the Gradio app
11
  from app.oceanai_init import b5
12
  from app.config import config_data
13
+ from app.components import html_message, dataframe, files_create_ui
14
 
15
 
16
  def event_handler_calculate_pt_scores_blocks(files, evt_data: gr.EventData):
 
21
  paths=files, url_accuracy="", accuracy=False, lang="en", out=out
22
  )
23
 
24
+ b5.df_files_.to_csv(config_data.Filenames_PT_SCORES)
25
+
26
  return (
27
  html_message(config_data.InformationMessages_NOTI_VIDEOS, False, False),
28
  dataframe(
 
30
  values=b5.df_files_.values.tolist(),
31
  visible=True,
32
  ),
33
+ files_create_ui(
34
+ config_data.Filenames_PT_SCORES,
35
+ "single",
36
+ [".csv"],
37
+ config_data.OtherMessages_EXPORT_PT_SCORES,
38
+ True,
39
+ False,
40
+ True,
41
+ "csv-container",
42
+ ),
43
  )
app/event_handlers/clear_blocks.py CHANGED
@@ -25,8 +25,19 @@ def event_handler_clear_blocks():
25
  config_data.OtherMessages_CALCULATE_PT_SCORES,
26
  False,
27
  3,
 
28
  "calculate_oceanai",
29
  ),
30
- button(config_data.OtherMessages_CLEAR_APP, False, 1, "clear_oceanai"),
31
  dataframe(visible=False),
 
 
 
 
 
 
 
 
 
 
32
  )
 
25
  config_data.OtherMessages_CALCULATE_PT_SCORES,
26
  False,
27
  3,
28
+ True,
29
  "calculate_oceanai",
30
  ),
31
+ button(config_data.OtherMessages_CLEAR_APP, False, 1, True, "clear_oceanai"),
32
  dataframe(visible=False),
33
+ files_create_ui(
34
+ None,
35
+ "single",
36
+ [".csv"],
37
+ config_data.OtherMessages_EXPORT_PT_SCORES,
38
+ True,
39
+ False,
40
+ False,
41
+ "csv-container",
42
+ ),
43
  )
app/event_handlers/event_handlers.py CHANGED
@@ -12,6 +12,7 @@ from app.event_handlers.files import (
12
  event_handler_files,
13
  event_handler_files_select,
14
  )
 
15
  from app.event_handlers.clear_blocks import event_handler_clear_blocks
16
  from app.event_handlers.calculate_pt_scores_blocks import (
17
  event_handler_calculate_pt_scores_blocks,
@@ -19,7 +20,14 @@ from app.event_handlers.calculate_pt_scores_blocks import (
19
 
20
 
21
  def setup_app_event_handlers(
22
- notifications, files, video, calculate_pt_scores, clear_app, pt_scores
 
 
 
 
 
 
 
23
  ):
24
  # Events
25
  files.change(
@@ -38,7 +46,15 @@ def setup_app_event_handlers(
38
  triggers=[calculate_pt_scores.click],
39
  fn=event_handler_calculate_pt_scores_blocks,
40
  inputs=[files],
41
- outputs=[notifications, pt_scores],
 
 
 
 
 
 
 
 
42
  queue=True,
43
  )
44
  clear_app.click(
@@ -51,6 +67,7 @@ def setup_app_event_handlers(
51
  calculate_pt_scores,
52
  clear_app,
53
  pt_scores,
 
54
  ],
55
  queue=True,
56
  )
 
12
  event_handler_files,
13
  event_handler_files_select,
14
  )
15
+ from app.event_handlers.examples_blocks import event_handler_examples_blocks
16
  from app.event_handlers.clear_blocks import event_handler_clear_blocks
17
  from app.event_handlers.calculate_pt_scores_blocks import (
18
  event_handler_calculate_pt_scores_blocks,
 
20
 
21
 
22
  def setup_app_event_handlers(
23
+ notifications,
24
+ files,
25
+ video,
26
+ examples,
27
+ calculate_pt_scores,
28
+ clear_app,
29
+ pt_scores,
30
+ csv_pt_scores,
31
  ):
32
  # Events
33
  files.change(
 
46
  triggers=[calculate_pt_scores.click],
47
  fn=event_handler_calculate_pt_scores_blocks,
48
  inputs=[files],
49
+ outputs=[notifications, pt_scores, csv_pt_scores],
50
+ queue=True,
51
+ )
52
+ examples.click(
53
+ fn=event_handler_examples_blocks,
54
+ inputs=[],
55
+ outputs=[
56
+ files,
57
+ ],
58
  queue=True,
59
  )
60
  clear_app.click(
 
67
  calculate_pt_scores,
68
  clear_app,
69
  pt_scores,
70
+ csv_pt_scores,
71
  ],
72
  queue=True,
73
  )
app/event_handlers/examples_blocks.py ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ File: examples_blocks.py
3
+ Author: Elena Ryumina and Dmitry Ryumin
4
+ Description: Event handler for the addition of examples to the Gradio app.
5
+ License: MIT License
6
+ """
7
+
8
+ # Importing necessary components for the Gradio app
9
+
10
+
11
+ def event_handler_examples_blocks():
12
+ return [
13
+ "videos/video1.mp4",
14
+ "videos/video2.mp4",
15
+ "videos/video3.mp4",
16
+ ]
app/event_handlers/files.py CHANGED
@@ -22,9 +22,12 @@ def event_handler_files(files):
22
  config_data.OtherMessages_CALCULATE_PT_SCORES,
23
  False,
24
  3,
 
25
  "calculate_oceanai",
26
  ),
27
- button(config_data.OtherMessages_CLEAR_APP, False, 1, "clear_oceanai"),
 
 
28
  )
29
 
30
  return (
@@ -34,9 +37,10 @@ def event_handler_files(files):
34
  config_data.OtherMessages_CALCULATE_PT_SCORES,
35
  True,
36
  3,
 
37
  "calculate_oceanai",
38
  ),
39
- button(config_data.OtherMessages_CLEAR_APP, True, 1, "clear_oceanai"),
40
  )
41
 
42
 
 
22
  config_data.OtherMessages_CALCULATE_PT_SCORES,
23
  False,
24
  3,
25
+ True,
26
  "calculate_oceanai",
27
  ),
28
+ button(
29
+ config_data.OtherMessages_CLEAR_APP, False, 1, True, "clear_oceanai"
30
+ ),
31
  )
32
 
33
  return (
 
37
  config_data.OtherMessages_CALCULATE_PT_SCORES,
38
  True,
39
  3,
40
+ True,
41
  "calculate_oceanai",
42
  ),
43
+ button(config_data.OtherMessages_CLEAR_APP, True, 1, True, "clear_oceanai"),
44
  )
45
 
46
 
app/tabs.py CHANGED
@@ -29,21 +29,45 @@ def app_tab():
29
  video = video_create_ui()
30
 
31
  with gr.Row():
 
 
 
32
  calculate_pt_scores = button(
33
  config_data.OtherMessages_CALCULATE_PT_SCORES,
34
  False,
35
  3,
 
36
  "calculate_oceanai",
37
  )
38
  clear_app = button(
39
- config_data.OtherMessages_CLEAR_APP, False, 1, "clear_oceanai"
40
  )
41
 
42
  notifications = html_message(config_data.InformationMessages_NOTI_VIDEOS, False)
43
 
44
  pt_scores = dataframe(visible=False)
45
 
46
- return (notifications, files, video, calculate_pt_scores, clear_app, pt_scores)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
47
 
48
 
49
  def about_authors_tab():
 
29
  video = video_create_ui()
30
 
31
  with gr.Row():
32
+ examples = button(
33
+ config_data.OtherMessages_EXAMPLES_APP, True, 1, True, "examples_oceanai"
34
+ )
35
  calculate_pt_scores = button(
36
  config_data.OtherMessages_CALCULATE_PT_SCORES,
37
  False,
38
  3,
39
+ True,
40
  "calculate_oceanai",
41
  )
42
  clear_app = button(
43
+ config_data.OtherMessages_CLEAR_APP, False, 1, True, "clear_oceanai"
44
  )
45
 
46
  notifications = html_message(config_data.InformationMessages_NOTI_VIDEOS, False)
47
 
48
  pt_scores = dataframe(visible=False)
49
 
50
+ csv_pt_scores = files_create_ui(
51
+ None,
52
+ "single",
53
+ [".csv"],
54
+ config_data.OtherMessages_EXPORT_PT_SCORES,
55
+ True,
56
+ False,
57
+ False,
58
+ "csv-container",
59
+ )
60
+
61
+ return (
62
+ notifications,
63
+ files,
64
+ video,
65
+ examples,
66
+ calculate_pt_scores,
67
+ clear_app,
68
+ pt_scores,
69
+ csv_pt_scores,
70
+ )
71
 
72
 
73
  def about_authors_tab():
config.toml CHANGED
@@ -1,5 +1,5 @@
1
  [AppSettings]
2
- APP_VERSION = "0.1.0"
3
  CSS_PATH = "app.css"
4
 
5
  [InformationMessages]
@@ -8,9 +8,13 @@ NOTI_VIDEOS = "Select the video(s)"
8
  [OtherMessages]
9
  CALCULATE_PT_SCORES = "Calculation of Big Five personality traits scores"
10
  CLEAR_APP = "Clear"
 
 
11
  NOTI_CALCULATE = "You can calculate Big Five personality traits scores"
12
 
13
  [TabCreators]
14
  "App" = "app_tab"
15
  "About the Authors" = "about_authors_tab"
16
 
 
 
 
1
  [AppSettings]
2
+ APP_VERSION = "0.2.0"
3
  CSS_PATH = "app.css"
4
 
5
  [InformationMessages]
 
8
  [OtherMessages]
9
  CALCULATE_PT_SCORES = "Calculation of Big Five personality traits scores"
10
  CLEAR_APP = "Clear"
11
+ EXAMPLES_APP = "Examples"
12
+ EXPORT_PT_SCORES = "Export Big Five personality traits to a CSV file"
13
  NOTI_CALCULATE = "You can calculate Big Five personality traits scores"
14
 
15
  [TabCreators]
16
  "App" = "app_tab"
17
  "About the Authors" = "about_authors_tab"
18
 
19
+ [Filenames]
20
+ PT_SCORES = "personality_traits_scores.csv"