diff --git a/include/otbTensorflowSampler.h b/include/otbTensorflowSampler.h index 35f2b8b91d3385f08cce0ec650bde373bf2e7be6..0fe60193f464fafe9e09d481ae72048f132fcc8f 100644 --- a/include/otbTensorflowSampler.h +++ b/include/otbTensorflowSampler.h @@ -21,6 +21,9 @@ // TF common #include "otbTensorflowCommon.h" +// Tree iterator +#include "itkPreOrderTreeIterator.h" + namespace otb { diff --git a/include/otbTensorflowStreamerFilter.h b/include/otbTensorflowStreamerFilter.h index b58e92923b5b5b4ad78d5cc3d48c487c97594bfe..bb7c982edf5bc66c2d91eb48d93a6b2ea22b6d92 100644 --- a/include/otbTensorflowStreamerFilter.h +++ b/include/otbTensorflowStreamerFilter.h @@ -11,8 +11,8 @@ #ifndef otbTensorflowStreamerFilter_h #define otbTensorflowStreamerFilter_h -// Image2image #include "itkImageToImageFilter.h" +#include "itkProgressReporter.h" namespace otb { diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..aee4395220da9820a2f3e15acc6011b26b6528ee --- /dev/null +++ b/test/CMakeLists.txt @@ -0,0 +1,88 @@ +otb_module_test() + +# Directories +set(DATADIR ${CMAKE_CURRENT_SOURCE_DIR}/data) +set(MODELSDIR ${CMAKE_CURRENT_SOURCE_DIR}/models) + +# Input images +set(IMAGEXS ${DATADIR}/xs_subset.tif) +set(IMAGEPAN ${DATADIR}/pan_subset.tif) +set(IMAGEPXS ${DATADIR}/pxs_subset.tif) + +# Input models +set(MODEL1 ${MODELSDIR}/model1) +set(MODEL2 ${MODELSDIR}/model2) +set(MODEL3 ${MODELSDIR}/model3) + +# Output images and baselines +set(MODEL1_PB_OUT apTvClTensorflowModelServeCNN16x16PB.tif) +set(MODEL2_PB_OUT apTvClTensorflowModelServeCNN8x8_32x32PB.tif) +set(MODEL2_FC_OUT apTvClTensorflowModelServeCNN8x8_32x32FC.tif) +set(MODEL3_PB_OUT apTvClTensorflowModelServeFCNN16x16PB.tif) +set(MODEL3_FC_OUT apTvClTensorflowModelServeFCNN16x16FC.tif) + +#----------- Model serving : 1-branch CNN (16x16) Patch-Based ---------------- +otb_test_application(NAME TensorflowModelServeCNN16x16PB + APP TensorflowModelServe + OPTIONS -source1.il ${IMAGEPXS} + -source1.rfieldx 16 -source1.rfieldy 16 -source1.placeholder x + -model.dir ${MODEL1} -output.names prediction + -out ${TEMP}/${MODEL1_PB_OUT} + VALID --compare-image ${EPSILON_6} + ${DATADIR}/${MODEL1_PB_OUT} + ${TEMP}/${MODEL1_PB_OUT}) + +#----------- Model serving : 2-branch CNN (8x8, 32x32) Patch-Based ---------------- +otb_test_application(NAME apTvClTensorflowModelServeCNN8x8_32x32PB + APP TensorflowModelServe + OPTIONS -source1.il ${IMAGEXS} + -source1.rfieldx 8 -source1.rfieldy 8 -source1.placeholder x1 + -source2.il ${IMAGEPAN} + -source2.rfieldx 32 -source2.rfieldy 32 -source2.placeholder x2 + -model.dir ${MODEL2} -output.names prediction + -out ${TEMP}/${MODEL2_PB_OUT} + VALID --compare-image ${EPSILON_6} + ${DATADIR}/${MODEL2_PB_OUT} + ${TEMP}/${MODEL2_PB_OUT}) +set_tests_properties(apTvClTensorflowModelServeCNN8x8_32x32PB PROPERTIES ENVIRONMENT "OTB_TF_NSOURCES=2;$ENV{OTB_TF_NSOURCES}") + +#----------- Model serving : 2-branch CNN (8x8, 32x32) Fully-Conv ---------------- +set(ENV{OTB_TF_NSOURCES} 2) +otb_test_application(NAME apTvClTensorflowModelServeCNN8x8_32x32FC + APP TensorflowModelServe + OPTIONS -source1.il ${IMAGEXS} + -source1.rfieldx 8 -source1.rfieldy 8 -source1.placeholder x1 + -source2.il ${IMAGEPAN} + -source2.rfieldx 32 -source2.rfieldy 32 -source2.placeholder x2 + -model.dir ${MODEL2} -output.names prediction -output.spcscale 4 + -out ${TEMP}/${MODEL2_FC_OUT} + VALID --compare-image ${EPSILON_6} + ${DATADIR}/${MODEL2_FC_OUT} + ${TEMP}/${MODEL2_FC_OUT}) +set_tests_properties(apTvClTensorflowModelServeCNN8x8_32x32FC PROPERTIES ENVIRONMENT "OTB_TF_NSOURCES=2;$ENV{OTB_TF_NSOURCES}") + +#----------- Model serving : 1-branch FCNN (16x16) Patch-Based ---------------- +set(ENV{OTB_TF_NSOURCES} 1) +otb_test_application(NAME apTvClTensorflowModelServeFCNN16x16PB + APP TensorflowModelServe + OPTIONS -source1.il ${IMAGEPXS} + -source1.rfieldx 16 -source1.rfieldy 16 -source1.placeholder x + -model.dir ${MODEL3} -output.names prediction + -out ${TEMP}/${MODEL3_PB_OUT} + VALID --compare-image ${EPSILON_6} + ${DATADIR}/${MODEL3_PB_OUT} + ${TEMP}/${MODEL3_PB_OUT}) + +#----------- Model serving : 1-branch FCNN (16x16) Fully-conv ---------------- +set(ENV{OTB_TF_NSOURCES} 1) +otb_test_application(NAME apTvClTensorflowModelServeFCNN16x16FC + APP TensorflowModelServe + OPTIONS -source1.il ${IMAGEPXS} + -source1.rfieldx 16 -source1.rfieldy 16 -source1.placeholder x + -model.dir ${MODEL3} -output.names prediction -model.fullyconv on + -out ${TEMP}/${MODEL3_FC_OUT} + VALID --compare-image ${EPSILON_6} + ${DATADIR}/${MODEL3_FC_OUT} + ${TEMP}/${MODEL3_FC_OUT}) + + diff --git a/test/data/apTvClTensorflowModelServeCNN16x16PB.tif b/test/data/apTvClTensorflowModelServeCNN16x16PB.tif new file mode 100644 index 0000000000000000000000000000000000000000..8d936fcbdf8406a5e3321e46c71ac108a7a7cc61 Binary files /dev/null and b/test/data/apTvClTensorflowModelServeCNN16x16PB.tif differ diff --git a/test/data/apTvClTensorflowModelServeCNN8x8_32x32FC.tif b/test/data/apTvClTensorflowModelServeCNN8x8_32x32FC.tif new file mode 100644 index 0000000000000000000000000000000000000000..0662360f8e63ba3ee6d547fb62df25f3300dbb3b Binary files /dev/null and b/test/data/apTvClTensorflowModelServeCNN8x8_32x32FC.tif differ diff --git a/test/data/apTvClTensorflowModelServeCNN8x8_32x32PB.tif b/test/data/apTvClTensorflowModelServeCNN8x8_32x32PB.tif new file mode 100644 index 0000000000000000000000000000000000000000..35cb2f460a1c0f879af2ba9f170eabb6da542e4b Binary files /dev/null and b/test/data/apTvClTensorflowModelServeCNN8x8_32x32PB.tif differ diff --git a/test/data/apTvClTensorflowModelServeFCNN16x16FC.tif b/test/data/apTvClTensorflowModelServeFCNN16x16FC.tif new file mode 100644 index 0000000000000000000000000000000000000000..14a5d11aa17a21ecf650b04e748e4b1b1bc74cd4 Binary files /dev/null and b/test/data/apTvClTensorflowModelServeFCNN16x16FC.tif differ diff --git a/test/data/apTvClTensorflowModelServeFCNN16x16PB.tif b/test/data/apTvClTensorflowModelServeFCNN16x16PB.tif new file mode 100644 index 0000000000000000000000000000000000000000..14a5d11aa17a21ecf650b04e748e4b1b1bc74cd4 Binary files /dev/null and b/test/data/apTvClTensorflowModelServeFCNN16x16PB.tif differ diff --git a/test/data/pan_subset.tif b/test/data/pan_subset.tif new file mode 100644 index 0000000000000000000000000000000000000000..ba380b4d410adc4397a2b58a43839b7369c600f9 Binary files /dev/null and b/test/data/pan_subset.tif differ diff --git a/test/data/pxs_subset.tif b/test/data/pxs_subset.tif new file mode 100644 index 0000000000000000000000000000000000000000..89ee7990d13a3b6dc7a0180b907055b2cb268ee6 Binary files /dev/null and b/test/data/pxs_subset.tif differ diff --git a/test/data/xs_subset.tif b/test/data/xs_subset.tif new file mode 100644 index 0000000000000000000000000000000000000000..36305231f01bd613e8097a5f85a7a4135672d45a Binary files /dev/null and b/test/data/xs_subset.tif differ diff --git a/test/models/model1/SavedModel_cnn/saved_model.pb b/test/models/model1/SavedModel_cnn/saved_model.pb new file mode 100644 index 0000000000000000000000000000000000000000..7674fb362182be7320d9e754dbaad36b8fe7839f Binary files /dev/null and b/test/models/model1/SavedModel_cnn/saved_model.pb differ diff --git a/test/models/model1/SavedModel_cnn/variables/variables.data-00000-of-00001 b/test/models/model1/SavedModel_cnn/variables/variables.data-00000-of-00001 new file mode 100644 index 0000000000000000000000000000000000000000..437b992435c708ddae6b776a36c7fe89bb38bf8a Binary files /dev/null and b/test/models/model1/SavedModel_cnn/variables/variables.data-00000-of-00001 differ diff --git a/test/models/model1/SavedModel_cnn/variables/variables.index b/test/models/model1/SavedModel_cnn/variables/variables.index new file mode 100644 index 0000000000000000000000000000000000000000..759c02f3cfc05ac212fb978e7a1864735763d24c Binary files /dev/null and b/test/models/model1/SavedModel_cnn/variables/variables.index differ diff --git a/test/models/model1/saved_model.pb b/test/models/model1/saved_model.pb new file mode 100644 index 0000000000000000000000000000000000000000..7674fb362182be7320d9e754dbaad36b8fe7839f Binary files /dev/null and b/test/models/model1/saved_model.pb differ diff --git a/test/models/model1/variables/variables.data-00000-of-00001 b/test/models/model1/variables/variables.data-00000-of-00001 new file mode 100644 index 0000000000000000000000000000000000000000..2aba6b57990bc65e95e0df46c9d80bb2f9b59d1c Binary files /dev/null and b/test/models/model1/variables/variables.data-00000-of-00001 differ diff --git a/test/models/model1/variables/variables.index b/test/models/model1/variables/variables.index new file mode 100644 index 0000000000000000000000000000000000000000..e2d1f8000606b30a0623e8c75b9d7c07df745660 Binary files /dev/null and b/test/models/model1/variables/variables.index differ diff --git a/test/models/model2/saved_model.pb b/test/models/model2/saved_model.pb new file mode 100644 index 0000000000000000000000000000000000000000..7269539b35274cae39f77778f75fab344527800c Binary files /dev/null and b/test/models/model2/saved_model.pb differ diff --git a/test/models/model2/variables/variables.data-00000-of-00001 b/test/models/model2/variables/variables.data-00000-of-00001 new file mode 100644 index 0000000000000000000000000000000000000000..60cb472a8c493715335c853eafbbe4467b53fe0c Binary files /dev/null and b/test/models/model2/variables/variables.data-00000-of-00001 differ diff --git a/test/models/model2/variables/variables.index b/test/models/model2/variables/variables.index new file mode 100644 index 0000000000000000000000000000000000000000..0e26de9679f0f33869b91dd724867f00a5b469f0 Binary files /dev/null and b/test/models/model2/variables/variables.index differ diff --git a/test/models/model3/saved_model.pb b/test/models/model3/saved_model.pb new file mode 100644 index 0000000000000000000000000000000000000000..099d0ce64a10d36cdf29ad14e6a3f4a570e794b5 Binary files /dev/null and b/test/models/model3/saved_model.pb differ diff --git a/test/models/model3/variables/variables.data-00000-of-00001 b/test/models/model3/variables/variables.data-00000-of-00001 new file mode 100644 index 0000000000000000000000000000000000000000..6d507b96f7b3affe8a7b4c3bd224d6a1f58df7c8 Binary files /dev/null and b/test/models/model3/variables/variables.data-00000-of-00001 differ diff --git a/test/models/model3/variables/variables.index b/test/models/model3/variables/variables.index new file mode 100644 index 0000000000000000000000000000000000000000..cea18cefd678b98110df9c820a72373c28117f7f Binary files /dev/null and b/test/models/model3/variables/variables.index differ