dcp_client.utils package

Submodules

dcp_client.utils.bentoml_model module

class dcp_client.utils.bentoml_model.BentomlModel(client: SyncHTTPClient | None = None)

Bases: Model

BentomlModel class for connecting to a BentoML server and running inference tasks.

connect(ip: str = '0.0.0.0', port: int = 7010) bool

Connects to the BentoML server.

Parameters:
  • ip (str) – IP address of the BentoML server. Default is ‘0.0.0.0’.

  • port (int) – Port number of the BentoML server. Default is 7010.

Returns:

True if connection is successful, False otherwise.

Return type:

bool

property is_connected: bool

Checks if the BentomlModel is connected to the BentoML server.

Returns:

True if connected, False otherwise.

Return type:

bool

run_train(path: str) None

Training functionality has been removed from the server.

Parameters:

path (str) – Path to training data (not used).

Raises:

NotImplementedError – Training is no longer available.

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.utils.fsimagestorage module

class dcp_client.utils.fsimagestorage.FilesystemImageStorage

Bases: ImageStorage

FilesystemImageStorage class for handling image storage operations on the local filesystem.

delete_image(from_directory: str, cur_selected_img: str) None

Deletes an image from the specified directory.

Parameters:
  • from_directory (str) – Path to the directory containing the image.

  • cur_selected_img (str) – Name of the image file.

get_unsupported_files(directory: str) List[str]

Get a list of files in the directory that are not supported image formats.

Parameters:

directory (str) – Path to the directory to search.

Returns:

List of unsupported file names.

Return type:

list

load_image(from_directory: str, cur_selected_img: str) ndarray

Loads an image from the specified directory.

Parameters:
  • from_directory (str) – Path to the directory containing the image.

  • cur_selected_img (str) – Name of the image file.

Returns:

Loaded image.

move_image(from_directory: str, to_directory: str, cur_selected_img: str) None

Moves an image from one directory to another.

Parameters:
  • from_directory (str) – Path to the source directory.

  • to_directory (str) – Path to the destination directory.

  • cur_selected_img (str) – Name of the image file.

save_image(to_directory: str, cur_selected_img: str, img: ndarray) None

Saves an image to the specified directory.

Parameters:
  • to_directory (str) – Path to the directory where the image will be saved.

  • cur_selected_img (str) – Name of the image file.

  • img – Image data to be saved.

search_images(directory: str) List[str]

Get a list of image file names in the directory (excluding segmentation files).

Parameters:

directory (str) – Path to the directory to search for images.

Returns:

List of image file names found in the directory.

Return type:

list

dcp_client.utils.settings module

dcp_client.utils.settings.init() None

Initialise global variables.

dcp_client.utils.sync_src_dst module

dcp_client.utils.utils module

dcp_client.utils.utils.check_equal_arrays(array1: ndarray, array2: ndarray) bool

Checks if two arrays are equal.

Parameters:
  • array1 (numpy.ndarray) – The first array.

  • array2 (numpy.ndarray) – The second array.

Returns:

True if the arrays are equal, False otherwise.

Return type:

bool

dcp_client.utils.utils.get_path_name(filepath: str) str

Returns the name of the file from the given filepath.

Parameters:

filepath (str) – The path of the file.

Returns:

The name of the file.

Return type:

str

dcp_client.utils.utils.get_path_parent(filepath: str) str

Returns the parent directory of the given filepath.

Parameters:

filepath (str) – The path of the file.

Returns:

The parent directory of the file.

Return type:

str

dcp_client.utils.utils.get_path_stem(filepath: str) str

Returns the stem (filename without its extension) from the given filepath.

Parameters:

filepath (str) – The path of the file.

Returns:

The stem of the file.

Return type:

str

dcp_client.utils.utils.get_relative_path(filepath: str) str

Returns the name of the file from the given filepath.

Parameters:

filepath (str) – The path of the file.

Returns:

The name of the file.

Return type:

str

dcp_client.utils.utils.join_path(root_dir: str, filepath: str) str

Joins the root directory path with the given filepath.

Parameters:
  • root_dir (str) – The root directory.

  • filepath (str) – The path of the file.

Returns:

The joined path.

Return type:

str

dcp_client.utils.utils.read_config(name: str, config_path: str = 'config.yaml') dict

Reads the configuration file

Parameters:
  • name (string) – name of the section you want to read (e.g. ‘setup’,’train’)

  • config_path (str, optional) – path to the configuration file, defaults to ‘config.yaml’

Returns:

dictionary from the config section given by name

Return type:

dict