From efe92a08aba8594984743fae35dd6f38996e7b54 Mon Sep 17 00:00:00 2001 From: sronilsson Date: Sat, 19 Oct 2024 16:23:07 +0000 Subject: [PATCH] cleaned --- .../yolo/geometries_to_annotations.py | 7 ++++-- .../boolean_conditional_calculator.py | 9 ++++--- simba/mixins/train_model_mixin.py | 13 ++++++---- .../third_party_label_appenders/converters.py | 24 ++++++++++++------- 4 files changed, 35 insertions(+), 18 deletions(-) diff --git a/simba/bounding_box_tools/yolo/geometries_to_annotations.py b/simba/bounding_box_tools/yolo/geometries_to_annotations.py index 9d8a792f4..1134d867f 100644 --- a/simba/bounding_box_tools/yolo/geometries_to_annotations.py +++ b/simba/bounding_box_tools/yolo/geometries_to_annotations.py @@ -10,9 +10,12 @@ from skimage.draw import polygon from simba.mixins.geometry_mixin import GeometryMixin -from simba.utils.checks import check_instance, check_int, check_valid_array, check_if_dir_exists +from simba.utils.checks import (check_if_dir_exists, check_instance, check_int, + check_valid_array) from simba.utils.enums import Formats -from simba.utils.read_write import (get_video_meta_data, read_df, read_frm_of_video, find_files_of_filetypes_in_directory) +from simba.utils.read_write import (find_files_of_filetypes_in_directory, + get_video_meta_data, read_df, + read_frm_of_video) def geometry_to_rle(geometry: Union[np.ndarray, Polygon], img_size: Tuple[int, int]): diff --git a/simba/data_processors/boolean_conditional_calculator.py b/simba/data_processors/boolean_conditional_calculator.py index 01c8b52b1..45962f5aa 100644 --- a/simba/data_processors/boolean_conditional_calculator.py +++ b/simba/data_processors/boolean_conditional_calculator.py @@ -6,11 +6,14 @@ import pandas as pd from simba.mixins.config_reader import ConfigReader -from simba.utils.checks import (check_all_file_names_are_represented_in_video_log, check_if_df_field_is_boolean, check_instance) +from simba.utils.checks import ( + check_all_file_names_are_represented_in_video_log, + check_if_df_field_is_boolean, check_instance) +from simba.utils.data import detect_bouts from simba.utils.errors import MissingColumnsError from simba.utils.printing import stdout_success -from simba.utils.read_write import (get_fn_ext, read_data_paths, read_df, read_video_info, str_2_bool) -from simba.utils.data import detect_bouts +from simba.utils.read_write import (get_fn_ext, read_data_paths, read_df, + read_video_info, str_2_bool) class BooleanConditionalCalculator(ConfigReader): diff --git a/simba/mixins/train_model_mixin.py b/simba/mixins/train_model_mixin.py index 60ae511c9..56b1c9e54 100644 --- a/simba/mixins/train_model_mixin.py +++ b/simba/mixins/train_model_mixin.py @@ -32,7 +32,8 @@ from sklearn.inspection import partial_dependence, permutation_importance from sklearn.metrics import classification_report, precision_recall_curve from sklearn.model_selection import ShuffleSplit, learning_curve -from sklearn.preprocessing import (MinMaxScaler, QuantileTransformer, StandardScaler) +from sklearn.preprocessing import (MinMaxScaler, QuantileTransformer, + StandardScaler) from sklearn.tree import export_graphviz from sklearn.utils import parallel_backend from tabulate import tabulate @@ -57,11 +58,15 @@ from simba.plotting.shap_agg_stats_visualizer import \ ShapAggregateStatisticsVisualizer from simba.ui.tkinter_functions import TwoOptionQuestionPopUp -from simba.utils.checks import (check_file_exist_and_readable, check_float, check_if_dir_exists, check_if_valid_input, check_instance, check_int, check_str, check_that_column_exist, check_valid_dataframe, check_valid_lst) +from simba.utils.checks import (check_file_exist_and_readable, check_float, + check_if_dir_exists, check_if_valid_input, + check_instance, check_int, check_str, + check_that_column_exist, check_valid_dataframe, + check_valid_lst) from simba.utils.data import (detect_bouts, detect_bouts_multiclass, get_library_version) -from simba.utils.enums import (OS, ConfigKey, Defaults, Dtypes, Methods, - MLParamKeys, Options, Formats) +from simba.utils.enums import (OS, ConfigKey, Defaults, Dtypes, Formats, + Methods, MLParamKeys, Options) from simba.utils.errors import (ClassifierInferenceError, ColumnNotFoundError, CorruptedFileError, DataHeaderError, FaultyTrainingSetError, diff --git a/simba/third_party_label_appenders/converters.py b/simba/third_party_label_appenders/converters.py index 88c4039d9..d9bcb8d43 100644 --- a/simba/third_party_label_appenders/converters.py +++ b/simba/third_party_label_appenders/converters.py @@ -1,26 +1,32 @@ +import base64 +import io +import itertools import json import os -import itertools -import pandas as pd -import io -from PIL import Image -import base64 from datetime import datetime -from typing import Dict, Optional, Tuple, Union, Any +from typing import Any, Dict, Optional, Tuple, Union import cv2 import numpy as np +import pandas as pd +from PIL import Image from pycocotools import mask from shapely.geometry import Polygon from skimage.draw import polygon from simba.mixins.geometry_mixin import GeometryMixin from simba.mixins.image_mixin import ImageMixin -from simba.utils.checks import check_instance, check_int, check_valid_array, check_if_dir_exists, check_if_keys_exist_in_dict, check_file_exist_and_readable, check_if_valid_img +from simba.utils.checks import (check_file_exist_and_readable, + check_if_dir_exists, + check_if_keys_exist_in_dict, + check_if_valid_img, check_instance, check_int, + check_valid_array) from simba.utils.enums import Formats -from simba.utils.read_write import get_video_meta_data, read_df, read_frm_of_video, find_files_of_filetypes_in_directory, get_fn_ext -from simba.utils.errors import NoFilesFoundError, InvalidInputError +from simba.utils.errors import InvalidInputError, NoFilesFoundError from simba.utils.printing import SimbaTimer, stdout_success +from simba.utils.read_write import (find_files_of_filetypes_in_directory, + get_fn_ext, get_video_meta_data, read_df, + read_frm_of_video) def geometry_to_rle(geometry: Union[np.ndarray, Polygon], img_size: Tuple[int, int]):