From 3d8b7298f8399367548f7b5135e37e4c57b94163 Mon Sep 17 00:00:00 2001 From: Dmitry Ryumin Date: Mon, 15 Apr 2024 22:28:16 +0300 Subject: [PATCH] Summary --- oceanai/__init__.py | 2 +- oceanai/modules/lab/prediction.py | 39 +++++++------------------------ oceanai/modules/lab/video.py | 2 +- 3 files changed, 10 insertions(+), 33 deletions(-) diff --git a/oceanai/__init__.py b/oceanai/__init__.py index 382f0c2..017ffda 100644 --- a/oceanai/__init__.py +++ b/oceanai/__init__.py @@ -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" diff --git a/oceanai/modules/lab/prediction.py b/oceanai/modules/lab/prediction.py index f0360e6..8a76fe1 100644 --- a/oceanai/modules/lab/prediction.py +++ b/oceanai/modules/lab/prediction.py @@ -2260,7 +2260,6 @@ def get_avt_predictions( if runtime: self._r_end(out=out) - def get_avt_predictions_gradio( self, paths: list[str] = [], @@ -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 @@ -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, @@ -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: @@ -2524,9 +2516,7 @@ 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: @@ -2534,9 +2524,7 @@ def get_avt_predictions_gradio( 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: @@ -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() @@ -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 @@ -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 @@ -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: diff --git a/oceanai/modules/lab/video.py b/oceanai/modules/lab/video.py index 40d842a..b9a0948 100644 --- a/oceanai/modules/lab/video.py +++ b/oceanai/modules/lab/video.py @@ -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