Skip to content

Commit

Permalink
buttons
Browse files Browse the repository at this point in the history
  • Loading branch information
sronilsson committed Aug 6, 2024
1 parent 52f8d75 commit a66e346
Show file tree
Hide file tree
Showing 31 changed files with 20 additions and 31 deletions.
30 changes: 15 additions & 15 deletions simba/SimBA.py
Original file line number Diff line number Diff line change
Expand Up @@ -798,8 +798,8 @@ def __init__(self):

video_process_menu = Menu(menu)
fps_menu = Menu(video_process_menu)
fps_menu.add_command(label="Change FPS for single video", command=ChangeFpsSingleVideoPopUp, font=Formats.FONT_REGULAR.value)
fps_menu.add_command(label="Change FPS for multiple videos", command=ChangeFpsMultipleVideosPopUp, font=Formats.FONT_REGULAR.value)
fps_menu.add_command(label="Change FPS for single video", compound="left", image=self.menu_icons["single_blue"]["img"], command=ChangeFpsSingleVideoPopUp, font=Formats.FONT_REGULAR.value)
fps_menu.add_command(label="Change FPS for multiple videos", compound="left", image=self.menu_icons["multiple_blue"]["img"], command=ChangeFpsMultipleVideosPopUp, font=Formats.FONT_REGULAR.value)
fps_menu.add_command(label="Up-sample fps with interpolation", command=UpsampleVideosPopUp, font=Formats.FONT_REGULAR.value)

menu.add_cascade(label="Tools", menu=video_process_menu)
Expand All @@ -826,17 +826,17 @@ def __init__(self):
img_format_menu = Menu(format_menu)
video_format_menu = Menu(format_menu)

img_format_menu.add_command(label="Convert images to PNG", command=Convert2PNGPopUp, font=Formats.FONT_REGULAR.value)
img_format_menu.add_command(label="Convert images to JPEG", command=Convert2jpegPopUp, font=Formats.FONT_REGULAR.value)
img_format_menu.add_command(label="Convert images to BMP", command=Convert2bmpPopUp, font=Formats.FONT_REGULAR.value)
img_format_menu.add_command(label="Convert images to TIFF", command=Convert2TIFFPopUp, font=Formats.FONT_REGULAR.value)
img_format_menu.add_command(label="Convert images to WEBP", command=Convert2WEBPPopUp, font=Formats.FONT_REGULAR.value)
video_format_menu.add_command(label="Convert videos to MP4", command=Convert2MP4PopUp, font=Formats.FONT_REGULAR.value)
video_format_menu.add_command(label="Convert videos to AVI", command=Convert2AVIPopUp, font=Formats.FONT_REGULAR.value)
video_format_menu.add_command(label="Convert videos to WEBM", command=Convert2WEBMPopUp, font=Formats.FONT_REGULAR.value)
video_format_menu.add_command(label="Convert videos to MOV", command=Convert2MOVPopUp, font=Formats.FONT_REGULAR.value)
format_menu.add_cascade(label="Convert image file formats...", compound="left", menu=img_format_menu, font=Formats.FONT_REGULAR.value)
format_menu.add_cascade(label="Change video file formats...", compound="left", menu=video_format_menu, font=Formats.FONT_REGULAR.value)
img_format_menu.add_command(label="Convert images to PNG", compound="left", image=self.menu_icons["png"]["img"], command=Convert2PNGPopUp, font=Formats.FONT_REGULAR.value)
img_format_menu.add_command(label="Convert images to JPEG", compound="left", image=self.menu_icons["jpeg"]["img"], command=Convert2jpegPopUp, font=Formats.FONT_REGULAR.value)
img_format_menu.add_command(label="Convert images to BMP", compound="left", image=self.menu_icons["bmp"]["img"], command=Convert2bmpPopUp, font=Formats.FONT_REGULAR.value)
img_format_menu.add_command(label="Convert images to TIFF", compound="left", image=self.menu_icons["tiff"]["img"], command=Convert2TIFFPopUp, font=Formats.FONT_REGULAR.value)
img_format_menu.add_command(label="Convert images to WEBP", compound="left", image=self.menu_icons["webp"]["img"], command=Convert2WEBPPopUp, font=Formats.FONT_REGULAR.value)
video_format_menu.add_command(label="Convert videos to MP4", compound="left", image=self.menu_icons["mp4"]["img"], command=Convert2MP4PopUp, font=Formats.FONT_REGULAR.value)
video_format_menu.add_command(label="Convert videos to AVI", compound="left", image=self.menu_icons["avi"]["img"], command=Convert2AVIPopUp, font=Formats.FONT_REGULAR.value)
video_format_menu.add_command(label="Convert videos to WEBM", compound="left", image=self.menu_icons["webm"]["img"], command=Convert2WEBMPopUp, font=Formats.FONT_REGULAR.value)
video_format_menu.add_command(label="Convert videos to MOV", compound="left", image=self.menu_icons["mov"]["img"], command=Convert2MOVPopUp, font=Formats.FONT_REGULAR.value)
format_menu.add_cascade(label="Convert image file formats...", compound="left", image=self.menu_icons["image"]["img"], menu=img_format_menu, font=Formats.FONT_REGULAR.value)
format_menu.add_cascade(label="Change video file formats...", compound="left", image=self.menu_icons["video_2"]["img"], menu=video_format_menu, font=Formats.FONT_REGULAR.value)
video_process_menu.add_cascade(label="Convert file formats...", compound="left", image=self.menu_icons["convert"]["img"], menu=format_menu, font=Formats.FONT_REGULAR.value)

rm_clr_menu = Menu(video_process_menu)
Expand All @@ -860,8 +860,8 @@ def __init__(self):
video_process_menu.add_command(label="Create path plot", compound="left", image=self.menu_icons["path"]["img"], command=MakePathPlotPopUp, font=Formats.FONT_REGULAR.value)

downsample_video_menu = Menu(video_process_menu)
downsample_video_menu.add_command(label="Down-sample single video", command=DownsampleSingleVideoPopUp, font=Formats.FONT_REGULAR.value)
downsample_video_menu.add_command(label="Down-sample multiple videos", command=DownsampleMultipleVideosPopUp, font=Formats.FONT_REGULAR.value)
downsample_video_menu.add_command(label="Down-sample single video", compound="left", image=self.menu_icons["single_green"]["img"], command=DownsampleSingleVideoPopUp, font=Formats.FONT_REGULAR.value)
downsample_video_menu.add_command(label="Down-sample multiple videos", compound="left", image=self.menu_icons["multiple_green"]["img"], command=DownsampleMultipleVideosPopUp, font=Formats.FONT_REGULAR.value)
video_process_menu.add_cascade(label="Down-sample video...", compound="left", image=self.menu_icons["sample"]["img"], menu=downsample_video_menu, font=Formats.FONT_REGULAR.value)
video_process_menu.add_cascade(label="Drop body-parts from tracking data", compound="left", image=self.menu_icons["trash"]["img"], command=DropTrackingDataPopUp, font=Formats.FONT_REGULAR.value)
extract_frames_menu = Menu(video_process_menu, font=Formats.FONT_REGULAR.value)
Expand Down
Binary file added simba/assets/icons/avi.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added simba/assets/icons/bar_graph_green.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added simba/assets/icons/bmp.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added simba/assets/icons/curve_black.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added simba/assets/icons/decision_tree_blue.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added simba/assets/icons/decision_tree_purple.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added simba/assets/icons/image.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added simba/assets/icons/jpeg.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added simba/assets/icons/load_black.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added simba/assets/icons/load_blue.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added simba/assets/icons/mov.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added simba/assets/icons/mp4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added simba/assets/icons/multiple_blue.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added simba/assets/icons/multiple_yellow.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added simba/assets/icons/permutation_blue.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added simba/assets/icons/png.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added simba/assets/icons/shap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added simba/assets/icons/single_black.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added simba/assets/icons/single_blue.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added simba/assets/icons/single_green.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added simba/assets/icons/tiff.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added simba/assets/icons/trash_red.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added simba/assets/icons/video_2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added simba/assets/icons/webm.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added simba/assets/icons/webp.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 0 additions & 1 deletion simba/labelling/play_annotation_video.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ def labelling_log_writer(frame_number: int) -> None:
time_between_frames = int(1000 / video_meta_data["fps"])
cv2.namedWindow(video_name, cv2.WINDOW_NORMAL)


def print_video_txt(frame: np.ndarray,
frame_number: int,
video_info: dict) -> np.ndarray:
Expand Down
4 changes: 0 additions & 4 deletions simba/plotting/clf_validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,16 +126,12 @@ def run(self):
p, clf_val = round(float(self.data_df.loc[current_frm, self.p_col]), 3), int(self.data_df.loc[current_frm, self.clf_name])
self.add_spacer = 2
img = PlottingMixin().put_text(img=img, text=f"{self.clf_name} event # {self.bout_cnt + 1}", pos=(TextOptions.BORDER_BUFFER_X.value, (self.video_info["height"] - self.video_info["height"])+ self.spacing_scale * self.add_spacer), font_size=self.font_size, font_thickness=TextOptions.TEXT_THICKNESS.value, text_color=self.text_clr)
#cv2.putText(img, f"{self.clf_name} event # {self.bout_cnt + 1}", (10, (self.video_info["height"] - self.video_info["height"])+ self.spacing_scale * self.add_spacer), self.font, self.font_size, self.text_clr, 2)
self.add_spacer += 1
img = PlottingMixin().put_text(img=img, text=f"Total frames of event: {event_frm_count}", pos=(TextOptions.BORDER_BUFFER_X.value, (self.video_info["height"] - self.video_info["height"])+ self.spacing_scale * self.add_spacer), font_size=self.font_size, font_thickness=TextOptions.TEXT_THICKNESS.value, text_color=self.text_clr)
#cv2.putText(img, f"Total frames of event: {event_frm_count}", (10, (self.video_info["height"] - self.video_info["height"]) + self.spacing_scale * self.add_spacer), self.font, self.font_size, self.text_clr, 2)
self.add_spacer += 1
img = PlottingMixin().put_text(img=img, text=f"Frames of event {start_window} to {end_window}", pos=(TextOptions.BORDER_BUFFER_X.value, (self.video_info["height"] - self.video_info["height"])+ self.spacing_scale * self.add_spacer), font_size=self.font_size, font_thickness=TextOptions.TEXT_THICKNESS.value, text_color=self.text_clr)
#cv2.putText(img, f"Frames of event {start_window} to {end_window}", (10, (self.video_info["height"] - self.video_info["height"]) + self.spacing_scale * self.add_spacer), self.font, self.font_size, self.text_clr, 2)
self.add_spacer += 1
img = PlottingMixin().put_text(img=img, text=f"Frame number: {current_frm}", pos=(TextOptions.BORDER_BUFFER_X.value, (self.video_info["height"] - self.video_info["height"])+ self.spacing_scale * self.add_spacer), font_size=self.font_size, font_thickness=TextOptions.TEXT_THICKNESS.value, text_color=self.text_clr)
#cv2.putText(img, f"Frame number: {current_frm}", (10, (self.video_info["height"] - self.video_info["height"]) + self.spacing_scale * self.add_spacer), self.font, self.font_size, self.text_clr, 2)
self.add_spacer += 1
if (self.highlight_clr != None) and (clf_val == 1):
img = PlottingMixin().put_text(img=img, text=f"Frame {self.clf_name} probability: {p}", pos=(TextOptions.BORDER_BUFFER_X.value, (self.video_info["height"] - self.video_info["height"])+ self.spacing_scale * self.add_spacer), font_size=self.font_size, font_thickness=TextOptions.TEXT_THICKNESS.value, text_color=self.highlight_clr)
Expand Down
3 changes: 0 additions & 3 deletions simba/plotting/plot_clf_results.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,22 +169,19 @@ def create_visualizations(self):
self.frame = np.array(Image.fromarray(self.frame).rotate(90, Image.BICUBIC, expand=True))
if self.print_timers:
self.frame = PlottingMixin().put_text(img=self.frame, text="TIMERS:", pos=(TextOptions.BORDER_BUFFER_Y.value, ((self.video_meta_data["height"] - self.video_meta_data["height"]) + self.spacing_scale)), font_size=self.font_size, font_thickness=self.text_thickness, font=self.font)
#cv2.putText(self.frame, "TIMERS:", (TextOptions.BORDER_BUFFER_Y.value, ((self.video_meta_data["height"] - self.video_meta_data["height"]) + self.spacing_scale)), self.font, self.font_size, TextOptions.COLOR.value, self.text_thickness)
self.add_spacer = 2
for model_no, model_info in self.video_model_dict.items():
frame_results = self.data_df.loc[row_n, model_info["model_name"]]
self.video_model_dict[model_no]["frame_results"] = frame_results
self.video_model_dict[model_no]["time"] += (frame_results / self.fps)
if self.print_timers:
self.frame = PlottingMixin().put_text(img=self.frame, text=model_info["model_name"] + " " + str(round(self.video_model_dict[model_no]["time"], 2)), pos=(TextOptions.BORDER_BUFFER_Y.value, ((self.video_meta_data["height"] - self.video_meta_data["height"]) + self.spacing_scale * self.add_spacer)), font_size=self.font_size, font_thickness=self.text_thickness, font=self.font)
#cv2.putText(self.frame, model_info["model_name"] + " " + str(round(self.video_model_dict[model_no]["time"], 2)) + str("s"), (TextOptions.BORDER_BUFFER_Y.value, (self.video_meta_data["height"] - self.video_meta_data["height"]) + self.spacing_scale * self.add_spacer), self.font, self.font_size, TextOptions.COLOR.value, self.text_thickness)
self.add_spacer += 1
self.frame = PlottingMixin().put_text(img=self.frame, text="ENSEMBLE PREDICTION:", pos=(TextOptions.BORDER_BUFFER_Y.value, ((self.video_meta_data["height"] - self.video_meta_data["height"]) + self.spacing_scale * self.add_spacer)), font_size=self.font_size, font_thickness=self.text_thickness, font=self.font)
self.add_spacer += 1
for model_cnt, model_info in self.video_model_dict.items():
if self.video_model_dict[model_cnt]["frame_results"] == 1:
self.frame = PlottingMixin().put_text(img=self.frame, text=model_info["model_name"], pos=(TextOptions.BORDER_BUFFER_Y.value, (self.video_meta_data["height"] - self.video_meta_data["height"]) + self.spacing_scale * self.add_spacer), font_size=self.font_size, font_thickness=self.text_thickness, font=self.font, text_color=TextOptions.COLOR.value)
#cv2.putText(self.frame, model_info["model_name"], (TextOptions.BORDER_BUFFER_Y.value, (self.video_meta_data["height"] - self.video_meta_data["height"]) + self.spacing_scale * self.add_spacer), self.font, self.font_size, self.clr_lst[model_cnt], self.text_thickness)
self.add_spacer += 1
if self.video_setting:
self.writer.write(self.frame)
Expand Down
3 changes: 0 additions & 3 deletions simba/plotting/plot_clf_results_mp.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,17 +96,14 @@ def _put_text(img: np.ndarray,
img = cv2.rotate(img, cv2.ROTATE_90_CLOCKWISE)
if print_timers:
img = _put_text(img=img, text="TIMERS:", pos=(TextOptions.BORDER_BUFFER_Y.value, text_attr[SPACE_SCALE]), font_size=text_attr[FONT_SIZE], font_thickness=text_attr[TEXT_THICKNESS], font=font, text_color=(255, 255, 255))
#cv2.putText(img, "TIMERS:", (TextOptions.BORDER_BUFFER_Y.value, text_attr[SPACE_SCALE]), font, text_attr[FONT_SIZE], (0, 255, 0), text_attr[TEXT_THICKNESS])
frame_results = {}
for model in models_info.values():
frame_results[model["model_name"]] = data.loc[current_frm, model["model_name"]]
if print_timers:
cumulative_time = round(data.loc[current_frm, model["model_name"] + "_cumsum"] / video_meta_data["fps"], 3)
img = _put_text(img=img, text=f"{model['model_name']} {cumulative_time}s", pos=(TextOptions.BORDER_BUFFER_Y.value, text_attr[SPACE_SCALE] * add_spacer), font_size=text_attr[FONT_SIZE], font_thickness=text_attr[TEXT_THICKNESS], font=font, text_color=(255, 255, 255))
#cv2.putText(img, f"{model['model_name']} {cumulative_time}s", (TextOptions.BORDER_BUFFER_Y.value, text_attr[SPACE_SCALE] * add_spacer),font,text_attr[FONT_SIZE], TextOptions.COLOR.value, text_attr[TEXT_THICKNESS])
add_spacer += 1
img = _put_text(img=img, text="ENSEMBLE PREDICTION:", pos=(TextOptions.BORDER_BUFFER_Y.value, text_attr[SPACE_SCALE] * add_spacer), font_size=text_attr[FONT_SIZE], font_thickness=text_attr[TEXT_THICKNESS], font=font, text_color=(255, 255, 255))
#cv2.putText(img, "ENSEMBLE PREDICTION:", (TextOptions.BORDER_BUFFER_Y.value, int(text_attr[SPACE_SCALE] * add_spacer)), font, text_attr[FONT_SIZE], (0, 255, 0), text_attr[TEXT_THICKNESS])
add_spacer += 1
for clf_cnt, (clf_name, clf_results) in enumerate(frame_results.items()):
if clf_results == 1:
Expand Down
10 changes: 5 additions & 5 deletions simba/ui/machine_model_settings_ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def __init__(self, config_path: Union[str, os.PathLike]):
icon_link=Links.TRAIN_ML_MODEL.value,)
self.select_config_file = FileSelect(load_meta_data_frm, "CONFIG PATH:")

load_config_btn = SimbaButton(parent=load_meta_data_frm, txt="LOAD", txt_clr='blue', font=Formats.FONT_REGULAR.value, cmd=self.load_config)
load_config_btn = SimbaButton(parent=load_meta_data_frm, txt="LOAD", img='load_blue', txt_clr='blue', font=Formats.FONT_REGULAR.value, cmd=self.load_config)
label_link = Label(load_meta_data_frm, text="[MODEL SETTINGS TUTORIAL]", fg="blue", font=Formats.FONT_REGULAR.value)
label_link.bind("<Button-1>", lambda e: webbrowser.open_new("https://github.com/sgoldenlab/simba/blob/master/docs/tutorial.md#step-7-train-machine-model"))

Expand Down Expand Up @@ -145,9 +145,9 @@ def __init__(self, config_path: Union[str, os.PathLike]):
)
self.save_frame = LabelFrame(self.main_frm, text="SAVE", font=Formats.FONT_HEADER.value)

save_global_btn = SimbaButton(parent=self.save_frame, txt="SAVE SETTINGS (GLOBAL ENVIRONMENT)", txt_clr='blue', font=Formats.FONT_REGULAR.value, cmd=self.save_global)
save_meta_btn = SimbaButton(parent=self.save_frame, txt="SAVE SETTINGS (SPECIFIC MODEL)", txt_clr='green', font=Formats.FONT_REGULAR.value, cmd=self.save_config)
clear_cache_btn = SimbaButton(parent=self.save_frame, txt="CLEAR CACHE", txt_clr='red', font=Formats.FONT_REGULAR.value, cmd=self.clear_cache)
save_global_btn = SimbaButton(parent=self.save_frame, txt="SAVE SETTINGS (GLOBAL ENVIRONMENT)", txt_clr='blue', img='save_blue', font=Formats.FONT_REGULAR.value, cmd=self.save_global)
save_meta_btn = SimbaButton(parent=self.save_frame, txt="SAVE SETTINGS (SPECIFIC MODEL)", txt_clr='green', img='save_green', font=Formats.FONT_REGULAR.value, cmd=self.save_config)
clear_cache_btn = SimbaButton(parent=self.save_frame, txt="CLEAR CACHE", txt_clr='red', img='trash_red', font=Formats.FONT_REGULAR.value, cmd=self.clear_cache)

load_meta_data_frm.grid(row=0, column=0, sticky=NW)
self.select_config_file.grid(row=0, column=0, sticky=NW)
Expand Down Expand Up @@ -608,4 +608,4 @@ def get_expected_meta_dict_entry_keys(self):
]


#_ = MachineModelSettingsPopUp(config_path=r"C:\troubleshooting\mitra\project_folder\project_config.ini")
#_ = MachineModelSettingsPopUp(config_path=r"/Users/simon/Desktop/envs/simba/troubleshooting/two_black_animals_14bp/project_folder/project_config.ini")

0 comments on commit a66e346

Please sign in to comment.