Skip to content

Commit

Permalink
Summary
Browse files Browse the repository at this point in the history
  • Loading branch information
DmitryRyumin committed Apr 15, 2024
1 parent 8f227bb commit 3d8b729
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 33 deletions.
2 changes: 1 addition & 1 deletion oceanai/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
__uri__ = "https://github.com/DmitryRyumin/oceanai"

__version__ = "1.0"
__release__ = __version__ + ".0a28"
__release__ = __version__ + ".0a29"

__author__ru__ = "Рюмина Елена, Рюмин Дмитрий, Карпов Алексей"
__author__en__ = "Elena Ryumina, Dmitry Ryumin, Alexey Karpov"
Expand Down
39 changes: 8 additions & 31 deletions oceanai/modules/lab/prediction.py
Original file line number Diff line number Diff line change
Expand Up @@ -2260,7 +2260,6 @@ def get_avt_predictions(
if runtime:
self._r_end(out=out)


def get_avt_predictions_gradio(
self,
paths: list[str] = [],
Expand Down Expand Up @@ -2409,14 +2408,11 @@ def get_avt_predictions_gradio(

last = False # Замена последнего сообщения

# print(paths)

paths = [i for i in paths if i.endswith(('.mp4', '.avi'))]
paths = [i for i in paths if i.endswith((".mp4", ".avi", "mov", "flv"))]
self.__len_paths = len(paths)

# Проход по всем искомым файлов
for i, curr_path in enumerate(paths):
# print(curr_path)
if i != 0:
last = True

Expand All @@ -2432,8 +2428,6 @@ def get_avt_predictions_gradio(
run=run,
)

# print(hc_audio_features, melspectrogram_audio_features)

# Извлечение признаков из визуального сигнала
hc_video_features, nn_video_features = self._get_visual_features(
path=curr_path,
Expand Down Expand Up @@ -2485,9 +2479,7 @@ def get_avt_predictions_gradio(

try:
# Оправка экспертных признаков в нейросетевую модель
_, features_hc_audio = self.audio_model_hc_(
np.array(hc_audio_features, dtype=np.float16)
)
_, features_hc_audio = self.audio_model_hc_(np.array(hc_audio_features, dtype=np.float16))
except TypeError:
code_error_pred_hc_audio = 1
except Exception:
Expand Down Expand Up @@ -2524,19 +2516,15 @@ def get_avt_predictions_gradio(

try:
# Оправка экспертных признаков в нейросетевую модель
_, features_hc_video = self.video_model_hc_(
np.array(hc_video_features, dtype=np.float16)
)
_, features_hc_video = self.video_model_hc_(np.array(hc_video_features, dtype=np.float16))
except TypeError:
code_error_pred_hc_video = 1
except Exception:
code_error_pred_hc_video = 2

try:
# Отправка нейросетевых признаков в нейросетевую модель
_, features_nn_video = self.video_model_nn_(
np.array(nn_video_features, dtype=np.float16)
)
_, features_nn_video = self.video_model_nn_(np.array(nn_video_features, dtype=np.float16))
except TypeError:
code_error_pred_nn_video = 1
except Exception:
Expand Down Expand Up @@ -2631,12 +2619,7 @@ def get_avt_predictions_gradio(
true_traits.append(true_trait)
else:
# Добавление данных в словарь для DataFrame
if (
self._append_to_list_of_files(
curr_path, [None] * len(self._b5["en"]), out
)
is False
):
if self._append_to_list_of_files(curr_path, [None] * len(self._b5["en"]), out) is False:
return False

self._del_last_el_notebook_history_output()
Expand All @@ -2660,9 +2643,7 @@ def get_avt_predictions_gradio(
for cnt, name_b5 in enumerate(self._df_files.keys().tolist()[1:]):
try:
mae_curr.append(
mean_absolute_error(
np.asarray(true_traits)[:, cnt], self._df_files[name_b5].to_list()
)
mean_absolute_error(np.asarray(true_traits)[:, cnt], self._df_files[name_b5].to_list())
)
except IndexError:
continue
Expand All @@ -2681,9 +2662,7 @@ def get_avt_predictions_gradio(

self._dict_of_accuracy.update({self.__df_accuracy_mean: [mae_mean, accuracy_mean]})
# Отображение в DataFrame с данными
self._df_accuracy = pd.DataFrame.from_dict(
data=self._dict_of_accuracy, orient="index"
).transpose()
self._df_accuracy = pd.DataFrame.from_dict(data=self._dict_of_accuracy, orient="index").transpose()
self._df_accuracy.index = self.__df_accuracy_index
self._df_accuracy.index.name = self.__df_accuracy_index_name

Expand Down Expand Up @@ -2714,9 +2693,7 @@ def get_avt_predictions_gradio(
name_logs_file = self.get_avt_predictions.__name__

# Сохранение LOG
res_save_logs_df_files = self._save_logs(
self._df_files, name_logs_file + "_df_files_" + curr_ts
)
res_save_logs_df_files = self._save_logs(self._df_files, name_logs_file + "_df_files_" + curr_ts)

# Подсчет точности
if accuracy is True:
Expand Down
2 changes: 1 addition & 1 deletion oceanai/modules/lab/video.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ def __post_init__(self):
# ----------------------- Только для внутреннего использования внутри класса

# Поддерживаемые видео форматы
self.__supported_video_formats: List[str] = ["mp4", "mov", "avi"]
self.__supported_video_formats: List[str] = ["mp4", "mov", "avi", "flv"]

self.__mp_face_mesh: ModuleType = mp.solutions.face_mesh # 468 3D-ориентиров лица
self.__mp_drawing: ModuleType = mp.solutions.drawing_utils # Утилиты MediaPipe
Expand Down

0 comments on commit 3d8b729

Please sign in to comment.