From 61f3e3f38ae0e3a6d5a06923828d67d2c143d0d8 Mon Sep 17 00:00:00 2001 From: William Patton Date: Mon, 17 Feb 2025 14:05:43 -0800 Subject: [PATCH] update documentation --- .../architectures/model_zoo_config.py | 8 ++-- .../experiments/tasks/predictors/predictor.py | 44 +------------------ 2 files changed, 6 insertions(+), 46 deletions(-) diff --git a/dacapo/experiments/architectures/model_zoo_config.py b/dacapo/experiments/architectures/model_zoo_config.py index df3780811..e05cf02e1 100644 --- a/dacapo/experiments/architectures/model_zoo_config.py +++ b/dacapo/experiments/architectures/model_zoo_config.py @@ -6,7 +6,7 @@ from funlib.geometry import Coordinate -from bioimageio.core import load_description_and_test +from bioimageio.core import load_description from bioimageio.core.model_adapters._pytorch_model_adapter import PytorchModelAdapter from bioimageio.spec import InvalidDescr from bioimageio.spec.model.v0_5 import ( @@ -28,7 +28,7 @@ class ModelZooConfig(ArchitectureConfig): Support is currently limited to models saved with the `PytorchStateDictWeightsDescr`. See more info here: https://bioimage-io.github.io/spec-bioimage-io/bioimageio/spec/model/v0_5.html#PytorchStateDictWeightsDescr - We try to support all model_id formats that are supported by the `bioimageio.core` `load_description_and_test` function. + We try to support all model_id formats that are supported by the `bioimageio.core` `load_description` function. However there seem to be some cases that fail. You may receive an `InvalidDescr` error when trying to load a model from a downloaded rdf file. In this case downloading the zipped model, or using the models name e.g. "affable-shark" should work. @@ -80,11 +80,11 @@ def model_description(self) -> ModelDescr: if isinstance(self.model_id, Path) and self.model_id.suffix == ".zip": with zipfile.ZipFile(self.model_id, "r") as zip_ref: zip_ref.extractall(Path(f"{self.model_id}.unzip")) - self._model_description = load_description_and_test( + self._model_description = load_description( Path(f"{self.model_id}.unzip") ) else: - self._model_description = load_description_and_test(self.model_id) + self._model_description = load_description(self.model_id) if isinstance(self._model_description, InvalidDescr): raise Exception("Invalid model description") return self._model_description diff --git a/dacapo/experiments/tasks/predictors/predictor.py b/dacapo/experiments/tasks/predictors/predictor.py index bb236ce60..47e9e154b 100644 --- a/dacapo/experiments/tasks/predictors/predictor.py +++ b/dacapo/experiments/tasks/predictors/predictor.py @@ -31,19 +31,9 @@ class Predictor(ABC): def create_model(self, architecture: "Architecture") -> "Model": """ Given a training architecture, create a model for this predictor. - This is usually done by appending extra layers to the output of the + This is usually done by appending a single final conv layer to the output of the architecture to get the output tensor of the architecture into the right shape for this predictor. - - Args: - architecture: The training architecture. - Returns: - The model. - Raises: - NotImplementedError: This method is not implemented. - Examples: - >>> predictor.create_model(architecture) - """ pass @@ -58,7 +48,7 @@ def create_target(self, gt: Array) -> Array: compared to the prediction (i.e., the output of the model). Depending on the predictor, the target can therefore be different from the ground-truth (e.g., an instance segmentation ground-truth would have to - be converted into boundaries, if the model is predicting boundaries). + be converted into affinities, if the model is predicting affinities). By default, it is assumed that the spatial dimensions of ground-truth and target are the same. @@ -67,16 +57,6 @@ def create_target(self, gt: Array) -> Array: (e.g., because it predicts the distance to a boundary, up to a certain threshold), you can request a larger ground-truth region. See method ``gt_region_for_roi``. - - Args: - gt: The ground-truth array. - Returns: - The target array. - Raises: - NotImplementedError: This method is not implemented. - Examples: - >>> predictor.create_target(gt) - """ pass @@ -119,31 +99,11 @@ def gt_region_for_roi(self, target_spec): Overwrite this method to request ground-truth in a larger ROI, as needed. - - Args: - target_spec: The ROI for which the target is requested. - Returns: - The ROI for which the ground-truth is requested. - Raises: - NotImplementedError: This method is not implemented. - Examples: - >>> predictor.gt_region_for_roi(target_spec) - - """ return target_spec def padding(self, gt_voxel_size: Coordinate) -> Coordinate: """ Return the padding needed for the ground-truth array. - - Args: - gt_voxel_size: The voxel size of the ground-truth array. - Returns: - The padding needed for the ground-truth array. - Raises: - NotImplementedError: This method is not implemented. - Examples: - >>> predictor.padding(gt_voxel_size) """ return Coordinate((0,) * gt_voxel_size.dims)