An error occurred while loading the file. Please try again.
-
Thibault Hallouin authored
in particular, BSS was returning 0 when BS reference was null, but 0 is a meaningful value for such score, so it is preferable to return -INF to indicate that the denominator was null and hence the division undefined the same philosophy is also used where relevant (i.e. in AWN, AWI, WSS)
8745886b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import pytest
import unittest
import otbtf
import otbApplication
import tensorflow as tf
from test_utils import resolve_paths
class NodataInferenceTest(unittest.TestCase):
def test_infersimple(self):
sm_dir = resolve_paths("$TMPDIR/l2_norm_savedmodel")
# Create model
x = tf.keras.Input(shape=[None, None, None], name="x")
y = tf.norm(x, axis=-1)
model = tf.keras.Model(inputs={"x": x}, outputs={"y": y})
model.save(sm_dir)
# OTB pipeline
bmx = otbApplication.Registry.CreateApplication("BandMathX")
bmx.SetParameterString("exp", "{idxX>idxY?idxX*idxY:0}")
bmx.SetParameterStringList(
"il", [resolve_paths("$DATADIR/fake_spot6.jp2")]
)
bmx.Execute()
infer = otbApplication.Registry.CreateApplication(
"TensorflowModelServe"
)
infer.SetParameterString("model.dir", sm_dir)
infer.SetParameterString("model.fullyconv", "on")
infer.AddImageToParameterInputImageList(
"source1.il", bmx.GetParameterOutputImage("out")
)
infer.SetParameterFloat("source1.nodata", 0.0)
for param in [
"source1.rfieldx", "source1.rfieldy", "output.efieldx", "output.efieldy"
]:
infer.SetParameterInt(param, 16)
infer.SetParameterString("out", resolve_paths("$TMPDIR/nd_out.tif"))
infer.ExecuteAndWriteOutput()
if __name__ == '__main__':
NodataInferenceTest().test_infersimple()
#unittest.main()