Spaces:
Running
Running
DmitryRyumin
commited on
Commit
β’
1717e06
1
Parent(s):
fffa006
Summary
Browse files
app/event_handlers/calculate_practical_tasks.py
CHANGED
@@ -6,9 +6,11 @@ License: MIT License
|
|
6 |
"""
|
7 |
|
8 |
from app.oceanai_init import b5
|
|
|
9 |
import re
|
10 |
import gradio as gr
|
11 |
from pathlib import Path
|
|
|
12 |
|
13 |
# Importing necessary components for the Gradio app
|
14 |
from app.config import config_data
|
@@ -204,44 +206,106 @@ def event_handler_calculate_practical_task_blocks(
|
|
204 |
|
205 |
preprocess_scores_df(pt_scores_copy, config_data.Dataframes_PT_SCORES[0][0])
|
206 |
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
|
|
214 |
|
215 |
-
|
216 |
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
|
231 |
-
|
|
|
|
|
|
|
|
|
232 |
|
233 |
-
|
234 |
|
235 |
-
|
|
|
|
|
236 |
|
237 |
-
|
238 |
-
|
239 |
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
|
244 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
245 |
|
246 |
existing_tuple = (
|
247 |
gr.Row(visible=True),
|
|
|
6 |
"""
|
7 |
|
8 |
from app.oceanai_init import b5
|
9 |
+
import pandas as pd
|
10 |
import re
|
11 |
import gradio as gr
|
12 |
from pathlib import Path
|
13 |
+
from bs4 import BeautifulSoup
|
14 |
|
15 |
# Importing necessary components for the Gradio app
|
16 |
from app.config import config_data
|
|
|
206 |
|
207 |
preprocess_scores_df(pt_scores_copy, config_data.Dataframes_PT_SCORES[0][0])
|
208 |
|
209 |
+
if type_modes == config_data.Settings_TYPE_MODES[0]:
|
210 |
+
b5._professional_match(
|
211 |
+
df_files=pt_scores_copy,
|
212 |
+
correlation_coefficients=df_correlation_coefficients,
|
213 |
+
personality_type=remove_parentheses(dropdown_mbti),
|
214 |
+
threshold=threshold_mbti,
|
215 |
+
out=False,
|
216 |
+
)
|
217 |
|
218 |
+
df = apply_rounding_and_rename_columns(b5.df_files_MBTI_job_match_)
|
219 |
|
220 |
+
df_hidden = df.drop(
|
221 |
+
columns=config_data.Settings_SHORT_PROFESSIONAL_SKILLS
|
222 |
+
+ config_data.Settings_DROPDOWN_MBTI_DEL_COLS
|
223 |
+
)
|
224 |
|
225 |
+
df_hidden.rename(
|
226 |
+
columns={
|
227 |
+
"Path": "Filename",
|
228 |
+
"MBTI": "Personality Type",
|
229 |
+
"MBTI_Score": "Personality Type Score",
|
230 |
+
},
|
231 |
+
inplace=True,
|
232 |
+
)
|
233 |
|
234 |
+
df_copy = df_hidden.copy()
|
235 |
+
df_copy["Personality Type"] = df_copy["Personality Type"].apply(
|
236 |
+
lambda x: "".join(BeautifulSoup(x, "html.parser").stripped_strings)
|
237 |
+
)
|
238 |
+
df_copy.to_csv(config_data.Filenames_MBTI_JOB, index=False)
|
239 |
|
240 |
+
df_hidden.reset_index(inplace=True)
|
241 |
|
242 |
+
person_id = (
|
243 |
+
int(df_hidden.iloc[0][config_data.Dataframes_PT_SCORES[0][0]]) - 1
|
244 |
+
)
|
245 |
|
246 |
+
short_mbti = extract_text_in_parentheses(dropdown_mbti)
|
247 |
+
mbti_values = df_hidden["Personality Type"].tolist()
|
248 |
|
249 |
+
df_hidden["Personality Type"] = [
|
250 |
+
compare_strings(short_mbti, mbti, False) for mbti in mbti_values
|
251 |
+
]
|
252 |
|
253 |
+
person_metadata = create_person_metadata(person_id, files, video_metadata)
|
254 |
+
elif type_modes == config_data.Settings_TYPE_MODES[1]:
|
255 |
+
all_hidden_dfs = []
|
256 |
+
|
257 |
+
for dropdown_mbti in config_data.Settings_DROPDOWN_MBTI:
|
258 |
+
b5._professional_match(
|
259 |
+
df_files=pt_scores_copy,
|
260 |
+
correlation_coefficients=df_correlation_coefficients,
|
261 |
+
personality_type=remove_parentheses(dropdown_mbti),
|
262 |
+
threshold=threshold_mbti,
|
263 |
+
out=False,
|
264 |
+
)
|
265 |
+
|
266 |
+
df = apply_rounding_and_rename_columns(b5.df_files_MBTI_job_match_)
|
267 |
+
|
268 |
+
df_hidden = df.drop(
|
269 |
+
columns=config_data.Settings_SHORT_PROFESSIONAL_SKILLS
|
270 |
+
+ config_data.Settings_DROPDOWN_MBTI_DEL_COLS_WEBCAM
|
271 |
+
)
|
272 |
+
|
273 |
+
df_hidden.insert(0, "Personality Type (Dropdown)", dropdown_mbti)
|
274 |
+
|
275 |
+
df_hidden.rename(
|
276 |
+
columns={
|
277 |
+
"MBTI": "Personality Type",
|
278 |
+
"MBTI_Score": "Personality Type Score",
|
279 |
+
},
|
280 |
+
inplace=True,
|
281 |
+
)
|
282 |
+
|
283 |
+
short_mbti = extract_text_in_parentheses(dropdown_mbti)
|
284 |
+
mbti_values = df_hidden["Personality Type"].tolist()
|
285 |
+
|
286 |
+
df_hidden["Personality Type"] = [
|
287 |
+
compare_strings(short_mbti, mbti, False) for mbti in mbti_values
|
288 |
+
]
|
289 |
+
|
290 |
+
all_hidden_dfs.append(df_hidden)
|
291 |
+
|
292 |
+
df_hidden = pd.concat(all_hidden_dfs, ignore_index=True)
|
293 |
+
|
294 |
+
df_hidden = df_hidden.sort_values(
|
295 |
+
by="Personality Type Score", ascending=False
|
296 |
+
)
|
297 |
+
|
298 |
+
df_hidden.reset_index(drop=True, inplace=True)
|
299 |
+
|
300 |
+
df_copy = df_hidden.copy()
|
301 |
+
df_copy["Personality Type"] = df_copy["Personality Type"].apply(
|
302 |
+
lambda x: "".join(BeautifulSoup(x, "html.parser").stripped_strings)
|
303 |
+
)
|
304 |
+
df_copy.to_csv(config_data.Filenames_MBTI_JOB, index=False)
|
305 |
+
|
306 |
+
person_id = 0
|
307 |
+
|
308 |
+
person_metadata = create_person_metadata(person_id, files, video_metadata)
|
309 |
|
310 |
existing_tuple = (
|
311 |
gr.Row(visible=True),
|
app/event_handlers/event_handlers.py
CHANGED
@@ -539,7 +539,7 @@ def setup_app_event_handlers(
|
|
539 |
)
|
540 |
practical_task_sorted.select(
|
541 |
event_handler_practical_task_sorted,
|
542 |
-
[files, practical_task_sorted],
|
543 |
[
|
544 |
video_sorted_column,
|
545 |
video_sorted,
|
|
|
539 |
)
|
540 |
practical_task_sorted.select(
|
541 |
event_handler_practical_task_sorted,
|
542 |
+
[type_modes, files, video, practical_task_sorted],
|
543 |
[
|
544 |
video_sorted_column,
|
545 |
video_sorted,
|
app/event_handlers/practical_task_sorted.py
CHANGED
@@ -15,16 +15,21 @@ from app.components import video_create_ui, textbox_create_ui
|
|
15 |
|
16 |
|
17 |
def event_handler_practical_task_sorted(
|
18 |
-
files, practical_task_sorted, evt_data: gr.SelectData
|
19 |
):
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
|
|
|
|
|
|
25 |
)
|
26 |
-
|
27 |
-
|
|
|
|
|
28 |
|
29 |
if evt_data.index[0] == 0:
|
30 |
label = "Best"
|
|
|
15 |
|
16 |
|
17 |
def event_handler_practical_task_sorted(
|
18 |
+
type_modes, files, video, practical_task_sorted, evt_data: gr.SelectData
|
19 |
):
|
20 |
+
if type_modes == config_data.Settings_TYPE_MODES[0]:
|
21 |
+
person_id = (
|
22 |
+
int(
|
23 |
+
practical_task_sorted.iloc[evt_data.index[0]][
|
24 |
+
config_data.Dataframes_PT_SCORES[0][0]
|
25 |
+
]
|
26 |
+
)
|
27 |
+
- 1
|
28 |
)
|
29 |
+
elif type_modes == config_data.Settings_TYPE_MODES[1]:
|
30 |
+
files = [video]
|
31 |
+
|
32 |
+
person_id = 0
|
33 |
|
34 |
if evt_data.index[0] == 0:
|
35 |
label = "Best"
|
config.toml
CHANGED
@@ -1,5 +1,5 @@
|
|
1 |
[AppSettings]
|
2 |
-
APP_VERSION = "0.10.
|
3 |
SERVER_NAME = "127.0.0.1"
|
4 |
PORT = 7860
|
5 |
CSS_PATH = "app.css"
|
@@ -148,6 +148,7 @@ DROPDOWN_MBTI = [
|
|
148 |
"The Commander (ENTJ): Construction Supervisor, Health Services Administrator, Financial Accountant, Auditor, Lawyer, School Principal, Chemical Engineer, Database Manager, etc.",
|
149 |
]
|
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"]
|
|
|
1 |
[AppSettings]
|
2 |
+
APP_VERSION = "0.10.2"
|
3 |
SERVER_NAME = "127.0.0.1"
|
4 |
PORT = 7860
|
5 |
CSS_PATH = "app.css"
|
|
|
148 |
"The Commander (ENTJ): Construction Supervisor, Health Services Administrator, Financial Accountant, Auditor, Lawyer, School Principal, Chemical Engineer, Database Manager, etc.",
|
149 |
]
|
150 |
DROPDOWN_MBTI_DEL_COLS = ["EI", "SN", "TF", "JP", "Match"]
|
151 |
+
DROPDOWN_MBTI_DEL_COLS_WEBCAM = ["EI", "SN", "TF", "JP", "Match", "Path"]
|
152 |
SHOW_VIDEO_METADATA = true
|
153 |
SUPPORTED_VIDEO_EXT = ["mp4", "mov", "avi", "flv"]
|
154 |
TYPE_MODES = ["Files", "Web"]
|
requirements.txt
CHANGED
@@ -4,3 +4,4 @@ toml==0.10.2
|
|
4 |
oceanai==1.0.0a46
|
5 |
torch==2.2.2
|
6 |
psutil==6.1.0
|
|
|
|
4 |
oceanai==1.0.0a46
|
5 |
torch==2.2.2
|
6 |
psutil==6.1.0
|
7 |
+
beautifulsoup4==4.12.3
|