From 4f5875ef4e5f703bc39eadb1f9164b8614eee1d1 Mon Sep 17 00:00:00 2001 From: "marc.wieland@dlr.de" Date: Wed, 30 Nov 2022 10:41:14 +0100 Subject: [PATCH 1/2] update onnxruntime --- CHANGELOG.rst | 6 ++++++ ukis_csmask/__init__.py | 2 +- ukis_csmask/mask.py | 4 +++- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 03f3027..e45719b 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -1,6 +1,12 @@ Changelog ========= +[0.1.6] (2022-11-30) +-------------------- +Changed +******* +- update onnxruntime version and add providers to session + [0.1.5] (2022-11-11) -------------------- Changed diff --git a/ukis_csmask/__init__.py b/ukis_csmask/__init__.py index da80c81..0815acf 100644 --- a/ukis_csmask/__init__.py +++ b/ukis_csmask/__init__.py @@ -1 +1 @@ -__version__ = "0.1.5" +__version__ = "0.1.6" diff --git a/ukis_csmask/mask.py b/ukis_csmask/mask.py index dd766ba..9572776 100644 --- a/ukis_csmask/mask.py +++ b/ukis_csmask/mask.py @@ -82,7 +82,9 @@ def _csm(self): x /= [0.16431, 0.16762, 0.18230, 0.17409, 0.16020, 0.14164] # start onnx inference session and load model - sess = onnxruntime.InferenceSession(str(Path(__file__).parent) + "/model.onnx") + sess = onnxruntime.InferenceSession( + str(Path(__file__).parent) + "/model.onnx", providers=onnxruntime.get_available_providers() + ) # predict on array tiles y_prob = [sess.run(None, {"input_1": tile[np.newaxis, :]}) for n, tile in enumerate(list(x))] From 9a7227680ddbf02b509a2c8e4ebdebe64e55260d Mon Sep 17 00:00:00 2001 From: "marc.wieland@dlr.de" Date: Wed, 30 Nov 2022 10:58:07 +0100 Subject: [PATCH 2/2] support latest versions of onnxruntime --- README.md | 2 +- requirements.txt | 2 +- tests/test_mask.py | 4 ++-- ukis_csmask/mask.py | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index c71966c..5a5250b 100644 --- a/README.md +++ b/README.md @@ -71,7 +71,7 @@ The easiest way to install ukis-csmask is through pip. The default installation pip install ukis-csmask ``` -To install ukis-csmask with GPU support run the following instead. This requires that you have a GPU with CUDA runtime libraries (CUDA 10.2 and cuDNN 8.0.3) installed on the system. +To install ukis-csmask with GPU support run the following instead. This requires that you have a GPU with CUDA runtime libraries installed on the system. ```shell pip install ukis-csmask[gpu] diff --git a/requirements.txt b/requirements.txt index 92dd0ac..372aba6 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,3 @@ numpy -onnxruntime +onnxruntime>=1.13 scipy diff --git a/tests/test_mask.py b/tests/test_mask.py index fe65aba..f5c1853 100644 --- a/tests/test_mask.py +++ b/tests/test_mask.py @@ -70,8 +70,8 @@ def test_csmask_valid(data): csmask = CSmask(img=data["img"], band_order=["Blue", "Green", "Red", "NIR", "SWIR1", "SWIR2"]) y_pred = csmask.valid y_true = reclassify(data["msk"], {"reclass_value_from": [0, 1, 2, 3, 4], "reclass_value_to": [0, 1, 1, 1, 0]}) - y_true_inverted = ~y_true.astype(np.bool) - y_true = (~ndimage.binary_dilation(y_true_inverted, iterations=4).astype(np.bool)).astype(np.uint8) + y_true_inverted = ~y_true.astype(bool) + y_true = (~ndimage.binary_dilation(y_true_inverted, iterations=4).astype(bool)).astype(np.uint8) y_true = y_true.ravel() y_pred = y_pred.ravel() kappa = round(cohen_kappa_score(y_true, y_pred), 2) diff --git a/ukis_csmask/mask.py b/ukis_csmask/mask.py index 9572776..53d2e81 100644 --- a/ukis_csmask/mask.py +++ b/ukis_csmask/mask.py @@ -118,8 +118,8 @@ def _valid(self, invalid_buffer): # dilate the inverse of the binary valid pixel mask (invalid=0) # this effectively buffers the invalid pixels - valid_i = ~valid.astype(np.bool) - valid = (~ndimage.binary_dilation(valid_i, iterations=invalid_buffer).astype(np.bool)).astype(np.uint8) + valid_i = ~valid.astype(bool) + valid = (~ndimage.binary_dilation(valid_i, iterations=invalid_buffer).astype(bool)).astype(np.uint8) if self.nodata_value is not None: # add image nodata pixels to valid pixel mask