simba-uw-tf-dev 4.7.6__py3-none-any.whl → 4.7.7__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/assets/.recent_projects.txt +1 -0
- simba/assets/icons/folder_2.png +0 -0
- simba/assets/icons/folder_video.png +0 -0
- simba/assets/lookups/tooptips.json +24 -2
- simba/model/yolo_fit.py +42 -9
- simba/sandbox/clean_sleap.py +4 -0
- simba/third_party_label_appenders/transform/coco_keypoints_to_yolo.py +1 -2
- simba/third_party_label_appenders/transform/sleap_csv_to_yolo.py +18 -12
- simba/ui/create_project_ui.py +1 -1
- simba/ui/pop_ups/batch_preprocess_pop_up.py +1 -1
- simba/ui/pop_ups/simba_to_yolo_keypoints_popup.py +96 -96
- simba/ui/pop_ups/sleap_annotations_to_yolo_popup.py +32 -18
- simba/ui/pop_ups/sleap_csv_predictions_to_yolo_popup.py +15 -14
- simba/ui/pop_ups/yolo_plot_results.py +146 -153
- simba/ui/pop_ups/yolo_pose_train_popup.py +69 -23
- simba/utils/checks.py +2414 -2401
- simba/utils/read_write.py +22 -20
- simba/video_processors/video_processing.py +3 -2
- {simba_uw_tf_dev-4.7.6.dist-info → simba_uw_tf_dev-4.7.7.dist-info}/METADATA +1 -1
- {simba_uw_tf_dev-4.7.6.dist-info → simba_uw_tf_dev-4.7.7.dist-info}/RECORD +24 -21
- {simba_uw_tf_dev-4.7.6.dist-info → simba_uw_tf_dev-4.7.7.dist-info}/LICENSE +0 -0
- {simba_uw_tf_dev-4.7.6.dist-info → simba_uw_tf_dev-4.7.7.dist-info}/WHEEL +0 -0
- {simba_uw_tf_dev-4.7.6.dist-info → simba_uw_tf_dev-4.7.7.dist-info}/entry_points.txt +0 -0
- {simba_uw_tf_dev-4.7.6.dist-info → simba_uw_tf_dev-4.7.7.dist-info}/top_level.txt +0 -0
|
@@ -21,7 +21,8 @@ TRAIN_SIZE_OPTIONS = np.arange(10, 110, 10)
|
|
|
21
21
|
SAMPLE_SIZE_OPTIONS = list(np.arange(50, 650, 50))
|
|
22
22
|
|
|
23
23
|
PADDING_OPTIONS = list(np.round(np.arange(0.01, 10.05, 0.05),2).astype(str))
|
|
24
|
-
PADDING_OPTIONS = np.insert(PADDING_OPTIONS, 0, 'None')
|
|
24
|
+
PADDING_OPTIONS = list(np.insert(PADDING_OPTIONS, 0, 'None'))
|
|
25
|
+
|
|
25
26
|
|
|
26
27
|
THRESHOLD_OPTION = list(range(10, 110, 10))
|
|
27
28
|
|
|
@@ -38,19 +39,19 @@ class SLEAPcsvInference2Yolo(PopUpMixin):
|
|
|
38
39
|
def __init__(self):
|
|
39
40
|
PopUpMixin.__init__(self, title="SLEAP CSV PREDICTIONS TO YOLO POSE ESTIMATION ANNOTATIONS", icon='sleap_small')
|
|
40
41
|
settings_frm = CreateLabelFrameWithIcon(parent=self.main_frm, header="SETTINGS", icon_name='settings')
|
|
41
|
-
self.sleap_dir = FolderSelect(settings_frm, folderDescription="SLEAP DATA DIRECTORY:", lblwidth=35, entry_width=40, initialdir=r"D:\troubleshooting\two_animals_sleap\import_data", lbl_icon='folder')
|
|
42
|
-
self.video_dir = FolderSelect(settings_frm, folderDescription="VIDEO DIRECTORY:", lblwidth=35, entry_width=40, initialdir=r"D:\troubleshooting\two_animals_sleap\project_folder\videos", lbl_icon='
|
|
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='
|
|
44
|
-
|
|
45
|
-
self.frm_cnt_dropdown = SimBADropDown(parent=settings_frm, dropdown_options=SAMPLE_SIZE_OPTIONS, label="FRAMES (PER VIDEO): ", label_width=35, dropdown_width=40, value=100, img='frames')
|
|
46
|
-
self.verbose_dropdown = SimBADropDown(parent=settings_frm, dropdown_options=['TRUE', 'FALSE'], label="VERBOSE: ", label_width=35, dropdown_width=40, value='TRUE', img='
|
|
47
|
-
self.threshold_dropdown = SimBADropDown(parent=settings_frm, dropdown_options=THRESHOLD_OPTION, label="THRESHOLD (%): ", label_width=35, dropdown_width=40, value=90, img='threshold')
|
|
48
|
-
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')
|
|
49
|
-
self.grey_dropdown = SimBADropDown(parent=settings_frm, dropdown_options=['TRUE', 'FALSE'], label="GREYSCALE: ", label_width=35, dropdown_width=40, value='FALSE', img='grey')
|
|
50
|
-
self.padding_dropdown = SimBADropDown(parent=settings_frm, dropdown_options=PADDING_OPTIONS, label="PADDING: ", label_width=35, dropdown_width=40, value='None', img='resize')
|
|
51
|
-
self.animal_cnt_dropdown = SimBADropDown(parent=settings_frm, dropdown_options=list(range(1, 10, 1)), label="ANIMAL COUNT: ", label_width=35, dropdown_width=40, value=2, img='abacus_2')
|
|
52
|
-
self.clahe_dropdown = SimBADropDown(parent=settings_frm, dropdown_options=['TRUE', 'FALSE'], label="CLAHE: ", label_width=35, dropdown_width=40, value='FALSE', img='clahe')
|
|
53
|
-
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')
|
|
42
|
+
self.sleap_dir = FolderSelect(settings_frm, folderDescription="SLEAP DATA DIRECTORY:", lblwidth=35, entry_width=40, initialdir=r"D:\troubleshooting\two_animals_sleap\import_data", lbl_icon='folder', tooltip_key='SLEAP_DATA_DIR')
|
|
43
|
+
self.video_dir = FolderSelect(settings_frm, folderDescription="VIDEO DIRECTORY:", lblwidth=35, entry_width=40, initialdir=r"D:\troubleshooting\two_animals_sleap\project_folder\videos", lbl_icon='folder_video', tooltip_key='VIDEO_DIR')
|
|
44
|
+
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_2', tooltip_key='SAVE_DIR')
|
|
45
|
+
|
|
46
|
+
self.frm_cnt_dropdown = SimBADropDown(parent=settings_frm, dropdown_options=SAMPLE_SIZE_OPTIONS, label="FRAMES (PER VIDEO): ", label_width=35, dropdown_width=40, value=100, img='frames', tooltip_key='simba2yolo_sample_size')
|
|
47
|
+
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')
|
|
48
|
+
self.threshold_dropdown = SimBADropDown(parent=settings_frm, dropdown_options=THRESHOLD_OPTION, label="THRESHOLD (%): ", label_width=35, dropdown_width=40, value=90, img='threshold', tooltip_key='sleap_threshold')
|
|
49
|
+
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')
|
|
50
|
+
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')
|
|
51
|
+
self.padding_dropdown = SimBADropDown(parent=settings_frm, dropdown_options=PADDING_OPTIONS, label="PADDING: ", label_width=35, dropdown_width=40, value='None', img='resize', tooltip_key='simba2yolo_padding')
|
|
52
|
+
self.animal_cnt_dropdown = SimBADropDown(parent=settings_frm, dropdown_options=list(range(1, 10, 1)), label="ANIMAL COUNT: ", label_width=35, dropdown_width=40, value=2, img='abacus_2', tooltip_key='ANIMAL_COUNT')
|
|
53
|
+
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')
|
|
54
|
+
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')
|
|
54
55
|
|
|
55
56
|
settings_frm.grid(row=0, column=0, sticky=NW)
|
|
56
57
|
self.sleap_dir .grid(row=0, column=0, sticky=NW)
|
|
@@ -1,153 +1,146 @@
|
|
|
1
|
-
from tkinter import *
|
|
2
|
-
|
|
3
|
-
import numpy as np
|
|
4
|
-
|
|
5
|
-
from simba.data_processors.cuda.utils import _is_cuda_available
|
|
6
|
-
from simba.mixins.pop_up_mixin import PopUpMixin
|
|
7
|
-
from simba.plotting.yolo_pose_track_visualizer import YOLOPoseTrackVisualizer
|
|
8
|
-
from simba.plotting.yolo_pose_visualizer import YOLOPoseVisualizer
|
|
9
|
-
from simba.ui.tkinter_functions import (CreateLabelFrameWithIcon, FileSelect,
|
|
10
|
-
FolderSelect, SimbaButton,
|
|
11
|
-
SimBADropDown)
|
|
12
|
-
from simba.utils.checks import (check_file_exist_and_readable,
|
|
13
|
-
check_if_dir_exists)
|
|
14
|
-
from simba.utils.enums import Options, PackageNames
|
|
15
|
-
from simba.utils.errors import (NoDataError, SimBAGPUError,
|
|
16
|
-
SimBAPAckageVersionError)
|
|
17
|
-
from simba.utils.printing import stdout_warning
|
|
18
|
-
from simba.utils.read_write import (find_core_cnt,
|
|
19
|
-
find_files_of_filetypes_in_directory,
|
|
20
|
-
get_pkg_version, get_video_meta_data,
|
|
21
|
-
str_2_bool)
|
|
22
|
-
from simba.utils.warnings import MissingFileWarning
|
|
23
|
-
|
|
24
|
-
MAX_TRACKS_OPTIONS = ['None', 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
|
|
25
|
-
CORE_CNT_OPTIONS = list(range(1, find_core_cnt()[0]))
|
|
26
|
-
THRESHOLD_OPTIONS = list(np.arange(0.0, 1.1, 0.1).astype(np.float32))
|
|
27
|
-
SIZE_OPTIONS = list(range(1, 21, 1))
|
|
28
|
-
SIZE_OPTIONS.insert(0, 'AUTO')
|
|
29
|
-
|
|
30
|
-
class YoloPoseVisualizerPopUp(PopUpMixin):
|
|
31
|
-
|
|
32
|
-
def __init__(self):
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
self.
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
self.
|
|
46
|
-
self.
|
|
47
|
-
self.
|
|
48
|
-
self.
|
|
49
|
-
self.
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
self.
|
|
53
|
-
|
|
54
|
-
self.
|
|
55
|
-
self.
|
|
56
|
-
self.
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
self.
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
self.
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
#YoloPoseVisualizerPopUp()
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
1
|
+
from tkinter import *
|
|
2
|
+
|
|
3
|
+
import numpy as np
|
|
4
|
+
|
|
5
|
+
from simba.data_processors.cuda.utils import _is_cuda_available
|
|
6
|
+
from simba.mixins.pop_up_mixin import PopUpMixin
|
|
7
|
+
from simba.plotting.yolo_pose_track_visualizer import YOLOPoseTrackVisualizer
|
|
8
|
+
from simba.plotting.yolo_pose_visualizer import YOLOPoseVisualizer
|
|
9
|
+
from simba.ui.tkinter_functions import (CreateLabelFrameWithIcon, FileSelect,
|
|
10
|
+
FolderSelect, SimbaButton,
|
|
11
|
+
SimBADropDown)
|
|
12
|
+
from simba.utils.checks import (check_file_exist_and_readable,
|
|
13
|
+
check_if_dir_exists)
|
|
14
|
+
from simba.utils.enums import Options, PackageNames
|
|
15
|
+
from simba.utils.errors import (NoDataError, SimBAGPUError,
|
|
16
|
+
SimBAPAckageVersionError)
|
|
17
|
+
from simba.utils.printing import stdout_warning
|
|
18
|
+
from simba.utils.read_write import (find_core_cnt,
|
|
19
|
+
find_files_of_filetypes_in_directory,
|
|
20
|
+
get_pkg_version, get_video_meta_data,
|
|
21
|
+
str_2_bool)
|
|
22
|
+
from simba.utils.warnings import MissingFileWarning
|
|
23
|
+
|
|
24
|
+
MAX_TRACKS_OPTIONS = ['None', 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
|
|
25
|
+
CORE_CNT_OPTIONS = list(range(1, find_core_cnt()[0]))
|
|
26
|
+
THRESHOLD_OPTIONS = list(np.arange(0.0, 1.1, 0.1).astype(np.float32))
|
|
27
|
+
SIZE_OPTIONS = list(range(1, 21, 1))
|
|
28
|
+
SIZE_OPTIONS.insert(0, 'AUTO')
|
|
29
|
+
|
|
30
|
+
class YoloPoseVisualizerPopUp(PopUpMixin):
|
|
31
|
+
|
|
32
|
+
def __init__(self):
|
|
33
|
+
PopUpMixin.__init__(self, title="PLOT YOLO POSE ESTIMATION RESULTS", icon='ultralytics_2')
|
|
34
|
+
settings_frm = CreateLabelFrameWithIcon(parent=self.main_frm, header="SETTINGS", icon_name='settings')
|
|
35
|
+
self.save_dir = FolderSelect(settings_frm, folderDescription="SAVE DIRECTORY:", lblwidth=35, entry_width=45, lbl_icon='folder', tooltip_key='SAVE_DIR')
|
|
36
|
+
self.core_cnt_dropdown = SimBADropDown(parent=settings_frm, dropdown_options=CORE_CNT_OPTIONS, label="CPU CORE COUNT:", label_width=35, dropdown_width=40, value=int(max(CORE_CNT_OPTIONS) / 3), img='cpu_small', tooltip_key='CORE_COUNT')
|
|
37
|
+
self.bbox_dropdown = SimBADropDown(parent=settings_frm, dropdown_options=['TRUE', 'FALSE'], label="SHOW BOUNDING BOXES:", label_width=35, dropdown_width=40, value='TRUE', img='rectangle_small', tooltip_key='SHOW_ANIMAL_BBOX')
|
|
38
|
+
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')
|
|
39
|
+
self.threshold_dropdown = SimBADropDown(parent=settings_frm, dropdown_options=THRESHOLD_OPTIONS, label="THRESHOLD:", label_width=35, dropdown_width=40, value=0.0, img='threshold', tooltip_key='threshold_dropdown')
|
|
40
|
+
self.thickness_dropdown = SimBADropDown(parent=settings_frm, dropdown_options=SIZE_OPTIONS, label="LINE THICKNESS:", label_width=35, dropdown_width=40, value='AUTO', img='line', tooltip_key='yolo_plot_line_thickness')
|
|
41
|
+
self.circle_dropdown = SimBADropDown(parent=settings_frm, dropdown_options=SIZE_OPTIONS, label="CIRCLE SIZE:", label_width=35, dropdown_width=40, value='AUTO', img='circle_small', tooltip_key='yolo_plot_circle_size')
|
|
42
|
+
self.tracks_dropdown = SimBADropDown(parent=settings_frm, dropdown_options=['TRUE', 'FALSE'], label="PLOT TRACKS:", label_width=35, dropdown_width=40, value='FALSE', img='path_2', tooltip_key='yolo_plot_tracks')
|
|
43
|
+
|
|
44
|
+
settings_frm.grid(row=0, column=0, sticky=NW)
|
|
45
|
+
self.save_dir.grid(row=0, column=0, sticky=NW)
|
|
46
|
+
self.tracks_dropdown.grid(row=1, column=0, sticky=NW)
|
|
47
|
+
self.core_cnt_dropdown.grid(row=2, column=0, sticky=NW)
|
|
48
|
+
self.bbox_dropdown.grid(row=3, column=0, sticky=NW)
|
|
49
|
+
self.verbose_dropdown.grid(row=4, column=0, sticky=NW)
|
|
50
|
+
self.threshold_dropdown.grid(row=5, column=0, sticky=NW)
|
|
51
|
+
self.thickness_dropdown.grid(row=6, column=0, sticky=NW)
|
|
52
|
+
self.circle_dropdown.grid(row=7, column=0, sticky=NW)
|
|
53
|
+
|
|
54
|
+
single_video_frm = CreateLabelFrameWithIcon(parent=self.main_frm, header="PLOT SINGLE VIDEO", icon_name='video')
|
|
55
|
+
self.data_path = FileSelect(parent=single_video_frm, fileDescription='DATA PATH (CSV):', lblwidth=35, entry_width=45, file_types=[("YOLO CSV RESULT", ".csv")], lbl_icon='csv_grey', tooltip_key='yolo_plot_data_path')
|
|
56
|
+
self.video_path = FileSelect(parent=single_video_frm, fileDescription='VIDEO PATH:', lblwidth=35, entry_width=45, file_types=[("YOLO CSV RESULT", Options.ALL_VIDEO_FORMAT_OPTIONS.value)], lbl_icon='video_2', tooltip_key='yolo_plot_video_path')
|
|
57
|
+
single_video_btn = SimbaButton(parent=single_video_frm, txt='CREATE SINGLE VIDEO', img='rocket', cmd=self.run, cmd_kwargs={'multiple': False})
|
|
58
|
+
|
|
59
|
+
single_video_frm.grid(row=1, column=0, sticky=NW)
|
|
60
|
+
self.data_path.grid(row=0, column=0, sticky=NW)
|
|
61
|
+
self.video_path.grid(row=1, column=0, sticky=NW)
|
|
62
|
+
single_video_btn.grid(row=2, column=0, sticky=NW)
|
|
63
|
+
|
|
64
|
+
multiple_video_frm = CreateLabelFrameWithIcon(parent=self.main_frm, header="PLOT MULTIPLE VIDEOS", icon_name='stack')
|
|
65
|
+
self.data_dir_path = FolderSelect(parent=multiple_video_frm, folderDescription='DATA DIRECTORY:', lblwidth=35, entry_width=45, lbl_icon='folder', tooltip_key='yolo_plot_data_dir')
|
|
66
|
+
self.video_dir_path = FolderSelect(parent=multiple_video_frm, folderDescription='VIDEO DIRECTORY:', lblwidth=35, entry_width=45, lbl_icon='folder_video', tooltip_key='VIDEO_DIR')
|
|
67
|
+
multiple_video_btn = SimbaButton(parent=multiple_video_frm, txt='CREATE MULTIPLE VIDEOS', img='rocket', cmd=self.run, cmd_kwargs={'multiple': True})
|
|
68
|
+
|
|
69
|
+
multiple_video_frm.grid(row=2, column=0, sticky=NW)
|
|
70
|
+
self.data_dir_path.grid(row=0, column=0, sticky=NW)
|
|
71
|
+
self.video_dir_path.grid(row=1, column=0, sticky=NW)
|
|
72
|
+
multiple_video_btn.grid(row=2, column=0, sticky=NW)
|
|
73
|
+
|
|
74
|
+
self.main_frm.mainloop()
|
|
75
|
+
|
|
76
|
+
def run(self, multiple: bool):
|
|
77
|
+
|
|
78
|
+
save_dir = self.save_dir.folder_path
|
|
79
|
+
core_cnt = int(self.core_cnt_dropdown.get_value())
|
|
80
|
+
bbox = str_2_bool(self.bbox_dropdown.get_value())
|
|
81
|
+
verbose = str_2_bool(self.verbose_dropdown.get_value())
|
|
82
|
+
threshold = float(self.threshold_dropdown.get_value())
|
|
83
|
+
thickness = None if self.thickness_dropdown.get_value() == 'AUTO' else int(self.thickness_dropdown.get_value())
|
|
84
|
+
circle_size = None if self.circle_dropdown.get_value() == 'AUTO' else int(self.circle_dropdown.get_value())
|
|
85
|
+
tracks = str_2_bool(self.tracks_dropdown.get_value())
|
|
86
|
+
|
|
87
|
+
Plotter = YOLOPoseTrackVisualizer if tracks else YOLOPoseVisualizer
|
|
88
|
+
|
|
89
|
+
if not multiple:
|
|
90
|
+
data_path = self.data_path.file_path
|
|
91
|
+
video_path = self.video_path.file_path
|
|
92
|
+
check_file_exist_and_readable(file_path=data_path, raise_error=True)
|
|
93
|
+
_ = get_video_meta_data(video_path=video_path)
|
|
94
|
+
plotter = Plotter(data_path=data_path,
|
|
95
|
+
video_path=video_path,
|
|
96
|
+
save_dir=save_dir,
|
|
97
|
+
core_cnt=core_cnt,
|
|
98
|
+
threshold=threshold,
|
|
99
|
+
thickness=thickness,
|
|
100
|
+
circle_size=circle_size,
|
|
101
|
+
verbose=verbose,
|
|
102
|
+
bbox=bbox)
|
|
103
|
+
plotter.run()
|
|
104
|
+
else:
|
|
105
|
+
data_dir = self.data_dir_path.folder_path
|
|
106
|
+
video_dir = self.video_dir_path.folder_path
|
|
107
|
+
check_if_dir_exists(in_dir=data_dir)
|
|
108
|
+
check_if_dir_exists(in_dir=video_dir)
|
|
109
|
+
data_paths = find_files_of_filetypes_in_directory(directory=data_dir, extensions=['.csv'], raise_error=True, as_dict=True)
|
|
110
|
+
video_paths = find_files_of_filetypes_in_directory(directory=video_dir, extensions=Options.ALL_VIDEO_FORMAT_OPTIONS.value, raise_error=True, as_dict=True)
|
|
111
|
+
|
|
112
|
+
missing_videos = list([x for x in video_paths.keys() if x not in data_paths.keys()])
|
|
113
|
+
missing_data_paths = list([x for x in data_paths.keys() if x not in video_paths.keys()])
|
|
114
|
+
if len(missing_videos) > 0:
|
|
115
|
+
MissingFileWarning(msg=f'Data files are missing video files in the {video_dir} directory: {missing_videos}', source=self.__class__.__name__)
|
|
116
|
+
if len(missing_data_paths) > 0:
|
|
117
|
+
MissingFileWarning(msg=f'Video files are missing data files in the {data_dir} directory: {missing_data_paths}', source=self.__class__.__name__)
|
|
118
|
+
|
|
119
|
+
data_paths = {k:v for k, v in data_paths.items() if k in video_paths.keys()}
|
|
120
|
+
if len(list(data_paths.keys())) == 0:
|
|
121
|
+
raise NoDataError(msg=f'No data file in the {data_dir} directory has a representative video file in the {video_dir} directory', source=self.__class__.__name__)
|
|
122
|
+
video_cnt = len(list(data_paths.keys()))
|
|
123
|
+
for cnt, (name, data_path) in enumerate(data_paths.items()):
|
|
124
|
+
if name in video_paths.keys():
|
|
125
|
+
video_path = video_paths[name]
|
|
126
|
+
print(f'Plotting YOLO results for video {name} (video {cnt+1}/{video_cnt}) ...')
|
|
127
|
+
plotter = Plotter(data_path=data_path,
|
|
128
|
+
video_path=video_path,
|
|
129
|
+
save_dir=save_dir,
|
|
130
|
+
core_cnt=core_cnt,
|
|
131
|
+
threshold=threshold,
|
|
132
|
+
thickness=thickness,
|
|
133
|
+
circle_size=circle_size,
|
|
134
|
+
verbose=verbose,
|
|
135
|
+
bbox=bbox)
|
|
136
|
+
plotter.run()
|
|
137
|
+
else:
|
|
138
|
+
stdout_warning(msg=f'Skipping video {name} (no video exist in {video_dir})...')
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
#YoloPoseVisualizerPopUp()
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
|
|
@@ -1,9 +1,12 @@
|
|
|
1
|
-
|
|
1
|
+
import os
|
|
2
|
+
import sys
|
|
3
|
+
import subprocess
|
|
4
|
+
import tempfile
|
|
2
5
|
from tkinter import *
|
|
6
|
+
from tkinter import messagebox
|
|
3
7
|
|
|
4
8
|
from simba.data_processors.cuda.utils import _is_cuda_available
|
|
5
9
|
from simba.mixins.pop_up_mixin import PopUpMixin
|
|
6
|
-
from simba.model.yolo_fit import FitYolo
|
|
7
10
|
from simba.third_party_label_appenders.transform.utils import \
|
|
8
11
|
check_valid_yolo_map
|
|
9
12
|
from simba.ui.tkinter_functions import (CreateLabelFrameWithIcon, FileSelect,
|
|
@@ -17,10 +20,13 @@ from simba.utils.read_write import find_core_cnt, get_pkg_version, str_2_bool
|
|
|
17
20
|
EPOCH_OPTIONS = list(range(100, 5750, 250))
|
|
18
21
|
PATIENCE_OPTIONS = list(range(50, 1050, 50))
|
|
19
22
|
IMG_SIZE_OPTIONS = [256, 320, 416, 480, 512, 640, 720, 768, 960, 1280]
|
|
20
|
-
|
|
23
|
+
# On Windows, PyTorch DataLoader often deadlocks with workers > 8; cap options to avoid hang
|
|
24
|
+
_max_workers = min(find_core_cnt()[0], 8) if sys.platform == 'win32' else find_core_cnt()[0]
|
|
25
|
+
CORE_CNT_OPTIONS = list(range(1, _max_workers + 1))
|
|
21
26
|
BATCH_SIZE_OPTIONS = [2, 4, 8, 16, 32, 64, 128]
|
|
22
27
|
devices = ['CPU']
|
|
23
|
-
|
|
28
|
+
FORMAT_OPTIONS = Options.VALID_YOLO_FORMATS.value
|
|
29
|
+
FORMAT_OPTIONS.insert(0, 'None')
|
|
24
30
|
class YOLOPoseTrainPopUP(PopUpMixin):
|
|
25
31
|
def __init__(self):
|
|
26
32
|
gpu_available, gpus = _is_cuda_available()
|
|
@@ -33,19 +39,19 @@ class YOLOPoseTrainPopUP(PopUpMixin):
|
|
|
33
39
|
PopUpMixin.__init__(self, title="TRAIN YOLO POSE ESTIMATION MODEL", icon='ultralytics_2')
|
|
34
40
|
settings_frm = CreateLabelFrameWithIcon(parent=self.main_frm, header="SETTINGS", icon_name='settings')
|
|
35
41
|
devices.extend([f'{x} : {y["model"]}' for x, y in gpus.items()])
|
|
36
|
-
self.yolo_map_path = FileSelect(parent=settings_frm, fileDescription='YOLO MAP FILE (YAML):', lblwidth=35, entry_width=45, file_types=[("YOLO MODEL FILE", ".yaml")], lbl_icon='file')
|
|
37
|
-
self.save_dir = FolderSelect(settings_frm, folderDescription="SAVE DIRECTORY:", lblwidth=35, entry_width=45, lbl_icon='save')
|
|
38
|
-
self.weights_path = FileSelect(parent=settings_frm, fileDescription='INITIAL WEIGHT FILE (E.G., .PT):', lblwidth=35, entry_width=45, lbl_icon='file')
|
|
42
|
+
self.yolo_map_path = FileSelect(parent=settings_frm, fileDescription='YOLO MAP FILE (YAML):', lblwidth=35, entry_width=45, file_types=[("YOLO MODEL FILE", ".yaml")], lbl_icon='file', tooltip_key='yolo_map_path')
|
|
43
|
+
self.save_dir = FolderSelect(settings_frm, folderDescription="SAVE DIRECTORY:", lblwidth=35, entry_width=45, lbl_icon='save', tooltip_key='SAVE_DIR')
|
|
44
|
+
self.weights_path = FileSelect(parent=settings_frm, fileDescription='INITIAL WEIGHT FILE (E.G., .PT):', lblwidth=35, entry_width=45, lbl_icon='file', tooltip_key='yolo_initial_weights_path')
|
|
39
45
|
|
|
40
|
-
self.epochs_dropdown = SimBADropDown(parent=settings_frm, dropdown_options=EPOCH_OPTIONS, label="EPOCHS: ", label_width=35, dropdown_width=40, value=500, img='rotate')
|
|
41
|
-
self.batch_dropdown = SimBADropDown(parent=settings_frm, dropdown_options=BATCH_SIZE_OPTIONS, label="BATCH SIZE: ", label_width=35, dropdown_width=40, value=16, img='weight')
|
|
42
|
-
self.plots_dropdown = SimBADropDown(parent=settings_frm, dropdown_options=['TRUE', 'FALSE'], label="PLOTS:", label_width=35, dropdown_width=40, value='TRUE', img='plot')
|
|
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.workers_dropdown = SimBADropDown(parent=settings_frm, dropdown_options=CORE_CNT_OPTIONS, label="CPU WORKERS:", label_width=35, dropdown_width=40, value=int(max(CORE_CNT_OPTIONS)/2), img='cpu_small')
|
|
45
|
-
self.format_dropdown = SimBADropDown(parent=settings_frm, dropdown_options=
|
|
46
|
-
self.img_size_dropdown = SimBADropDown(parent=settings_frm, dropdown_options=IMG_SIZE_OPTIONS, label="IMAGE SIZE:", label_width=35, dropdown_width=40, value=640, img='resize')
|
|
47
|
-
self.patience_dropdown = SimBADropDown(parent=settings_frm, dropdown_options=PATIENCE_OPTIONS, label="PATIENCE:", label_width=35, dropdown_width=40, value=100, img='timer')
|
|
48
|
-
self.devices_dropdown = SimBADropDown(parent=settings_frm, dropdown_options=devices, label="DEVICE:", label_width=35, dropdown_width=40, value=devices[1], img='gpu_3')
|
|
46
|
+
self.epochs_dropdown = SimBADropDown(parent=settings_frm, dropdown_options=EPOCH_OPTIONS, label="EPOCHS: ", label_width=35, dropdown_width=40, value=500, img='rotate', tooltip_key='epochs_dropdown')
|
|
47
|
+
self.batch_dropdown = SimBADropDown(parent=settings_frm, dropdown_options=BATCH_SIZE_OPTIONS, label="BATCH SIZE: ", label_width=35, dropdown_width=40, value=16, img='weight', tooltip_key='batch_dropdown')
|
|
48
|
+
self.plots_dropdown = SimBADropDown(parent=settings_frm, dropdown_options=['TRUE', 'FALSE'], label="PLOTS:", label_width=35, dropdown_width=40, value='TRUE', img='plot', tooltip_key='plots_dropdown')
|
|
49
|
+
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')
|
|
50
|
+
self.workers_dropdown = SimBADropDown(parent=settings_frm, dropdown_options=CORE_CNT_OPTIONS, label="CPU WORKERS:", label_width=35, dropdown_width=40, value=int(max(CORE_CNT_OPTIONS)/2), img='cpu_small', tooltip_key='workers_dropdown')
|
|
51
|
+
self.format_dropdown = SimBADropDown(parent=settings_frm, dropdown_options=FORMAT_OPTIONS, label="FORMAT:", label_width=35, dropdown_width=40, value='None', img='file_type', tooltip_key='format_dropdown')
|
|
52
|
+
self.img_size_dropdown = SimBADropDown(parent=settings_frm, dropdown_options=IMG_SIZE_OPTIONS, label="IMAGE SIZE:", label_width=35, dropdown_width=40, value=640, img='resize', tooltip_key='img_size_dropdown')
|
|
53
|
+
self.patience_dropdown = SimBADropDown(parent=settings_frm, dropdown_options=PATIENCE_OPTIONS, label="PATIENCE:", label_width=35, dropdown_width=40, value=100, img='timer', tooltip_key='patience_dropdown')
|
|
54
|
+
self.devices_dropdown = SimBADropDown(parent=settings_frm, dropdown_options=devices, label="DEVICE:", label_width=35, dropdown_width=40, value=devices[1], img='gpu_3', tooltip_key='devices_dropdown')
|
|
49
55
|
|
|
50
56
|
settings_frm.grid(row=0, column=0, sticky=NW)
|
|
51
57
|
self.yolo_map_path.grid(row=0, column=0, sticky=NW)
|
|
@@ -74,16 +80,56 @@ class YOLOPoseTrainPopUP(PopUpMixin):
|
|
|
74
80
|
workers = int(self.workers_dropdown.get_value())
|
|
75
81
|
batch_size = int(self.batch_dropdown.get_value())
|
|
76
82
|
device = self.devices_dropdown.get_value()
|
|
77
|
-
|
|
78
|
-
|
|
83
|
+
device_str = 'cpu' if device == 'CPU' else device.split(':', 1)[0]
|
|
84
|
+
format_val = None if self.format_dropdown.get_value() == 'None' else self.format_dropdown.get_value()
|
|
79
85
|
imgsz = int(self.img_size_dropdown.get_value())
|
|
80
86
|
patience = int(self.patience_dropdown.get_value())
|
|
81
|
-
|
|
82
87
|
check_if_dir_exists(in_dir=save_dir, source=f'{self.__class__.__name__} SAVE DIRECTORY')
|
|
83
|
-
check_file_exist_and_readable(file_path=weights_path, raise_error=
|
|
88
|
+
if not check_file_exist_and_readable(file_path=weights_path, raise_error=False):
|
|
89
|
+
weights_path = None
|
|
84
90
|
check_file_exist_and_readable(file_path=yolo_map_path, raise_error=True)
|
|
85
91
|
check_valid_yolo_map(yolo_map=yolo_map_path)
|
|
86
|
-
|
|
87
|
-
|
|
92
|
+
workers_for_subprocess = min(workers, 8) if sys.platform == 'win32' else workers
|
|
93
|
+
cmd = [
|
|
94
|
+
sys.executable, '-m', 'simba.model.yolo_fit',
|
|
95
|
+
'--model_yaml', yolo_map_path,
|
|
96
|
+
'--save_path', save_dir,
|
|
97
|
+
'--epochs', str(epochs),
|
|
98
|
+
'--batch', str(batch_size),
|
|
99
|
+
'--plots', 'True' if plots else 'False',
|
|
100
|
+
'--imgsz', str(imgsz),
|
|
101
|
+
'--device', str(device_str),
|
|
102
|
+
'--verbose', 'True' if verbose else 'False',
|
|
103
|
+
'--workers', str(workers_for_subprocess),
|
|
104
|
+
'--patience', str(patience),
|
|
105
|
+
]
|
|
106
|
+
if weights_path is not None:
|
|
107
|
+
cmd.extend(['--weights_path', weights_path])
|
|
108
|
+
if format_val is not None:
|
|
109
|
+
cmd.extend(['--format', format_val])
|
|
110
|
+
|
|
111
|
+
creationflags = subprocess.CREATE_NEW_CONSOLE if sys.platform == 'win32' else 0
|
|
112
|
+
env = os.environ.copy()
|
|
113
|
+
env['MPLBACKEND'] = 'Agg'
|
|
114
|
+
try:
|
|
115
|
+
if sys.platform == 'win32':
|
|
116
|
+
cmd_line = subprocess.list2cmdline(cmd)
|
|
117
|
+
with tempfile.NamedTemporaryFile(mode='w', suffix='.bat', delete=False, newline='') as f:
|
|
118
|
+
f.write('@echo off\n' + cmd_line + '\npause\n')
|
|
119
|
+
bat_path = f.name
|
|
120
|
+
subprocess.Popen([bat_path], creationflags=creationflags, env=env)
|
|
121
|
+
else:
|
|
122
|
+
subprocess.Popen(cmd, creationflags=creationflags, env=env)
|
|
123
|
+
except Exception as e:
|
|
124
|
+
messagebox.showerror('YOLO training', f'Failed to start training process: {e}')
|
|
125
|
+
return
|
|
126
|
+
msg = (
|
|
127
|
+
'YOLO training has been started in a separate process to avoid memory issues.\n\n'
|
|
128
|
+
'On Windows a new console window will show training progress. '
|
|
129
|
+
'On other platforms, check the terminal from which SimBA was launched.\n\n'
|
|
130
|
+
f'Results will be saved to:\n{save_dir}'
|
|
131
|
+
)
|
|
132
|
+
messagebox.showinfo('YOLO training started', msg)
|
|
133
|
+
|
|
88
134
|
|
|
89
|
-
|
|
135
|
+
#@YOLOPoseTrainPopUP()
|