simba-uw-tf-dev 4.7.6__py3-none-any.whl → 4.7.8__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.
Files changed (27) hide show
  1. simba/assets/.recent_projects.txt +1 -0
  2. simba/assets/icons/folder_2.png +0 -0
  3. simba/assets/icons/folder_video.png +0 -0
  4. simba/assets/lookups/tooptips.json +35 -2
  5. simba/model/yolo_fit.py +42 -9
  6. simba/sandbox/clean_sleap.py +4 -0
  7. simba/third_party_label_appenders/transform/coco_keypoints_to_yolo.py +1 -2
  8. simba/third_party_label_appenders/transform/sleap_csv_to_yolo.py +21 -13
  9. simba/ui/create_project_ui.py +1 -1
  10. simba/ui/pop_ups/batch_preprocess_pop_up.py +2 -2
  11. simba/ui/pop_ups/simba_to_yolo_keypoints_popup.py +96 -96
  12. simba/ui/pop_ups/sleap_annotations_to_yolo_popup.py +32 -18
  13. simba/ui/pop_ups/sleap_csv_predictions_to_yolo_popup.py +15 -14
  14. simba/ui/pop_ups/video_processing_pop_up.py +8 -7
  15. simba/ui/pop_ups/yolo_plot_results.py +146 -153
  16. simba/ui/pop_ups/yolo_pose_train_popup.py +69 -23
  17. simba/ui/tkinter_functions.py +53 -6
  18. simba/utils/checks.py +2414 -2401
  19. simba/utils/read_write.py +22 -20
  20. simba/video_processors/batch_process_menus.py +22 -22
  21. simba/video_processors/video_processing.py +3 -2
  22. {simba_uw_tf_dev-4.7.6.dist-info → simba_uw_tf_dev-4.7.8.dist-info}/METADATA +1 -1
  23. {simba_uw_tf_dev-4.7.6.dist-info → simba_uw_tf_dev-4.7.8.dist-info}/RECORD +27 -24
  24. {simba_uw_tf_dev-4.7.6.dist-info → simba_uw_tf_dev-4.7.8.dist-info}/LICENSE +0 -0
  25. {simba_uw_tf_dev-4.7.6.dist-info → simba_uw_tf_dev-4.7.8.dist-info}/WHEEL +0 -0
  26. {simba_uw_tf_dev-4.7.6.dist-info → simba_uw_tf_dev-4.7.8.dist-info}/entry_points.txt +0 -0
  27. {simba_uw_tf_dev-4.7.6.dist-info → simba_uw_tf_dev-4.7.8.dist-info}/top_level.txt +0 -0
@@ -1,3 +1,4 @@
1
+ E:/troubleshooting/mitra_pbn/mitra_pbn/project_folder/project_config.ini
1
2
  C:/troubleshooting/sleap_two_animals/project_folder/project_config.ini
2
3
  E:/troubleshooting/mitra_emergence/project_folder/project_config.ini
3
4
  C:/troubleshooting/meberled/project_folder/project_config.ini
Binary file
Binary file
@@ -5,7 +5,7 @@
5
5
  "batch_dropdown": "Number of frames processed at once. Larger batches speed up inference but require more GPU RAM.",
6
6
  "verbose_dropdown": "Toggle console printouts for progress and timings. Keep TRUE while tuning, FALSE for quiet runs.",
7
7
  "workers_dropdown": "How many CPU worker threads to use for pre/post-processing. Set <= available cores.",
8
- "format_dropdown": "Model serialization format (None = auto-detect from file extension). Match the format used when exporting the weights.",
8
+ "format_dropdown": "Export/serialization format. Training: export the trained model to this format after training (None = PyTorch .pt only). Inference: match the format of your weights file, or None to auto-detect from file extension. Options: onnx, engine, torchscript, onnxsimplify, coreml, openvino, pb, tf, tflite, torch.",
9
9
  "img_size_dropdown": "Resize shorter image side to this many pixels before inference. Larger sizes improve accuracy but slow down processing.",
10
10
  "devices_dropdown": "Compute device to run on. Select CUDA device ID for GPU or CPU.",
11
11
  "interpolate_dropdown": "Fill missing detections by interpolating coordinates over time. Recommended for cleaner trajectories.",
@@ -43,5 +43,38 @@
43
43
  "KLEINBERG_GAMMA": "Higher values (e.g., 0.5-1.0) reduce total burst count by making downward transitions costly; lower values (e.g., 0.1-0.3) allow more flexible state changes",
44
44
  "KLEINBERG_HIERARCHY": "Hierarchy level to extract bursts from (0=lowest, higher=more selective).\n Level 0 captures all bursts; level 1-2 typically filters noise; level 3+ selects only the most prominent, sustained bursts.\nHigher levels yield fewer but more confident detections",
45
45
  "KLEINBERG_HIERARCHY_SEARCH": "If True, searches for target hierarchy level within detected burst periods,\n falling back to lower levels if target not found. If False, extracts only bursts at the exact specified hierarchy level.\n Recommended when target hierarchy may be sparse.",
46
- "KLEINBERG_SAVE_ORIGINALS": "If True, saves the original data in a new sub-directory of \nthe project_folder/csv/machine_results directory"
46
+ "KLEINBERG_SAVE_ORIGINALS": "If True, saves the original data in a new sub-directory of \nthe project_folder/csv/machine_results directory",
47
+ "yolo_map_path": "Path to the YOLO dataset YAML file. Defines class names, paths to train/val images and labels, and number of keypoints.",
48
+ "yolo_initial_weights_path": "Optional path to pretrained weights (.pt) to start training from (e.g. yolo11n-pose.pt). Leave blank to train from scratch.",
49
+ "epochs_dropdown": "Number of training epochs. More epochs can improve accuracy but increase overfitting risk and training time.",
50
+ "plots_dropdown": "If TRUE, generate and save training curves (loss, mAP, etc.) in the save directory.",
51
+ "patience_dropdown": "Early-stopping patience: training stops if validation metric does not improve for this many epochs.",
52
+ "simba2yolo_config": "Path to the SimBA project configuration file (.ini). Defines project paths, body-parts, and animals.",
53
+ "simba2yolo_train_size": "Percentage of sampled frames to use for the YOLO training set. The remainder is used for validation. E.g. 70 means 70% train, 30% val.",
54
+ "simba2yolo_padding": "Extra margin (as a fraction of image size) added around the keypoint bounding box. Use a small value (e.g. 0.05–0.2) if the tight box cuts off body parts or you want more context in each crop; None or 0 = no padding.",
55
+ "simba2yolo_sample_size": "Maximum number of frames to sample per video for creating YOLO images and labels. Higher values give more data but increase processing time.",
56
+ "simba2yolo_grey": "If TRUE, extracted video frames are saved in greyscale. If FALSE, frames are saved in color.",
57
+ "simba2yolo_clahe": "If TRUE, apply CLAHE (Contrast Limited Adaptive Histogram Equalization) to frames before saving. Can improve keypoint visibility in low-contrast videos.",
58
+ "yolo_plot_line_thickness": "Thickness of the lines drawn between keypoints (skeleton). AUTO lets the plotter choose based on video size; or set 1–20 pixels.",
59
+ "yolo_plot_circle_size": "Radius of the circles drawn at each keypoint. AUTO lets the plotter choose based on video size; or set 1–20 pixels.",
60
+ "yolo_plot_tracks": "If TRUE, draw trajectory paths (tracks) for each detected instance over time. If FALSE, draw only keypoints and skeleton per frame.",
61
+ "yolo_plot_data_path": "Path to a single YOLO pose result CSV (output from YOLO pose inference). Must match the video you select.",
62
+ "yolo_plot_video_path": "Path to the video file to overlay pose results onto. Filename should match the data CSV (without extension).",
63
+ "yolo_plot_data_dir": "Directory containing YOLO pose result CSV files. Used for batch plotting; each CSV is matched to a video of the same name in the video directory.",
64
+ "SLEAP_DATA_DIR": "Directory containing SLEAP CSV prediction files. Each CSV should match a video filename (without extension).",
65
+ "ANIMAL_COUNT": "Number of animals (tracks) in the videos. Used to name classes (e.g. animal_1, animal_2) in the YOLO dataset.",
66
+ "sleap_remove_animal_ids": "If TRUE, merge all tracks into a single identity (animal_1). Use when animal IDs are not meaningful or for single-animal data.",
67
+ "sleap_threshold": "Minimum SLEAP instance confidence (the instance.score column in the CSV). Only pose predictions with score ≥ this value are used when building the YOLO dataset. E.g. 90 means keep instances where instance.score ≥ 0.9; lower values include more frames but may add noisy predictions.",
68
+ "SLEAP_SLP_DATA_DIR": "Directory containing SLEAP .SLP project/annotation files. Each .SLP file is converted to YOLO pose format.",
69
+ "BATCH_CLIP_START_TIME": "Start time for clipping all videos. Use HH:MM:SS (e.g. 00:00:10). Click APPLY to copy this value to every video row.",
70
+ "BATCH_CLIP_END_TIME": "End time for clipping all videos. Use HH:MM:SS (e.g. 00:01:30). Must be after start time. Click APPLY to copy this value to every video row.",
71
+ "BATCH_DOWNSAMPLE_WIDTH": "Output width in pixels when downsampling all videos. Must be even. Click APPLY to copy to every video row.",
72
+ "BATCH_DOWNSAMPLE_HEIGHT": "Output height in pixels when downsampling all videos. Must be even. Click APPLY to copy to every video row.",
73
+ "BATCH_FPS": "Target frames per second for all videos. Click APPLY to copy this value to every video row.",
74
+ "BATCH_APPLY_DOWNSAMPLE": "Tick to check the downsample box for all videos (all will be downsampled on execute). Untick to uncheck all. Set width and height in the DOWNSAMPLE VIDEOS panel, then click APPLY there to copy those values to every row.",
75
+ "BATCH_APPLY_FPS": "Tick to enable FPS change for all videos.\nUntick to disable for all.\nSet FPS in CHANGE FPS panel, then APPLY there.",
76
+ "BATCH_APPLY_GREYSCALE": "Tick to enable greyscale for all videos.\nUntick to disable for all.",
77
+ "BATCH_APPLY_FRAME_COUNT": "Tick to superimpose frame numbers on all videos.\nUntick to disable for all.",
78
+ "BATCH_APPLY_CLAHE": "Tick to apply CLAHE (contrast) to all videos.\nUntick to disable for all.",
79
+ "BATCH_APPLY_CLIP": "Tick to enable clipping for all videos.\nUntick to disable for all.\nSet start/end in CLIP VIDEOS SETTING, then APPLY there."
47
80
  }
simba/model/yolo_fit.py CHANGED
@@ -1,5 +1,6 @@
1
1
  import os
2
2
  import sys
3
+ import urllib.request
3
4
  from contextlib import redirect_stderr, redirect_stdout
4
5
 
5
6
  os.environ["KMP_DUPLICATE_LIB_OK"]="TRUE"
@@ -19,13 +20,19 @@ except ModuleNotFoundError:
19
20
  from simba.data_processors.cuda.utils import _is_cuda_available
20
21
  from simba.utils.checks import (check_file_exist_and_readable,
21
22
  check_if_dir_exists, check_int, check_str,
22
- check_valid_boolean, check_valid_device)
23
+ check_valid_boolean, check_valid_device,
24
+ check_valid_url)
23
25
  from simba.utils.enums import Options
24
26
  from simba.utils.errors import SimBAGPUError, SimBAPAckageVersionError
25
27
  from simba.utils.printing import stdout_information
26
28
  from simba.utils.read_write import find_core_cnt, get_current_time
27
29
  from simba.utils.yolo import load_yolo_model
28
30
 
31
+ #YOLO_X_PATH = "https://huggingface.co/Ultralytics/YOLO11/resolve/main/yolo11x-pose.pt"
32
+
33
+ YOLO_M_PATH = "https://huggingface.co/Ultralytics/YOLO11/resolve/main/yolo11m-pose.pt"
34
+
35
+
29
36
 
30
37
  class FitYolo():
31
38
 
@@ -74,9 +81,9 @@ class FitYolo():
74
81
  """
75
82
 
76
83
  def __init__(self,
77
- weights_path: Union[str, os.PathLike],
78
84
  model_yaml: Union[str, os.PathLike],
79
85
  save_path: Union[str, os.PathLike],
86
+ weights_path: Optional[Union[str, os.PathLike]] = None,
80
87
  epochs: int = 200,
81
88
  batch: Union[int, float] = 16,
82
89
  plots: bool = True,
@@ -92,7 +99,11 @@ class FitYolo():
92
99
  raise SimBAGPUError(msg='No GPU detected.', source=self.__class__.__name__)
93
100
  if YOLO is None:
94
101
  raise SimBAPAckageVersionError(msg='Ultralytics package not detected.', source=self.__class__.__name__)
95
- check_file_exist_and_readable(file_path=weights_path)
102
+ if weights_path is not None:
103
+ check_file_exist_and_readable(file_path=weights_path)
104
+ self.weights_path = weights_path
105
+ else:
106
+ self._download_start_weights()
96
107
  check_file_exist_and_readable(file_path=model_yaml)
97
108
  check_valid_boolean(value=verbose, source=f'{__class__.__name__} verbose', raise_error=True)
98
109
  check_valid_boolean(value=plots, source=f'{__class__.__name__} plots', raise_error=True)
@@ -106,12 +117,19 @@ class FitYolo():
106
117
  check_valid_device(device=device)
107
118
  self.model_yaml, self.epochs, self.batch = model_yaml, epochs, batch
108
119
  self.imgsz, self.device, self.workers, self.format = imgsz, device, workers, format
109
- self.plots, self.save_path, self.verbose, self.weights_path, self.patience = plots, save_path, verbose, weights_path, patience
120
+ self.plots, self.save_path, self.verbose, self.patience = plots, save_path, verbose, patience
121
+
122
+ def _download_start_weights(self, url: str = YOLO_M_PATH, save_path: Union[str, os.PathLike] = "yolo11m-pose.pt"):
123
+ print(f'No start weights provided, downloading {save_path} from {url}...')
124
+ check_valid_url(url=url, raise_error=True, source=self.__class__.__name__)
125
+ if not os.path.isfile(save_path):
126
+ urllib.request.urlretrieve(url, save_path)
127
+ stdout_information(msg=f'Downloaded initial weights from {url}', source=self.__class__.__name__)
128
+ self.weights_path = save_path
129
+ print(self.weights_path)
110
130
 
111
131
 
112
132
  def run(self):
113
- # Temporarily redirect stdout/stderr to terminal to ensure ultralytics output goes to terminal
114
- # sys.__stdout__ and sys.__stderr__ are the original terminal streams
115
133
  stdout_information(msg=f'[{get_current_time()}] Please follow the YOLO pose model training in the terminal from where SimBA was launched ...', source=self.__class__.__name__)
116
134
  stdout_information(msg=f'[{get_current_time()}] Results will be stored in the {self.save_path} directory ..', source=self.__class__.__name__)
117
135
  with redirect_stdout(sys.__stdout__), redirect_stderr(sys.__stderr__):
@@ -133,7 +151,7 @@ class FitYolo():
133
151
 
134
152
  if __name__ == "__main__" and not hasattr(sys, 'ps1'):
135
153
  parser = argparse.ArgumentParser(description="Fit YOLO model using ultralytics package.")
136
- parser.add_argument('--weights_path', type=str, required=True, help='Path to the trained YOLO model weights (e.g., yolo11n-pose.pt)')
154
+ parser.add_argument('--weights_path', type=str, default=None, help='Path to the trained YOLO model weights (e.g., yolo11n-pose.pt). Omit to download default starter weights.')
137
155
  parser.add_argument('--model_yaml', type=str, required=True, help='Path to map.yaml (model structure and label definitions)')
138
156
  parser.add_argument('--save_path', type=str, required=True, help='Directory where trained model and logs will be saved')
139
157
  parser.add_argument('--epochs', type=int, default=25, help='Number of epochs to train the model. Default is 25')
@@ -146,7 +164,6 @@ if __name__ == "__main__" and not hasattr(sys, 'ps1'):
146
164
  parser.add_argument('--workers', type=int, default=8, help='Number of data loader workers. Default is 8. Use -1 for max cores')
147
165
  parser.add_argument('--patience', type=int, default=100, help='Number of epochs to wait without improvement in validation metrics before early stopping the training. Default is 100')
148
166
 
149
-
150
167
  args = parser.parse_args()
151
168
 
152
169
  yolo_fitter = FitYolo(weights_path=args.weights_path,
@@ -159,11 +176,27 @@ if __name__ == "__main__" and not hasattr(sys, 'ps1'):
159
176
  format=args.format,
160
177
  device=int(args.device) if args.device != 'cpu' else 'cpu',
161
178
  verbose=args.verbose,
162
- workers=args.workers)
179
+ workers=args.workers,
180
+ patience=args.patience)
163
181
  yolo_fitter.run()
164
182
 
165
183
 
166
184
 
185
+
186
+
187
+ # fitter = FitYolo(weights_path=r"D:\maplight_tg2576_yolo\yolo_mdl\original_weight_oct\best.pt",
188
+ # model_yaml=r"D:\maplight_tg2576_yolo\yolo_mdl\map.yaml",
189
+ # save_path=r"D:\maplight_tg2576_yolo\yolo_mdl\mdl",
190
+ # epochs=1500,
191
+ # batch=22,
192
+ # format=None,
193
+ # device=0,
194
+ # imgsz=640)
195
+ # fitter.run()
196
+
197
+
198
+
199
+
167
200
  # fitter = FitYolo(weights_path=r"E:\yolo_resident_intruder\mdl\train3\weights\best.pt",
168
201
  # model_yaml=r"E:\maplight_videos\yolo_mdl\map.yaml",
169
202
  # save_path=r"E:\maplight_videos\yolo_mdl\mdl",
@@ -0,0 +1,4 @@
1
+ from simba.utils.read_write import clean_sleap_file_name
2
+
3
+
4
+ clean_sleap_file_name(filename=f'2026-01-09 11-53-23 box1_1143_0_Gq_5cno.predictions.000_2026-01-09 11-53-23 box1_1143_0_Gq_5cno.analysis.csv')
@@ -75,7 +75,7 @@ class COCOKeypoints2Yolo:
75
75
  img_dir: Union[str, os.PathLike],
76
76
  save_dir: Union[str, os.PathLike],
77
77
  train_size: float = 0.7,
78
- flip_idx: Tuple[int, ...] = (0, 2, 1, 3, 5, 4, 6, 7, 8),
78
+ flip_idx: Tuple[int, ...] = (0, 2, 1, 5, 4, 3, 6),
79
79
  verbose: bool = True,
80
80
  greyscale: bool = False,
81
81
  clahe: bool = False,
@@ -175,7 +175,6 @@ class COCOKeypoints2Yolo:
175
175
  missing = [x for x in list(range(shapes[0])) if x not in self.flip_idx]
176
176
  if len(missing) > 0:
177
177
  raise InvalidInputError(msg=f'keypoints contains index values not in flip_idx ({missing}).', source=self.__class__.__name__)
178
-
179
178
  create_yolo_keypoint_yaml(path=self.save_dir, train_path=self.train_img_dir, val_path=self.val_img_dir, names=self.map_dict, save_path=self.map_path, kpt_shape=(int(shapes[0]), 3), flip_idx=self.flip_idx)
180
179
  timer.stop_timer()
181
180
  if self.verbose: stdout_success(msg=f'COCO keypoints to YOLO conversion complete. Data saved in directory {self.save_dir}.', elapsed_time=timer.elapsed_time_str)
@@ -19,10 +19,12 @@ from simba.utils.checks import (check_float, check_if_dir_exists, check_int,
19
19
  check_valid_dataframe, check_valid_tuple)
20
20
  from simba.utils.enums import Options
21
21
  from simba.utils.errors import NoFilesFoundError
22
- from simba.utils.printing import SimbaTimer, stdout_success
23
- from simba.utils.read_write import (create_directory,
22
+ from simba.utils.printing import SimbaTimer, stdout_information, stdout_success
23
+ from simba.utils.read_write import (clean_sleap_filenames_in_directory,
24
+ copy_files_to_directory, create_directory,
24
25
  find_files_of_filetypes_in_directory,
25
- get_video_meta_data, read_frm_of_video)
26
+ get_video_meta_data, read_frm_of_video,
27
+ remove_a_folder)
26
28
  from simba.utils.yolo import keypoint_array_to_yolo_annotation_str
27
29
 
28
30
 
@@ -70,11 +72,16 @@ class Sleap2Yolo:
70
72
  padding: float = 0.00,
71
73
  single_id: Optional[str] = None):
72
74
 
75
+ check_if_dir_exists(in_dir=save_dir)
73
76
  self.data_paths = find_files_of_filetypes_in_directory(directory=data_dir, extensions=['.csv'], as_dict=True, raise_error=True)
77
+ self.data_temp_dir = os.path.join(data_dir, '.temp')
78
+ create_directory(paths=self.data_temp_dir, overwrite=True, verbose=True)
79
+ copy_files_to_directory(file_paths=list(self.data_paths.values()), dir=self.data_temp_dir, verbose=False, integer_save_names=False)
80
+ clean_sleap_filenames_in_directory(dir=self.data_temp_dir, verbose=True)
81
+ self.data_paths = find_files_of_filetypes_in_directory(directory=self.data_temp_dir, extensions=['.csv'], as_dict=True, raise_error=True)
74
82
  self.video_paths = find_files_of_filetypes_in_directory(directory=video_dir, extensions=Options.ALL_VIDEO_FORMAT_OPTIONS.value, as_dict=True, raise_error=True)
75
83
  missing_video_paths = [x for x in self.video_paths.keys() if x not in self.data_paths.keys()]
76
84
  missing_data_paths = [x for x in self.data_paths.keys() if x not in self.video_paths.keys()]
77
- check_if_dir_exists(in_dir=save_dir)
78
85
  self.img_dir, self.lbl_dir = os.path.join(save_dir, 'images'), os.path.join(save_dir, 'labels')
79
86
  self.img_train_dir, self.img_val_dir = os.path.join(save_dir, 'images', 'train'), os.path.join(save_dir, 'images', 'val')
80
87
  self.lbl_train_dir, self.lb_val_dir = os.path.join(save_dir, 'labels', 'train'), os.path.join(save_dir, 'labels', 'val')
@@ -92,15 +99,15 @@ class Sleap2Yolo:
92
99
  if frms_cnt is not None:
93
100
  check_int(name=f'{self.__class__.__name__} frms_cnt', value=frms_cnt, min_value=1, raise_error=True)
94
101
  if len(missing_video_paths) > 0:
95
- raise NoFilesFoundError(msg=f'Video(s) {missing_video_paths} could not be found in {video_dir} directory', source=self.__class__.__name__)
102
+ remove_a_folder(folder_dir=self.data_temp_dir, ignore_errors=True)
103
+ raise NoFilesFoundError(msg=f'{len(missing_video_paths)} video(s) {missing_video_paths} (of {len(self.data_paths.keys())} expected) could not be found in {video_dir} directory', source=self.__class__.__name__)
96
104
  if len(missing_data_paths) > 0:
97
- raise NoFilesFoundError(msg=f'CSV data for {missing_data_paths} could not be found in {data_dir} directory', source=self.__class__.__name__)
105
+ remove_a_folder(folder_dir=self.data_temp_dir, ignore_errors=True)
106
+ raise NoFilesFoundError(msg=f'{len(missing_data_paths)} CSV data for {missing_data_paths} (of {len(self.video_paths.keys())} could not be found in {data_dir} directory', source=self.__class__.__name__)
98
107
  self.verbose, self.instance_threshold, self.frms_cnt = verbose, instance_threshold, frms_cnt
99
108
  self.names, self.greyscale, self.train_size, self.clahe = names, greyscale, train_size, clahe
100
109
  self.padding, self.flip_idx, self.save_dir, self.single_id = padding, flip_idx, save_dir, single_id
101
110
 
102
-
103
-
104
111
  def run(self):
105
112
  dfs, timer, bp_cols = [], SimbaTimer(start=True), []
106
113
  for file_cnt, (file_name, file_path) in enumerate(self.data_paths.items()):
@@ -115,6 +122,7 @@ class Sleap2Yolo:
115
122
  dfs.append(df)
116
123
 
117
124
  dfs = pd.concat(dfs, axis=0)
125
+ dfs['track'] = dfs['track'].fillna(-1)
118
126
  unique_tracks_lk = {v: k for k, v in enumerate(dfs['track'].unique())}
119
127
  if self.names is not None:
120
128
  check_valid_tuple(x=self.names, source=f'{self.__class__.__name__} names', valid_dtypes=(str,), accepted_lengths=(len(list(unique_tracks_lk.keys())),))
@@ -125,14 +133,13 @@ class Sleap2Yolo:
125
133
  train_idx = random.sample(list(dfs['id'].unique()), int(len(dfs['frame_idx'].unique()) * self.train_size))
126
134
  if self.flip_idx is None:
127
135
  self.flip_idx = get_yolo_keypoint_flip_idx(x=list(dict.fromkeys([x[:-2] for x in bp_cols])))
128
-
129
136
  for frm_cnt, frm_id in enumerate(dfs['id'].unique()):
130
137
  frm_data = dfs[dfs['id'] == frm_id]
131
138
  video_path = list(frm_data['video'])[0]
132
139
  frm_idx = list(frm_data['frame_idx'])[0]
133
140
  video_meta = get_video_meta_data(video_path=video_path)
134
141
  if self.verbose:
135
- print(f'Processing frame: {frm_cnt + 1}/{len(list(dfs["id"].unique()))} ...')
142
+ stdout_information(msg=f'Processing frame: {frm_cnt + 1}/{len(list(dfs["id"].unique()))} ...', source=self.__class__.__name__)
136
143
  img = read_frm_of_video(video_path=video_path, frame_index=frm_idx, greyscale=self.greyscale, clahe=self.clahe)
137
144
  img_h, img_w = img.shape[0], img.shape[1]
138
145
  if list(frm_data['id'])[0] in train_idx:
@@ -155,12 +162,13 @@ class Sleap2Yolo:
155
162
 
156
163
  create_yolo_keypoint_yaml(path=self.save_dir, train_path=self.img_train_dir, val_path=self.img_val_dir, names=map_dict, save_path=self.map_path, kpt_shape=(len(self.flip_idx), 3), flip_idx=tuple(self.flip_idx))
157
164
  timer.stop_timer()
165
+ remove_a_folder(folder_dir=self.data_temp_dir, ignore_errors=True)
158
166
  stdout_success(msg=f'YOLO formated data saved in {self.save_dir} directory', source=self.__class__.__name__, elapsed_time=timer.elapsed_time_str)
159
167
 
160
168
 
161
- # DATA_DIR = r'D:\ares\data\ant\sleap_csv'
162
- # VIDEO_DIR = r'D:\ares\data\ant\sleap_video'
163
- # SAVE_DIR = r"D:\imgs\sleap_csv"
169
+ # DATA_DIR = r'E:\troubleshooting\mitra_pbn\raw_data\yolo\tracking'
170
+ # VIDEO_DIR = r'E:\troubleshooting\mitra_pbn\raw_data\yolo\videos'
171
+ # SAVE_DIR = r"E:\troubleshooting\mitra_pbn\raw_data\yolo\data"
164
172
  #
165
173
  # runner = Sleap2Yolo(data_dir=DATA_DIR, video_dir=VIDEO_DIR, frms_cnt=50, train_size=0.8, instance_threshold=0.9, save_dir=SAVE_DIR, single_id='ant')
166
174
  # runner.run()
@@ -66,7 +66,7 @@ class ProjectCreatorPopUp():
66
66
  self.settings_frm = CreateLabelFrameWithIcon(parent=self.create_project_tab, header="SETTINGS", icon_name=Keys.DOCUMENTATION.value, icon_link=Links.CREATE_PROJECT.value)
67
67
  self.general_settings_frm = CreateLabelFrameWithIcon(parent=self.settings_frm, header="GENERAL PROJECT SETTINGS", icon_name='settings', icon_link=Links.CREATE_PROJECT.value, padx=5, pady=5, relief='solid')
68
68
  self.project_dir_select = FolderSelect(self.general_settings_frm, "PROJECT DIRECTORY:", lblwidth=35, entry_width=35, font=Formats.FONT_REGULAR.value, lbl_icon='browse')
69
- self.project_name_eb = Entry_Box(self.general_settings_frm, "PROJECT NAME:", labelwidth=35, entry_box_width=35, img='id_card_2')
69
+ self.project_name_eb = Entry_Box(self.general_settings_frm, "PROJECT NAME:", labelwidth=35, entry_box_width=35, img='id_card_2', justify='center')
70
70
  self.file_type_dropdown = SimBADropDown(parent=self.general_settings_frm, dropdown_options=Options.WORKFLOW_FILE_TYPE_OPTIONS.value, label='WORKFLOW FILE TYPE:', label_width=35, dropdown_width=35, value=Options.WORKFLOW_FILE_TYPE_OPTIONS.value[0], img='file_type')
71
71
 
72
72
  self.ml_settings_frm = GetMLSettingsFrame(parent=self.create_project_tab, lbl_width=35, bx_width=22)
@@ -20,8 +20,8 @@ class BatchPreProcessPopUp(PopUpMixin):
20
20
  def __init__(self):
21
21
  PopUpMixin.__init__(self, title="BATCH PROCESS VIDEO", size=(600, 400), icon='stack')
22
22
  selections_frm = CreateLabelFrameWithIcon(parent=self.main_frm, header="SELECTIONS", icon_name=Keys.DOCUMENTATION.value, icon_link=Links.BATCH_PREPROCESS.value,)
23
- self.input_folder_select = FolderSelect(selections_frm, "INPUT VIDEO DIRECTORY:", title="Select Folder with Input Videos", lblwidth=30, lbl_icon='folder')
24
- self.output_folder_select = FolderSelect(selections_frm, "OUTPUT VIDEO DIRECTORY:", title="Select Folder for Output videos", lblwidth=30, lbl_icon='folder')
23
+ self.input_folder_select = FolderSelect(selections_frm, "INPUT VIDEO DIRECTORY:", title="Select Folder with Input Videos", lblwidth=30, lbl_icon='folder', tooltip_key='VIDEO_DIR')
24
+ self.output_folder_select = FolderSelect(selections_frm, "OUTPUT VIDEO DIRECTORY:", title="Select Folder for Output videos", lblwidth=30, lbl_icon='folder_2', tooltip_key='SAVE_DIR')
25
25
 
26
26
  confirm_btn = SimbaButton(parent=selections_frm, txt="CONFIRM", img='tick', txt_clr='blue', font=Formats.FONT_REGULAR.value, cmd=self.run)
27
27
  selections_frm.grid(row=0, column=0, sticky=NW)
@@ -1,96 +1,96 @@
1
- __author__ = "Simon Nilsson; sronilsson@gmail.com"
2
-
3
- from tkinter import *
4
-
5
- import numpy as np
6
-
7
- from simba.mixins.config_reader import ConfigReader
8
- from simba.mixins.pop_up_mixin import PopUpMixin
9
- from simba.third_party_label_appenders.transform.simba_to_yolo import \
10
- SimBA2Yolo
11
- from simba.third_party_label_appenders.transform.utils import (
12
- get_yolo_keypoint_bp_id_idx, get_yolo_keypoint_flip_idx)
13
- from simba.ui.tkinter_functions import (CreateLabelFrameWithIcon, FileSelect,
14
- FolderSelect, SimBADropDown)
15
- from simba.utils.read_write import str_2_bool
16
-
17
- TRAIN_SIZE_OPTIONS = np.arange(10, 110, 10)
18
- SAMPLE_SIZE_OPTIONS = list(np.arange(50, 650, 50))
19
-
20
- THRESHOLD_OPTIONS = list(np.arange(0.1, 1.1, 0.1))
21
-
22
- PADDING_OPTIONS = list(np.round(np.arange(0.01, 10.05, 0.05),2).astype(str))
23
- PADDING_OPTIONS = list(np.insert(PADDING_OPTIONS, 0, 'None'))
24
-
25
- class SimBA2YoloKeypointsPopUp(PopUpMixin):
26
-
27
- """
28
- :example:
29
- >>> SimBA2YoloKeypointsPopUp()
30
- """
31
- def __init__(self):
32
- PopUpMixin.__init__(self, title="SIMBA TO YOLO KEYPOINTS", icon='SimBA_logo_3_small')
33
- settings_frm = CreateLabelFrameWithIcon(parent=self.main_frm, header="SETTINGS", icon_name='settings')
34
- self.config_select = FileSelect(parent=settings_frm, fileDescription='SIMBA PROJECT CONFIG (.INI): ', lblwidth=35, file_types=[("INI FILE", (".ini", ".INI",))], entry_width=40, initialdir=r"C:\troubleshooting\mitra\project_folder", lbl_icon='ini')
35
- self.save_dir = FolderSelect(settings_frm, folderDescription="SAVE DIRECTORY:", lblwidth=35, entry_width=40, initialdir=r'C:\troubleshooting\mitra\yolo', lbl_icon='folder')
36
- self.train_size_dropdown = SimBADropDown(parent=settings_frm, dropdown_options=TRAIN_SIZE_OPTIONS, label="TRAIN SIZE (%): ", label_width=35, dropdown_width=40, value=70, img='pct_2')
37
- self.verbose_dropdown = SimBADropDown(parent=settings_frm, dropdown_options=['TRUE', 'FALSE'], label="VERBOSE: ", label_width=35, dropdown_width=40, value='TRUE', img='verbose')
38
- self.padding_dropdown = SimBADropDown(parent=settings_frm, dropdown_options=PADDING_OPTIONS, label="PADDING: ", label_width=35, dropdown_width=40, value='None', img='size_black')
39
- self.sample_size_dropdown = SimBADropDown(parent=settings_frm, dropdown_options=SAMPLE_SIZE_OPTIONS, label="FRAME SAMPLES PER VIDEO: ", label_width=35, dropdown_width=40, value=100, img='frames')
40
- self.threshold_dropdown = SimBADropDown(parent=settings_frm, dropdown_options=THRESHOLD_OPTIONS, label="CONFIDENCE THRESHOLD: ", label_width=35, dropdown_width=40, value='None', img='threshold')
41
- self.grey_dropdown = SimBADropDown(parent=settings_frm, dropdown_options=['TRUE', 'FALSE'], label="GREYSCALE: ", label_width=35, dropdown_width=40, value='FALSE', img='grey')
42
- self.clahe_dropdown = SimBADropDown(parent=settings_frm, dropdown_options=['TRUE', 'FALSE'], label="CLAHE: ", label_width=35, dropdown_width=40, value='FALSE', img='clahe')
43
-
44
- settings_frm.grid(row=0, column=0, sticky=NW)
45
- self.config_select.grid(row=0, column=0, sticky=NW)
46
- self.save_dir.grid(row=1, column=0, sticky=NW)
47
- self.train_size_dropdown.grid(row=2, column=0, sticky=NW)
48
-
49
- self.verbose_dropdown.grid(row=3, column=0, sticky=NW)
50
- self.padding_dropdown.grid(row=4, column=0, sticky=NW)
51
- self.sample_size_dropdown.grid(row=5, column=0, sticky=NW)
52
- self.threshold_dropdown.grid(row=6, column=0, sticky=NW)
53
- self.grey_dropdown.grid(row=7, column=0, sticky=NW)
54
- self.clahe_dropdown.grid(row=8, column=0, sticky=NW)
55
-
56
- self.create_run_frm(run_function=self.run)
57
- self.main_frm.mainloop()
58
-
59
-
60
- def run(self):
61
- config_path = self.config_select.file_path
62
- config = ConfigReader(config_path=config_path)
63
- animal_names = list(config.animal_bp_dict.keys())
64
- bps = [x[:-2] for x in config.animal_bp_dict[animal_names[0]]['X_bps']]
65
- flip_idx = get_yolo_keypoint_flip_idx(x=bps)
66
- #map_dict = {c: k for c, k in enumerate(animal_names)}
67
- bp_id_idx = None
68
- if len(animal_names) > 1:
69
- bp_id_idx = get_yolo_keypoint_bp_id_idx(animal_bp_dict=config.animal_bp_dict)
70
- train_size = int(self.train_size_dropdown.get_value()) / 100
71
- verbose = str_2_bool(self.verbose_dropdown.get_value())
72
- save_dir = self.save_dir.folder_path
73
- padding = float(self.padding_dropdown.get_value()) if self.padding_dropdown.get_value() != 'None' else 0.0
74
- sample_size = int(self.sample_size_dropdown.get_value())
75
- grey = str_2_bool(self.grey_dropdown.get_value())
76
- clahe = str_2_bool(self.clahe_dropdown.get_value())
77
- threshold = float(self.threshold_dropdown.get_value())
78
-
79
- runner = SimBA2Yolo(config_path=config_path,
80
- save_dir=save_dir,
81
- data_dir=None,
82
- train_size=train_size,
83
- threshold=threshold,
84
- verbose=verbose,
85
- greyscale=grey,
86
- padding=padding,
87
- flip_idx=flip_idx,
88
- names=tuple(animal_names),
89
- sample_size=sample_size,
90
- bp_id_idx=bp_id_idx,
91
- clahe=clahe)
92
- runner.run()
93
-
94
-
95
- #SimBA2YoloKeypointsPopUp()
96
- #simba_to_yolo_keypoints(config_path=r"C:\troubleshooting\mitra\project_folder\project_config.ini", save_dir=r'C:\troubleshooting\mitra\yolo', sample_size=150, verbose=True)
1
+ __author__ = "Simon Nilsson; sronilsson@gmail.com"
2
+
3
+ from tkinter import *
4
+
5
+ import numpy as np
6
+
7
+ from simba.mixins.config_reader import ConfigReader
8
+ from simba.mixins.pop_up_mixin import PopUpMixin
9
+ from simba.third_party_label_appenders.transform.simba_to_yolo import \
10
+ SimBA2Yolo
11
+ from simba.third_party_label_appenders.transform.utils import (
12
+ get_yolo_keypoint_bp_id_idx, get_yolo_keypoint_flip_idx)
13
+ from simba.ui.tkinter_functions import (CreateLabelFrameWithIcon, FileSelect,
14
+ FolderSelect, SimBADropDown)
15
+ from simba.utils.read_write import str_2_bool
16
+
17
+ TRAIN_SIZE_OPTIONS = np.arange(10, 110, 10)
18
+ SAMPLE_SIZE_OPTIONS = list(np.arange(50, 650, 50))
19
+
20
+ THRESHOLD_OPTIONS = [round(x, 2) for x in np.arange(0.1, 1.1, 0.1)]
21
+
22
+ PADDING_OPTIONS = list(np.round(np.arange(0.01, 10.05, 0.05),2).astype(str))
23
+ PADDING_OPTIONS = list(np.insert(PADDING_OPTIONS, 0, 'None'))
24
+
25
+ class SimBA2YoloKeypointsPopUp(PopUpMixin):
26
+
27
+ """
28
+ :example:
29
+ >>> SimBA2YoloKeypointsPopUp()
30
+ """
31
+ def __init__(self):
32
+ PopUpMixin.__init__(self, title="SIMBA TO YOLO KEYPOINTS", icon='SimBA_logo_3_small')
33
+ settings_frm = CreateLabelFrameWithIcon(parent=self.main_frm, header="SETTINGS", icon_name='settings')
34
+ self.config_select = FileSelect(parent=settings_frm, fileDescription='SIMBA PROJECT CONFIG (.INI): ', lblwidth=35, file_types=[("INI FILE", (".ini", ".INI",))], entry_width=40, initialdir=r"C:\troubleshooting\mitra\project_folder", lbl_icon='ini', tooltip_key='simba2yolo_config')
35
+ self.save_dir = FolderSelect(settings_frm, folderDescription="SAVE DIRECTORY:", lblwidth=35, entry_width=40, initialdir=r'C:\troubleshooting\mitra\yolo', lbl_icon='folder', tooltip_key='SAVE_DIR')
36
+ self.train_size_dropdown = SimBADropDown(parent=settings_frm, dropdown_options=TRAIN_SIZE_OPTIONS, label="TRAIN SIZE (%): ", label_width=35, dropdown_width=40, value=70, img='pct_2', tooltip_key='simba2yolo_train_size')
37
+ self.verbose_dropdown = SimBADropDown(parent=settings_frm, dropdown_options=['TRUE', 'FALSE'], label="VERBOSE: ", label_width=35, dropdown_width=40, value='TRUE', img='verbose', tooltip_key='verbose_dropdown')
38
+ self.padding_dropdown = SimBADropDown(parent=settings_frm, dropdown_options=PADDING_OPTIONS, label="PADDING: ", label_width=35, dropdown_width=40, value='None', img='size_black', tooltip_key='simba2yolo_padding')
39
+ self.sample_size_dropdown = SimBADropDown(parent=settings_frm, dropdown_options=SAMPLE_SIZE_OPTIONS, label="FRAME SAMPLES PER VIDEO: ", label_width=35, dropdown_width=40, value=100, img='frames', tooltip_key='simba2yolo_sample_size')
40
+ self.threshold_dropdown = SimBADropDown(parent=settings_frm, dropdown_options=THRESHOLD_OPTIONS, label="CONFIDENCE THRESHOLD: ", label_width=35, dropdown_width=40, value='None', img='threshold', tooltip_key='threshold_dropdown')
41
+ self.grey_dropdown = SimBADropDown(parent=settings_frm, dropdown_options=['TRUE', 'FALSE'], label="GREYSCALE: ", label_width=35, dropdown_width=40, value='FALSE', img='grey', tooltip_key='simba2yolo_grey')
42
+ self.clahe_dropdown = SimBADropDown(parent=settings_frm, dropdown_options=['TRUE', 'FALSE'], label="CLAHE: ", label_width=35, dropdown_width=40, value='FALSE', img='clahe', tooltip_key='simba2yolo_clahe')
43
+
44
+ settings_frm.grid(row=0, column=0, sticky=NW)
45
+ self.config_select.grid(row=0, column=0, sticky=NW)
46
+ self.save_dir.grid(row=1, column=0, sticky=NW)
47
+ self.train_size_dropdown.grid(row=2, column=0, sticky=NW)
48
+
49
+ self.verbose_dropdown.grid(row=3, column=0, sticky=NW)
50
+ self.padding_dropdown.grid(row=4, column=0, sticky=NW)
51
+ self.sample_size_dropdown.grid(row=5, column=0, sticky=NW)
52
+ self.threshold_dropdown.grid(row=6, column=0, sticky=NW)
53
+ self.grey_dropdown.grid(row=7, column=0, sticky=NW)
54
+ self.clahe_dropdown.grid(row=8, column=0, sticky=NW)
55
+
56
+ self.create_run_frm(run_function=self.run)
57
+ self.main_frm.mainloop()
58
+
59
+
60
+ def run(self):
61
+ config_path = self.config_select.file_path
62
+ config = ConfigReader(config_path=config_path)
63
+ animal_names = list(config.animal_bp_dict.keys())
64
+ bps = [x[:-2] for x in config.animal_bp_dict[animal_names[0]]['X_bps']]
65
+ flip_idx = get_yolo_keypoint_flip_idx(x=bps)
66
+ #map_dict = {c: k for c, k in enumerate(animal_names)}
67
+ bp_id_idx = None
68
+ if len(animal_names) > 1:
69
+ bp_id_idx = get_yolo_keypoint_bp_id_idx(animal_bp_dict=config.animal_bp_dict)
70
+ train_size = int(self.train_size_dropdown.get_value()) / 100
71
+ verbose = str_2_bool(self.verbose_dropdown.get_value())
72
+ save_dir = self.save_dir.folder_path
73
+ padding = float(self.padding_dropdown.get_value()) if self.padding_dropdown.get_value() != 'None' else 0.0
74
+ sample_size = int(self.sample_size_dropdown.get_value())
75
+ grey = str_2_bool(self.grey_dropdown.get_value())
76
+ clahe = str_2_bool(self.clahe_dropdown.get_value())
77
+ threshold = float(self.threshold_dropdown.get_value())
78
+
79
+ runner = SimBA2Yolo(config_path=config_path,
80
+ save_dir=save_dir,
81
+ data_dir=None,
82
+ train_size=train_size,
83
+ threshold=threshold,
84
+ verbose=verbose,
85
+ greyscale=grey,
86
+ padding=padding,
87
+ flip_idx=flip_idx,
88
+ names=tuple(animal_names),
89
+ sample_size=sample_size,
90
+ bp_id_idx=bp_id_idx,
91
+ clahe=clahe)
92
+ runner.run()
93
+
94
+
95
+ #SimBA2YoloKeypointsPopUp()
96
+ #simba_to_yolo_keypoints(config_path=r"C:\troubleshooting\mitra\project_folder\project_config.ini", save_dir=r'C:\troubleshooting\mitra\yolo', sample_size=150, verbose=True)
@@ -20,8 +20,9 @@ from simba.utils.read_write import (find_files_of_filetypes_in_directory,
20
20
  TRAIN_SIZE_OPTIONS = list(np.arange(10, 110, 10))
21
21
  SAMPLE_SIZE_OPTIONS = list(np.arange(50, 650, 50))
22
22
 
23
- PADDING_OPTIONS = list(np.round(np.arange(0.01, 10.05, 0.05),2).astype(str))
24
- PADDING_OPTIONS = list(np.insert(PADDING_OPTIONS, 0, 'None'))
23
+ _padding_arr = np.concatenate([[0.01], np.arange(0.05, 10.05, 0.05)])
24
+ PADDING_OPTIONS = [f"{x:.2f}" for x in np.round(_padding_arr, 2)]
25
+ PADDING_OPTIONS = ['None'] + PADDING_OPTIONS
25
26
 
26
27
 
27
28
 
@@ -37,26 +38,28 @@ class SLEAPAnnotations2YoloPopUp(PopUpMixin):
37
38
  def __init__(self):
38
39
  PopUpMixin.__init__(self, title="SLEAP ANNOTATIONS TO YOLO POSE ESTIMATION ANNOTATIONS", icon='sleap_small')
39
40
  settings_frm = CreateLabelFrameWithIcon(parent=self.main_frm, header="SETTINGS", icon_name='settings')
40
- self.sleap_dir = FolderSelect(settings_frm, folderDescription="SLEAP DATA DIRECTORY (.SLP):", lblwidth=35, entry_width=40, initialdir=r"D:\troubleshooting\two_animals_sleap\import_data", lbl_icon='folder')
41
- self.save_dir = FolderSelect(settings_frm, folderDescription="SAVE DIRECTORY:", lblwidth=35, entry_width=40, initialdir=r"D:\troubleshooting\two_animals_sleap\yolo_kpts_2", lbl_icon='folder')
41
+ self.sleap_dir = FolderSelect(settings_frm, folderDescription="SLEAP DATA DIRECTORY (.SLP):", lblwidth=35, entry_width=40, lbl_icon='folder', tooltip_key='SLEAP_SLP_DATA_DIR')
42
+ self.video_dir = FolderSelect(settings_frm, folderDescription="VIDEO DIRECTORY:", lblwidth=35, entry_width=40, lbl_icon='folder_video', tooltip_key='VIDEO_DIR')
43
+ self.save_dir = FolderSelect(settings_frm, folderDescription="SAVE DIRECTORY:", lblwidth=35, entry_width=40, initialdir=r"D:\troubleshooting\two_animals_sleap\yolo_kpts_2", lbl_icon='folder', tooltip_key='SAVE_DIR')
42
44
 
43
- self.verbose_dropdown = SimBADropDown(parent=settings_frm, dropdown_options=['TRUE', 'FALSE'], label="VERBOSE: ", label_width=35, dropdown_width=40, value='TRUE', img='verbose')
44
- self.train_size_dropdown = SimBADropDown(parent=settings_frm, dropdown_options=TRAIN_SIZE_OPTIONS, label="TRAIN SIZE (%): ", label_width=35, dropdown_width=40, value=70, img='pct_2')
45
- self.grey_dropdown = SimBADropDown(parent=settings_frm, dropdown_options=['TRUE', 'FALSE'], label="GREYSCALE: ", label_width=35, dropdown_width=40, value='FALSE', img='grey')
46
- self.padding_dropdown = SimBADropDown(parent=settings_frm, dropdown_options=PADDING_OPTIONS, label="PADDING: ", label_width=35, dropdown_width=40, value='None', img='size_black')
47
- self.clahe_dropdown = SimBADropDown(parent=settings_frm, dropdown_options=['TRUE', 'FALSE'], label="CLAHE: ", label_width=35, dropdown_width=40, value='FALSE', img='clahe')
48
- self.single_id_dropdown = SimBADropDown(parent=settings_frm, dropdown_options=['TRUE', 'FALSE'], label="REMOVE ANIMAL ID'S", label_width=35, dropdown_width=40, value='FALSE', img='mouse_head')
45
+ self.verbose_dropdown = SimBADropDown(parent=settings_frm, dropdown_options=['TRUE', 'FALSE'], label="VERBOSE: ", label_width=35, dropdown_width=40, value='TRUE', img='verbose', tooltip_key='verbose_dropdown')
46
+ self.train_size_dropdown = SimBADropDown(parent=settings_frm, dropdown_options=TRAIN_SIZE_OPTIONS, label="TRAIN SIZE (%): ", label_width=35, dropdown_width=40, value=70, img='pct_2', tooltip_key='simba2yolo_train_size')
47
+ self.grey_dropdown = SimBADropDown(parent=settings_frm, dropdown_options=['TRUE', 'FALSE'], label="GREYSCALE: ", label_width=35, dropdown_width=40, value='FALSE', img='grey', tooltip_key='simba2yolo_grey')
48
+ self.padding_dropdown = SimBADropDown(parent=settings_frm, dropdown_options=PADDING_OPTIONS, label="PADDING: ", label_width=35, dropdown_width=40, value='None', img='size_black', tooltip_key='simba2yolo_padding')
49
+ self.clahe_dropdown = SimBADropDown(parent=settings_frm, dropdown_options=['TRUE', 'FALSE'], label="CLAHE: ", label_width=35, dropdown_width=40, value='FALSE', img='clahe', tooltip_key='simba2yolo_clahe')
50
+ self.single_id_dropdown = SimBADropDown(parent=settings_frm, dropdown_options=['TRUE', 'FALSE'], label="REMOVE ANIMAL ID'S", label_width=35, dropdown_width=40, value='FALSE', img='mouse_head', tooltip_key='sleap_remove_animal_ids')
49
51
 
50
52
  settings_frm.grid(row=0, column=0, sticky=NW)
51
53
  self.sleap_dir .grid(row=0, column=0, sticky=NW)
52
- self.save_dir.grid(row=1, column=0, sticky=NW)
54
+ self.video_dir.grid(row=1, column=0, sticky=NW)
55
+ self.save_dir.grid(row=2, column=0, sticky=NW)
53
56
 
54
- self.verbose_dropdown.grid(row=2, column=0, sticky=NW)
55
- self.train_size_dropdown.grid(row=3, column=0, sticky=NW)
56
- self.grey_dropdown.grid(row=4, column=0, sticky=NW)
57
- self.clahe_dropdown.grid(row=5, column=0, sticky=NW)
58
- self.padding_dropdown.grid(row=6, column=0, sticky=NW)
59
- self.single_id_dropdown.grid(row=7, column=0, sticky=NW)
57
+ self.verbose_dropdown.grid(row=3, column=0, sticky=NW)
58
+ self.train_size_dropdown.grid(row=4, column=0, sticky=NW)
59
+ self.grey_dropdown.grid(row=5, column=0, sticky=NW)
60
+ self.clahe_dropdown.grid(row=6, column=0, sticky=NW)
61
+ self.padding_dropdown.grid(row=7, column=0, sticky=NW)
62
+ self.single_id_dropdown.grid(row=8, column=0, sticky=NW)
60
63
 
61
64
  self.create_run_frm(run_function=self.run)
62
65
  self.main_frm.mainloop()
@@ -65,9 +68,12 @@ class SLEAPAnnotations2YoloPopUp(PopUpMixin):
65
68
  def run(self):
66
69
  sleap_dir = self.sleap_dir.folder_path
67
70
  save_dir = self.save_dir.folder_path
71
+ video_dir = self.video_dir.folder_path
68
72
 
69
73
  check_if_dir_exists(in_dir=sleap_dir, source=f'{self.__class__.__name__} SLEAP DATA DIRECTORY', raise_error=True)
70
74
  check_if_dir_exists(in_dir=save_dir, source=f'{self.__class__.__name__} SAVE DIRECTORY', raise_error=True)
75
+ video_dir_exist = check_if_dir_exists(in_dir=video_dir, source=f'{self.__class__.__name__} VIDEO DIRECTORY', raise_error=False)
76
+ video_dir = video_dir if video_dir_exist else None
71
77
  _ = find_files_of_filetypes_in_directory(directory=sleap_dir, extensions=['.slp'], raise_error=True)
72
78
 
73
79
  grey = str_2_bool(self.grey_dropdown.get_value())
@@ -77,7 +83,15 @@ class SLEAPAnnotations2YoloPopUp(PopUpMixin):
77
83
  padding = float(self.padding_dropdown.get_value()) if self.padding_dropdown.get_value() != 'None' else 0.0
78
84
  single_id = 'animal_1' if str_2_bool(self.single_id_dropdown.get_value()) else None
79
85
 
80
- runner = SleapAnnotations2Yolo(sleap_dir=sleap_dir, save_dir=save_dir, padding=padding, train_size=train_size, verbose=verbose, greyscale=grey, clahe=clahe, single_id=single_id)
86
+ runner = SleapAnnotations2Yolo(sleap_dir=sleap_dir,
87
+ save_dir=save_dir,
88
+ video_dir=video_dir,
89
+ padding=padding,
90
+ train_size=train_size,
91
+ verbose=verbose,
92
+ greyscale=grey,
93
+ clahe=clahe,
94
+ single_id=single_id)
81
95
  runner.run()
82
96
 
83
97