Commit 034be860 authored by Remi Cresson's avatar Remi Cresson
Browse files

TEST: add inference no-data test (wip)

2 merge requests!88Release v4.1.0,!83Tfmodelserve nodata
Pipeline #46059 passed with stages
in 23 minutes and 6 seconds
Showing with 41 additions and 0 deletions
+41 -0
#!/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?1:0}")
bmx.SetParameterStringList(
"il", [resolve_paths("$DATADIR/fake_spot6.jp2")]
)
bmx.Execute()
infer = otbApplication.Registry.CreateApplication(
"TensorflowModelServe"
)
infer.SetParameterString("model.dir", sm_dir)
infer.AddImageToParameterInputImageList(
"source1.il", bmx.GetParameterOutputImage("out")
)
infer.SetParameterString("out", resolve_paths("$TMPDIR/nd_out.tif"))
infer.ExecuteAndWriteOutput()
if __name__ == '__main__':
unittest.main()
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment