simba-uw-tf-dev 4.6.1__py3-none-any.whl → 4.6.3__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- simba/SimBA.py +2 -2
- simba/assets/icons/frames_2.png +0 -0
- simba/data_processors/agg_clf_counter_mp.py +52 -53
- simba/data_processors/cuda/image.py +3 -1
- simba/data_processors/cue_light_analyzer.py +5 -9
- simba/mixins/geometry_mixin.py +14 -28
- simba/mixins/image_mixin.py +10 -14
- simba/mixins/train_model_mixin.py +2 -2
- simba/plotting/ROI_feature_visualizer_mp.py +3 -5
- simba/plotting/clf_validator_mp.py +4 -5
- simba/plotting/cue_light_visualizer.py +6 -7
- simba/plotting/directing_animals_visualizer_mp.py +2 -3
- simba/plotting/distance_plotter_mp.py +378 -378
- simba/plotting/frame_mergerer_ffmpeg.py +137 -137
- simba/plotting/gantt_creator_mp.py +59 -31
- simba/plotting/geometry_plotter.py +270 -272
- simba/plotting/heat_mapper_clf_mp.py +2 -4
- simba/plotting/heat_mapper_location_mp.py +2 -2
- simba/plotting/light_dark_box_plotter.py +2 -2
- simba/plotting/path_plotter_mp.py +26 -29
- simba/plotting/plot_clf_results_mp.py +455 -454
- simba/plotting/pose_plotter_mp.py +27 -32
- simba/plotting/probability_plot_creator_mp.py +288 -288
- simba/plotting/roi_plotter_mp.py +29 -30
- simba/plotting/single_run_model_validation_video_mp.py +427 -427
- simba/plotting/spontaneous_alternation_plotter.py +2 -3
- simba/plotting/yolo_pose_track_visualizer.py +31 -27
- simba/plotting/yolo_pose_visualizer.py +32 -34
- simba/plotting/yolo_seg_visualizer.py +2 -3
- simba/roi_tools/roi_aggregate_stats_mp.py +4 -3
- simba/roi_tools/roi_clf_calculator_mp.py +3 -3
- simba/sandbox/cuda/egocentric_rotator.py +374 -0
- simba/sandbox/get_cpu_pool.py +5 -0
- simba/ui/pop_ups/clf_add_remove_print_pop_up.py +3 -1
- simba/ui/pop_ups/egocentric_alignment_pop_up.py +6 -3
- simba/ui/pop_ups/multiple_videos_to_frames_popup.py +10 -11
- simba/ui/pop_ups/single_video_to_frames_popup.py +10 -10
- simba/ui/pop_ups/video_processing_pop_up.py +63 -63
- simba/ui/tkinter_functions.py +7 -1
- simba/utils/data.py +89 -12
- simba/utils/enums.py +1 -0
- simba/utils/printing.py +9 -8
- simba/utils/read_write.py +3726 -3721
- simba/video_processors/clahe_ui.py +65 -22
- simba/video_processors/egocentric_video_rotator.py +6 -9
- simba/video_processors/video_processing.py +21 -10
- simba/video_processors/videos_to_frames.py +3 -2
- {simba_uw_tf_dev-4.6.1.dist-info → simba_uw_tf_dev-4.6.3.dist-info}/METADATA +1 -1
- {simba_uw_tf_dev-4.6.1.dist-info → simba_uw_tf_dev-4.6.3.dist-info}/RECORD +53 -50
- {simba_uw_tf_dev-4.6.1.dist-info → simba_uw_tf_dev-4.6.3.dist-info}/LICENSE +0 -0
- {simba_uw_tf_dev-4.6.1.dist-info → simba_uw_tf_dev-4.6.3.dist-info}/WHEEL +0 -0
- {simba_uw_tf_dev-4.6.1.dist-info → simba_uw_tf_dev-4.6.3.dist-info}/entry_points.txt +0 -0
- {simba_uw_tf_dev-4.6.1.dist-info → simba_uw_tf_dev-4.6.3.dist-info}/top_level.txt +0 -0
|
@@ -12,17 +12,15 @@ import pandas as pd
|
|
|
12
12
|
from simba.mixins.config_reader import ConfigReader
|
|
13
13
|
from simba.mixins.geometry_mixin import GeometryMixin
|
|
14
14
|
from simba.mixins.plotting_mixin import PlottingMixin
|
|
15
|
-
from simba.utils.checks import (check_instance, check_int,
|
|
16
|
-
|
|
17
|
-
check_that_column_exist, check_valid_boolean)
|
|
18
|
-
from simba.utils.data import create_color_palette
|
|
15
|
+
from simba.utils.checks import (check_instance, check_int, check_nvidea_gpu_available, check_str, check_that_column_exist, check_valid_boolean)
|
|
16
|
+
from simba.utils.data import create_color_palette, terminate_cpu_pool, get_cpu_pool
|
|
19
17
|
from simba.utils.enums import OS, Formats, Options
|
|
20
18
|
from simba.utils.errors import CountError, InvalidFilepathError
|
|
21
19
|
from simba.utils.printing import SimbaTimer, stdout_success
|
|
22
20
|
from simba.utils.read_write import (concatenate_videos_in_folder,
|
|
23
21
|
find_core_cnt,
|
|
24
22
|
find_files_of_filetypes_in_directory,
|
|
25
|
-
get_fn_ext, get_video_meta_data, read_df)
|
|
23
|
+
get_fn_ext, get_video_meta_data, read_df, get_current_time)
|
|
26
24
|
from simba.utils.warnings import FrameRangeWarning
|
|
27
25
|
|
|
28
26
|
|
|
@@ -59,7 +57,7 @@ def pose_plotter_mp(data: pd.DataFrame,
|
|
|
59
57
|
img = cv2.polylines(img, [animal_bbox], True, colors_dict[animal_cnt][0], thickness=max(1, int(circle_size/1.5)), lineType=-1)
|
|
60
58
|
writer.write(img)
|
|
61
59
|
current_frm += 1
|
|
62
|
-
print(f"Multi-processing video frame {current_frm} on core {group_cnt}...")
|
|
60
|
+
print(f"[{get_current_time()}] Multi-processing video frame {current_frm} on core {group_cnt}...")
|
|
63
61
|
else:
|
|
64
62
|
print(f'Frame {current_frm} not found in video {video_path}, terminating video creation...')
|
|
65
63
|
break
|
|
@@ -109,9 +107,8 @@ class PosePlotterMultiProcess():
|
|
|
109
107
|
else:
|
|
110
108
|
files_found = [data_path]
|
|
111
109
|
self.animal_bp_dict = self.config.body_parts_lst
|
|
112
|
-
if circle_size is not None:
|
|
113
|
-
|
|
114
|
-
check_int(name='core_cnt', value=core_cnt, min_value=-1)
|
|
110
|
+
if circle_size is not None: check_int(name='circle_size', value=circle_size, min_value=1)
|
|
111
|
+
check_int(name='core_cnt', value=core_cnt, min_value=-1, unaccepted_vals=[0])
|
|
115
112
|
if core_cnt == -1: core_cnt = find_core_cnt()[0]
|
|
116
113
|
self.color_dict = {}
|
|
117
114
|
if palettes is not None:
|
|
@@ -145,12 +142,12 @@ class PosePlotterMultiProcess():
|
|
|
145
142
|
multiprocessing.set_start_method("spawn", force=True)
|
|
146
143
|
|
|
147
144
|
def run(self):
|
|
145
|
+
self.pool = get_cpu_pool(core_cnt=self.core_cnt, source=self.__class__.__name__)
|
|
148
146
|
for file_cnt, (pose_path, video_path) in enumerate(self.data.items()):
|
|
149
147
|
video_timer = SimbaTimer(start=True)
|
|
150
148
|
video_name = get_fn_ext(pose_path)[1]
|
|
151
149
|
self.temp_folder = os.path.join(self.out_dir, video_name, "temp")
|
|
152
|
-
if os.path.exists(self.temp_folder):
|
|
153
|
-
self.config.remove_a_folder(self.temp_folder)
|
|
150
|
+
if os.path.exists(self.temp_folder): self.config.remove_a_folder(self.temp_folder)
|
|
154
151
|
os.makedirs(self.temp_folder, exist_ok=True)
|
|
155
152
|
save_video_path = os.path.join(self.out_dir, f"{video_name}.mp4")
|
|
156
153
|
pose_df = read_df(file_path=pose_path, file_type=self.config.file_type, check_multiindex=True)
|
|
@@ -170,35 +167,33 @@ class PosePlotterMultiProcess():
|
|
|
170
167
|
pose_df = (pose_df.apply(pd.to_numeric, errors="coerce").fillna(0).reset_index(drop=True))
|
|
171
168
|
pose_lst, obs_per_split = PlottingMixin().split_and_group_df(df=pose_df, splits=self.core_cnt)
|
|
172
169
|
print(f"Creating pose videos, multiprocessing (chunksize: {self.config.multiprocess_chunksize}, cores: {self.core_cnt})...")
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
print(f"Image {min(len(pose_df), obs_per_split*(cnt+1))}/{len(pose_df)}, Video {file_cnt+1}/{len(list(self.data.keys()))}...")
|
|
184
|
-
pool.terminate()
|
|
185
|
-
pool.join()
|
|
170
|
+
constants = functools.partial(pose_plotter_mp,
|
|
171
|
+
video_meta_data=video_meta_data,
|
|
172
|
+
video_path=video_path,
|
|
173
|
+
bp_dict=self.config.animal_bp_dict,
|
|
174
|
+
colors_dict=self.color_dict,
|
|
175
|
+
circle_size=video_circle_size,
|
|
176
|
+
bbox=self.bbox,
|
|
177
|
+
video_save_dir=self.temp_folder)
|
|
178
|
+
for cnt, result in enumerate(self.pool.imap(constants, pose_lst, chunksize=self.config.multiprocess_chunksize)):
|
|
179
|
+
print(f"[{get_current_time()}] Image {min(len(pose_df), obs_per_split*(cnt+1))}/{len(pose_df)}, Video {file_cnt+1}/{len(list(self.data.keys()))}...")
|
|
186
180
|
print(f"Joining {video_name} multi-processed video...")
|
|
187
181
|
concatenate_videos_in_folder(in_folder=self.temp_folder, save_path=save_video_path, remove_splits=True, gpu=self.gpu)
|
|
188
182
|
video_timer.stop_timer()
|
|
189
183
|
stdout_success(msg=f"Pose video {video_name} complete and saved at {save_video_path}", elapsed_time=video_timer.elapsed_time_str, source=self.__class__.__name__)
|
|
184
|
+
terminate_cpu_pool(pool=self.pool, force=False, source=self.__class__.__name__)
|
|
190
185
|
self.config.timer.stop_timer()
|
|
191
186
|
stdout_success(f"Pose visualizations for {len(list(self.data.keys()))} video(s) created in {self.out_dir} directory", elapsed_time=self.config.timer.elapsed_time_str, source=self.__class__.__name__)
|
|
192
187
|
|
|
193
188
|
|
|
194
|
-
if __name__ == "__main__":
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
189
|
+
# if __name__ == "__main__":
|
|
190
|
+
# test = PosePlotterMultiProcess(data_path=r"C:\troubleshooting\mitra\project_folder\csv\input_csv",
|
|
191
|
+
# out_dir=None,
|
|
192
|
+
# circle_size=8,
|
|
193
|
+
# core_cnt=18,
|
|
194
|
+
# palettes=None,
|
|
195
|
+
# bbox=True,)
|
|
196
|
+
# test.run()
|
|
202
197
|
|
|
203
198
|
|
|
204
199
|
|