Skip to content

Advanced Functionalities

AdvancedAnalysis

Function to open a toplevel where masks can either be created for training purposes or can be inspected subsequent to labelling.

is_running property writable

Instance method to define the is_running property getter method. By defining this as a property, is_running is treated like a public attribute even though it is private.

This is used to stop the analysis process running in a seperate thread.

RETURNS DESCRIPTION
is_running

Boolean variable to check whether the analysis process started from the GUI is running. The process is only stopped when is_running = True.

TYPE: bool

should_stop property writable

Instance method to define the should_stop property getter method. By defining this as a property, should_stop is treated like a public attribute even though it is private.

This is used to stop the analysis process running in a seperate thread.

RETURNS DESCRIPTION
should_stop

Boolean variable to decide whether the analysis process started from the GUI should be stopped. The process is stopped when should_stop = True.

TYPE: bool

augment_images()

Instance method to augment input images, when the "Augment Images" button is pressed. Input parameters for the gui_helpers.image_augmentation function are taken from the chosen image and mask directories. The newly generated data will be saved under the same directories.

crop_video()

Crops the loaded video based on the selected start and end frames.

display_frame(frame_index)

Displays a specific frame on the canvas.

do_break()

Instance method to break the analysis process when the button "break" is pressed.

This changes the instance attribute self.should_stop to True, given that the analysis is already running. The attribute is checked befor every iteration of the analysis process.

get_mask_dir()

Instance method to ask the user to select the training mask directory path. All mask files (of the same specified filetype) in the directory are analysed.The mask files and the corresponding image must have the exact same name. This must be an absolute path.

get_output_dir()

Instance method to ask the user to select the output directory path. Here, all file created during model training (model file, weight file, graphs) are saved. This must be an absolute path.

get_train_dir()

Instance method to ask the user to select the training image directory path. All image files (of the same specified filetype) in the directory are analysed. This must be an absolute path.

load_video()

Loads a video and displays the first frame in the cropping interface.

on_mask_change(*args)

Depending on which mask opration is selected, this function adapts the GUI.

Instance method to open new window for model training. The window is opened upon pressing of the "analysis parameters" button.

Several parameters are displayed. - Image Directory: The user must select or input the image directory. This path must to the directory containing the training images. Images must be in RGB format. - Mask Directory: The user must select or input the mask directory. This path must to the directory containing the training images. Masks must be binary. - Output Directory: The user must select or input the mask directory. This path must lead to the directory where the trained model and the model weights should be saved. - Batch Size: The user must input the batch size used during model training by selecting from the dropdown list or entering a value. Although a larger batch size has advantages during model trainig, the images used here are large. Thus, the larger the batch size, the more compute power is needed or the longer the training duration. Integer, must be non-negative and non-zero. - Learning Rate: The user must enter the learning rate used for model training by selecting from the dropdown list or entering a value. Float, must be non-negative and non-zero. - Epochs: The user must enter the number of Epochs used during model training by selecting from the dropdown list or entering a value. The total amount of epochs will only be used if early stopping does not happen. Integer, must be non-negative and non-zero. - Loss Function: The user must enter the loss function used for model training by selecting from the dropdown list. These can be "BCE" (binary cross-entropy), "Dice" (Dice coefficient) or "FL"(Focal loss).

Model training is started by pressing the "start training" button. Although all parameters relevant for model training can be adapted, we advise users with limited experience to keep the pre-defined settings. These settings are best practice and devised from the original papers that proposed the models used here. Singularly the batch size should be adapted to 1 if comupte power is limited (no GPU or GPU with RAM lower than 8 gigabyte).

There is an "Augment Images" button, which allows to generate new training images. The images and masks for the data augmentation are taken from the chosen image directory and mask directory. The new images are saved under the same directories.

on_slider_change(value)

Triggered when the slider is moved. Displays the corresponding frame.

remove_video_parts()

Removes the selected parts from the video and saves the modified video.

resize_video()

Crops the selected area from the video and saves the cropped video.

train_model()

Instance method to execute the model training when the "start training" button is pressed.

By pressing the button, a seperate thread is started in which the model training is run. This allows the user to break any training process at certain stages. When the analysis can be interrupted, a tk.messagebox opens asking the user to either continue or terminate the analysis. Moreover, the threading allows interaction with the GUI during ongoing analysis process.

update_slider_range()

Updates the slider to match the number of frames in the video.