Skip to content

napari_cellseg3d.code_models.models.TEMPLATE_model

This is a template for a model class. It is not used in the plugin, but is here to show how to implement a model class.

Please note that custom model implementations are not fully supported out of the box yet, but might be in the future.

Classes:

Name Description
ModelTemplate_

Template for a model class. This is not used in the plugin, but is here to show how to implement a model class.

ModelTemplate_

Bases: ABC

Template for a model class. This is not used in the plugin, but is here to show how to implement a model class.

Methods:

Name Description
__init__

Reimplement this as needed; only include input_image_size if necessary. For now only in/out channels = 1 is supported.

forward

Reimplement this as needed. Ensure that output is a torch tensor with dims (batch, channels, z, y, x).

Source code in napari_cellseg3d/code_models/models/TEMPLATE_model.py
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
class ModelTemplate_(ABC):
    """Template for a model class. This is not used in the plugin, but is here to show how to implement a model class."""

    weights_file = (
        "model_template.pth"  # specify the file name of the weights file only
    )
    default_threshold = 0.5  # specify the default threshold for the model

    @abstractmethod
    def __init__(self, input_image_size, in_channels=1, out_channels=1, **kwargs):
        """Reimplement this as needed; only include input_image_size if necessary. For now only in/out channels = 1 is supported."""
        pass

    @abstractmethod
    def forward(self, x):
        """Reimplement this as needed. Ensure that output is a torch tensor with dims (batch, channels, z, y, x)."""
        pass

__init__ abstractmethod

__init__(input_image_size, in_channels=1, out_channels=1, **kwargs)

Reimplement this as needed; only include input_image_size if necessary. For now only in/out channels = 1 is supported.

Source code in napari_cellseg3d/code_models/models/TEMPLATE_model.py
17
18
19
20
@abstractmethod
def __init__(self, input_image_size, in_channels=1, out_channels=1, **kwargs):
    """Reimplement this as needed; only include input_image_size if necessary. For now only in/out channels = 1 is supported."""
    pass

forward abstractmethod

forward(x)

Reimplement this as needed. Ensure that output is a torch tensor with dims (batch, channels, z, y, x).

Source code in napari_cellseg3d/code_models/models/TEMPLATE_model.py
22
23
24
25
@abstractmethod
def forward(self, x):
    """Reimplement this as needed. Ensure that output is a torch tensor with dims (batch, channels, z, y, x)."""
    pass