segmenter_model_zoo package¶
Subpackages¶
- segmenter_model_zoo.bin package
- segmenter_model_zoo.model_wrapper package
- Submodules
- segmenter_model_zoo.model_wrapper.DNA_MEM_instance_basic module
- segmenter_model_zoo.model_wrapper.DNA_MEM_instance_plus_LF module
- segmenter_model_zoo.model_wrapper.DNA_MEM_instance_plus_LF_two_camera module
- segmenter_model_zoo.model_wrapper.LMNB1_morphological_production_alpha module
- segmenter_model_zoo.model_wrapper.LMNB1_morphological_with_labelfree module
- segmenter_model_zoo.model_wrapper.structure_AAVS1_100x_hipsc module
- segmenter_model_zoo.model_wrapper.structure_H2B_100x_hipsc module
- Module contents
Submodules¶
segmenter_model_zoo.quilt_utils module¶
-
class
segmenter_model_zoo.quilt_utils.
QuiltModelZoo
[source]¶ Bases:
object
download model from quilt
connect to model zoo on quilt3
segmenter_model_zoo.utils module¶
-
segmenter_model_zoo.utils.
bb_intersection_over_union
(boxA, boxB)[source]¶ computer IOU of two bounding boxes
-
segmenter_model_zoo.utils.
exist_double_assignment
(cell_pairs)[source]¶ check if one object is associated with multiple pairs
-
segmenter_model_zoo.utils.
find_strongest_associate
(main_score, aux_score)[source]¶ find the most likely pair from all candidate in one bounding box
-
segmenter_model_zoo.utils.
getLargestCC
(labels, is_label=True)[source]¶ return the largest connect component from a label image or a binary image
-
segmenter_model_zoo.utils.
load_filenames
(data_config)[source]¶ load the filenames of all the images need to be processed based on config. Three types of loading are currently supported: - “folder”
two parameters are required: “dir” and “search”. Basically, we just
search using the rules defined by “search” (either “*” for all files or a regular expression) inside the folder “dir”. * one optional parameter: “data_range”. If provided, a specific range of all files will be processed, e.g. [0, 100] or [100, -1]. This is useful when running in a distributed setting.
- “zstack”
one parameter: “dir” specifying the filepath
- “csv”
two parameters are required: “file” and “column”. After loading the
csv pointed by “file”, all filenames in the column defined by “column” will be identified as files to be processed.
-
segmenter_model_zoo.utils.
prune_cell_pairs
(multi_pair, current_best_pair)[source]¶ update candidates after taking out one pair
-
segmenter_model_zoo.utils.
save_as_uint
(img: numpy.ndarray, save_path: Union[str, pathlib.Path], core_fn: str, overwrite: bool = False, tag: str = 'segmentation')[source]¶ save the segmentation to disk as uint type (either 8-bit or 16-bit depending on data)
- Parameters
img (np.ndarray) – the image to save
save_path (Union[str, Path]) – the path to save the image
core_fn (str) – saved filename will be {core_fn}_{tag}.tiff
overwrite (bool) – whether allowing overwriting existing results
tag (str) – the tag to be added to the end of output filename default is “segmentation”
segmenter_model_zoo.zoo module¶
-
class
segmenter_model_zoo.zoo.
SegModel
[source]¶ Bases:
object
-
apply_on_single_zstack
(input_img: numpy.ndarray = None, filename: str = None, inputCh: Union[int, List[int]] = None, normalization: int = None, already_normalized: bool = False, cutoff: float = None, inference_param: Dict = {}) → numpy.ndarray[source]¶ Apply a trained model on an image
- input_img: np.ndarray
the image to be applied can be passed in as a numpy array
- filename: str
the image to be appplied can be passed in as a filename. If input_img is used, the filename will be omitted
- inputCh: Union(int, List(int))
when filename is used, inputCh must be specified. It can be an integer (if only one channel is needed), or a list of integers (if multiple channels are needed). Each model may have different requirement.
- normalization: int
an index to indicate which normalization reciepy will be used to normalize the image
- already_normalized: bool
A flag to indicate whether the image has been normalized or not. This is applicable to both cases: numpy array or filename.
- cutoff: float
a cutoff value can be passed in, which will be applied on the prediction. If nothing passed in, default value will be used.
- inference_param: Dict
a dictionary to pass in extra parameters for inference. Currently, only one parameter is allowed: “ResizeRatio” (a list of three float numbers to indicate the ResizeRatio to apply on ZYX axis). More parameters may be added in the future.
- output_img: np.ndarray
the segmentation result
-
load_train
(checkpoint_name: str, model_param: Dict = {'local_path': './'})[source]¶ load a trained model
- Parameters
checkpoint_name (str) – the name of the model, use list_all_trained_models() to get a list of all current models
model_param (Dict) – a dictionary of additional parameters can be passed in. If nothing is passed in, default parameters will be used. There are two important parameters: “local_path” and “model_path”. If “model_path” is specified, it will be loaded directly. Otherwise, the model will be downloaded from quilt and save at “local_path” (default is the current working directory).
-
-
class
segmenter_model_zoo.zoo.
SuperModel
(model_name: str, model_param: Dict = {'local_path': './'})[source]¶ Bases:
object
Define a SuperModel
- model_name: str
the name of the super model
- model_param: Dict
the extra parameters for the super model. the order must match the order of models in this SuperModel. For each dict, there are two importance parameters: “local_path” and “model_path”. “model_path” is a dictionary specifying the path to each basic model, e.g. “model_path”: {“DNA_mask_production”: “/path/to/mask/model”, “DNA_seed_production”: “path/to/seed/model”}. If “model_path” is specified, the model will be loaded directly. Otherwise, the models will be downloaded from quilt and saved at “local_path” (default is the current working directory).
-
apply_on_single_zstack
(input_img: numpy.ndarray = None, filename: Union[str, pathlib.Path] = None, inputCh: List = [0], **kwargs) → Union[numpy.ndarray, List][source]¶ Appply a super model on one image
- input_img: np.ndarray
the image to be segmented, if it is not None, filename and inputCh will not be used. Otherwise, use filename and inputCh to read image
- filename: Union(str, Path)
when input_img is None, use filename to load image
- inputCh: List
when input_img is None, take specific channels from the image loaded from filename
- output: Union[np.ndarray, List]
the segmentation result
Module contents¶
Top-level package for segmenter_model_zoo.