Skip to content

Commit

Permalink
Merge pull request #9 from dlr-eoc/update_onnxruntime
Browse files Browse the repository at this point in the history
Update onnxruntime
  • Loading branch information
MWieland authored Nov 30, 2022
2 parents 05366bd + 9a72276 commit 64d9d05
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 8 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
numpy
onnxruntime
onnxruntime>=1.13
scipy
4 changes: 2 additions & 2 deletions tests/test_mask.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion ukis_csmask/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.1.5"
__version__ = "0.1.6"
8 changes: 5 additions & 3 deletions ukis_csmask/mask.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))]
Expand Down Expand Up @@ -116,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
Expand Down

0 comments on commit 64d9d05

Please sign in to comment.