utils
General helpful utilities to be found here.
Module
Submodules
- bitfount.utils.concurrency_utils - Useful components related to asyncio, multithreading or multiprocessing.
- bitfount.utils.db_connector - Helper class to connect to local SQLite database.
- bitfount.utils.fs_utils - Utility functions to interact with the filesystem.
- bitfount.utils.logging_utils - Utilities for logging and warning messages functionality.
- bitfount.utils.numpy_utils - Utility functions for interacting with numpy.
- bitfount.utils.pandas_utils - Utility functions for interacting with pandas.
- bitfount.utils.ssl_utils - Utilities/patches for working with non-standard SSL configurations.
- bitfount.utils.web_utils - Utility functions for web interactions.
Functions
is_notebook
def is_notebook() ‑> bool:
Checks if code is being executed in a notebook or not.
one_hot_encode_list
def one_hot_encode_list( targets: Union[np.ndarray, Iterable[np.ndarray], Iterable[int], Iterable[Iterable[int]]],) ‑> numpy.ndarray:
Converts a list of targets into a list of one-hot targets.
seed_all
def seed_all(seed_value: Optional[int] = None) ‑> None:
Sets random seed for numpy
, python.random
and any other relevant library.
If pytorch
is used as the backend, this is just a wrapper around the
seed_everything
function from pytorch-lightning
.
PYTHONHASHSEED
is not set as an environment variable because this has no effect
once the process has been started. If you wish to set this, you should set it
yourself in your own environment before running python.
Arguments
seed_value
: The seed value to use. If None, uses the default seed (42).
Classes
ExampleSegmentationData
class ExampleSegmentationData():
A synthetic segmentation dataset example.
This class is used mainly in Tutorial 10 and testing.
Methods
generate_data
def generate_data(self, height: int, width: int, count: int) ‑> tuple:
Generate random data given height, weight and count.
Arguments
height
: The height of the images to generate.width
: The width of the images to generate.count
: The number of images to generate.
masks_to_colorimg
def masks_to_colorimg(self, masks: np.ndarray) ‑> numpy.ndarray:
Adds RGB coloring to masks.
Arguments
masks
: The masks to which we want to add coloring.
Returns The masks with RGB coloring applied to them.