diff --git a/README.md b/README.md index 91088fa..bb73815 100644 --- a/README.md +++ b/README.md @@ -83,6 +83,7 @@ For more details on setting up a development environment see [DEVELOPMENT docs]( 1. Merge `main` to `release` with a _merge commit_. 2. Run "Create Release" workflow with workflow from `release` branch. 3. Merge `release` to `main` with a _merge commit_. +4. Check package versions in Conda Feedstock [meta.yaml file](https://github.com/conda-forge/nrtk-explorer-feedstock/blob/main/recipe/meta.yaml) [1]: https://trame.readthedocs.io/en/latest/ [2]: https://www.kitware.com/ diff --git a/pyproject.toml b/pyproject.toml index d102fc9..7cd4746 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -30,7 +30,7 @@ dependencies = [ "accelerate", "numpy", "Pillow", - "pybsm>=0.6,<=0.9.0", + "pybsm==0.10.2", "scikit-learn>=1.6.0", "smqtk_image_io", "tabulate", @@ -42,7 +42,7 @@ dependencies = [ "transformers", "datasets[vision]", "umap-learn", - "nrtk[headless]>=0.12.0,<=0.16.0", + "nrtk[headless]==0.18.0", "trame-annotations>=0.4.0", ] diff --git a/src/nrtk_explorer/app/transforms.py b/src/nrtk_explorer/app/transforms.py index e0aabd5..d5ec247 100644 --- a/src/nrtk_explorer/app/transforms.py +++ b/src/nrtk_explorer/app/transforms.py @@ -8,7 +8,6 @@ from trame_server import Server import nrtk_explorer.library.transforms as trans -import nrtk_explorer.library.nrtk_transforms as nrtk_trans import nrtk_explorer.library.yaml_transforms as nrtk_yaml from nrtk_explorer.library import object_detector from nrtk_explorer.library.app_config import process_config @@ -173,9 +172,6 @@ def delete_meta_state(old_ids, new_ids): "identity": trans.IdentityTransform, } - if nrtk_trans.nrtk_transforms_available(): - self._transform_classes["nrtk_pybsm"] = nrtk_trans.NrtkPybsmTransform - # Add transform from YAML definition self._transform_classes.update(nrtk_yaml.generate_transforms()) diff --git a/src/nrtk_explorer/library/nrtk_transforms.py b/src/nrtk_explorer/library/nrtk_transforms.py index 973734a..010cb93 100644 --- a/src/nrtk_explorer/library/nrtk_transforms.py +++ b/src/nrtk_explorer/library/nrtk_transforms.py @@ -1,33 +1,14 @@ -from typing import Any, Dict, Optional, TYPE_CHECKING - import numpy as np import logging -from PIL import Image as ImageModule -from PIL.Image import Image -from nrtk_explorer.library.transforms import ImageTransform, ParameterDescription - -ENABLED_NRTK_TRANSFORMS = True logger = logging.getLogger(__name__) logger.setLevel(logging.INFO) try: from pybsm.otf import dark_current_from_density - from nrtk.impls.perturb_image.pybsm.perturber import PybsmPerturber, PybsmSensor, PybsmScenario + from nrtk.impls.perturb_image.pybsm.perturber import PybsmSensor, PybsmScenario except ImportError: logger.info("Disabling NRTK transforms due to missing library/failing imports") - ENABLED_NRTK_TRANSFORMS = False - -if TYPE_CHECKING: - PybsmPerturberType = PybsmPerturber -else: - PybsmPerturberType = None - -PybsmPerturberArg = Optional[PybsmPerturberType] - - -def nrtk_transforms_available(): - return ENABLED_NRTK_TRANSFORMS # copied from https://github.com/Kitware/nrtk/blob/main/tests/impls/test_pybsm_utils.py @@ -144,54 +125,3 @@ def create_sample_scenario(): def create_sample_sensor_and_scenario(): return dict(sensor=create_sample_sensor(), scenario=create_sample_scenario()) - - -class NrtkPybsmTransform(ImageTransform): - def __init__(self, perturber: PybsmPerturberArg = None): - if perturber is None: - kwargs = create_sample_sensor_and_scenario() - perturber = PybsmPerturber(**kwargs) - - self._perturber: PybsmPerturber = perturber - - def get_parameters(self) -> dict[str, Any]: - return { - "D": self._perturber.sensor.D, - "f": self._perturber.sensor.f, - } - - def set_parameters(self, params: Dict[str, Any]): - self._perturber.sensor.D = params["D"] - self._perturber.sensor.f = params["f"] - - @classmethod - def get_parameters_description(cls) -> Dict[str, ParameterDescription]: - aperture_description: ParameterDescription = { - "type": "float", - "label": "Effective Aperture (m)", - "default": None, - "description": None, - "options": None, - } - - focal_description: ParameterDescription = { - "type": "float", - "label": "Focal Length (m)", - "default": None, - "description": None, - "options": None, - } - - return { - "D": aperture_description, - "f": focal_description, - } - - def execute(self, input: Image, *input_args: Any) -> Image: - if len(input_args) == 0: - input_args = ({"img_gsd": 0.15},) - - input_array = np.asarray(input) - output_array = self._perturber.perturb(input_array, *input_args) - - return ImageModule.fromarray(output_array) diff --git a/src/nrtk_explorer/library/nrtk_transforms.yaml b/src/nrtk_explorer/library/nrtk_transforms.yaml index c63a8bd..71dcee9 100644 --- a/src/nrtk_explorer/library/nrtk_transforms.yaml +++ b/src/nrtk_explorer/library/nrtk_transforms.yaml @@ -115,10 +115,10 @@ nrtk_pybsm_detector_otf: type: float label: Focal length (m) -nrtk_pybsm_2: +nrtk_pybsm: perturber: nrtk.impls.perturb_image.pybsm.perturber.PybsmPerturber perturber_kwargs: nrtk_explorer.library.nrtk_transforms.create_sample_sensor_and_scenario - exec_default_args: [{ img_gsd: 0.15 }] + exec_default_args: [None, { img_gsd: 0.15 }] description: D: _path: [sensor, D] diff --git a/src/nrtk_explorer/library/yaml_transforms.py b/src/nrtk_explorer/library/yaml_transforms.py index e1f3365..3cef3c8 100644 --- a/src/nrtk_explorer/library/yaml_transforms.py +++ b/src/nrtk_explorer/library/yaml_transforms.py @@ -152,6 +152,6 @@ def execute(self, input, *input_args): input_args = self.exec_args input_array = np.asarray(input) - output_array = self._perturber.perturb(input_array, *input_args) + output_array, unknown = self._perturber.perturb(input_array, *input_args) return ImageModule.fromarray(output_array) diff --git a/tests/test_transforms.py b/tests/test_transforms.py index 1c758c9..8f41710 100644 --- a/tests/test_transforms.py +++ b/tests/test_transforms.py @@ -14,6 +14,6 @@ def test_gaussian_blur(): def test_pybsm(): transforms = generate_transforms() - pybsm = transforms["nrtk_pybsm_2"]() + pybsm = transforms["nrtk_pybsm"]() pybsm.set_parameters({"D": 0.25, "f": 4.0}) pybsm.execute(get_image())