dcp_client package

The dcp_client package contains modules and subpackages for interacting with a server for model inference. It provides functionalities for managing GUI windows, handling image storage, and connecting to the server for model operations.

dcp_client.app
Defines the core application class and related functionalities.
  • dcp_client.app.Application: Represents the main application and provides methods for image management, model interaction, and server connectivity.

  • dcp_client.app.DataSync: Abstract base class for data synchronization operations.

  • dcp_client.app.ImageStorage: Abstract base class for image storage operations.

  • dcp_client.app.Model: Abstract base class for model operations.

dcp_client.gui
Contains modules for GUI components.
  • dcp_client.gui.main_window: Defines the main application window and associated event functions.

  • dcp_client.gui.napari_window: Manages the Napari window and its functionalities.

  • dcp_client.gui.welcome_window: Implements the welcome window and its interactions.

dcp_client.utils
Contains utility modules for various tasks.
  • dcp_client.utils.bentoml_model: Handles interactions with BentoML for model inference.

  • dcp_client.utils.fsimagestorage: Provides functions for managing images stored in the filesystem.

  • dcp_client.utils.settings: Defines initialization functions and settings.

  • dcp_client.utils.sync_src_dst: Implements data synchronization between source and destination.

  • dcp_client.utils.utils: Offers various utility functions for common tasks.

Submodules

dcp_client.app module

class dcp_client.app.Application(ml_model: Model, num_classes: int, image_storage: ImageStorage, server_ip: str, server_port: int, uncur_data_path: str = '', cur_data_path: str = '', inprogr_data_path: str = '')

Bases: object

check_existing_segmentations()

Checks if any images in uncur_data_path already have segmentation files.

Returns:

Dictionary with image names as keys and list of existing segmentation files as values. Returns empty dict if no segmentations exist.

Return type:

dict

delete_images(image_names)

If image_name in the image_names list exists in the current directory it is deleted.

Parameters:

image_names (list[str]) – A list of image names to be deleted.

extract_features(save_path: str, selected_features: dict)

Compute selected features for all images in curated dataset and save as CSV.

Returns (success: bool, message: str)

load_image(image_name=None)

Loads an image from the file system storage.

Parameters:

image_name (str) – The name of the image file to load. If not provided, loads the currently selected image.

Returns:

The loaded image.

Return type:

numpy.ndarray

move_images(dst_directory, move_segs=False)

Moves cur_selected_img image from the current directory to the dst_directory.

Parameters:
  • dst_directory (str) – The destination directory where the images will be moved.

  • move_segs (bool) – If True, moves the corresponding segmentation along with the image. Default is False.

run_inference(progress_callback=None, skip_images=None)

Checks if the ml model is connected to the server, connects if not (and if possible), and runs inference on all images in uncur_data_path

Parameters:
  • progress_callback (callable, optional) – Optional callback function to report progress. Called with (current, total) arguments.

  • skip_images (set or list, optional) – Optional set/list of image names to skip during segmentation.

run_train()

Checks if the ml model is connected to the server, connects if not (and if possible), and trains the model with all data available in cur_data_path

save_image(dst_directory, image_name, img)

Saves img array image in the dst_directory with filename cur_selected_img

Parameters:
  • dst_directory (str) – The destination directory where the image will be saved.

  • image_name (str) – The name of the image file.

  • img (numpy.ndarray) – The image that will be saved.

search_segs()

Searches in cur_selected_path for all possible segmentation files associated to cur_selected_img. These files should have a _seg extension to the cur_selected_img filename.

try_server_connection()

Checks if the ml model is connected to server and attempts to connect if not.

class dcp_client.app.ImageStorage

Bases: ABC

abstract load_image(from_directory, cur_selected_img) Tuple[ndarray[Any, dtype[_ScalarType_co]], ndarray[Any, dtype[_ScalarType_co]]]
abstract save_image(to_directory, cur_selected_img, img) None
search_segs(img_directory, cur_selected_img)

Returns a list of full paths of segmentations for an image

class dcp_client.app.Model

Bases: ABC

abstract run_train(path: str) None
abstract async segment_image(image: ndarray[Any, dtype[_ScalarType_co]]) ndarray[Any, dtype[_ScalarType_co]]

Segments a single image.

Parameters:

image (NDArray) – Pre-loaded image as numpy array

Returns:

Segmentation mask

Return type:

NDArray

dcp_client.gui module

dcp_client.utils module