Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pretrained weights error sr.py #21

Closed
raialvaro opened this issue Apr 5, 2021 · 9 comments
Closed

pretrained weights error sr.py #21

raialvaro opened this issue Apr 5, 2021 · 9 comments
Labels
help wanted Extra attention is needed

Comments

@raialvaro
Copy link

Hi @remicres!

I am testing my sentinel image (the same one with which I previously trained with your code) pre-trained weights that you have recently uploaded and I get the following error:

**python sr.py --input matched_SGtoPNOA_8bits.tif --savedmodel /SR/sr4rs_mini-mtp-2.5_savedmodel --output prueba.tif --pad 64
2021-04-05 07:10:58 (INFO) ReadImageInfo:
Image general information:
Number of bands : 3
Data type : unsigned_char
No data flags :
Band 1: 0
Band 2: 0
Band 3: 0
Start index : [0,0]
Size : [1284,1223]
Origin : [38417.6,4.70833e+06]
Spacing : [10,-10]
Estimated ground spacing (in meters): [9.95252,9.98852]

Image acquisition information:
Sensor :
Image identification number:
Image projection : PROJCS["ETRS89 / UTM zone 30N",
GEOGCS["ETRS89",
DATUM["European_Terrestrial_Reference_System_1989",
SPHEROID["GRS 1980",6378137,298.257222101,
AUTHORITY["EPSG","7019"]],
TOWGS84[0,0,0,0,0,0,0],
AUTHORITY["EPSG","6258"]],
PRIMEM["Greenwich",0,
AUTHORITY["EPSG","8901"]],
UNIT["degree",0.0174532925199433,
AUTHORITY["EPSG","9122"]],
AUTHORITY["EPSG","4258"]],
PROJECTION["Transverse_Mercator"],
PARAMETER["latitude_of_origin",0],
PARAMETER["central_meridian",-3],
PARAMETER["scale_factor",0.9996],
PARAMETER["false_easting",500000],
PARAMETER["false_northing",0],
UNIT["metre",1,
AUTHORITY["EPSG","9001"]],
AXIS["Easting",EAST],
AXIS["Northing",NORTH],
AUTHORITY["EPSG","25830"]]

Image default RGB composition:
[R, G, B] = [0,1,2]

Ground control points information:
Number of GCPs = 0
GCPs projection =

2021-04-05 07:10:58.706125: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library libcudart.so.10.1
2021-04-05 07:10:58 (INFO) TensorflowModelServe: Default RAM limit for OTB is 256 MB
2021-04-05 07:10:58 (INFO) TensorflowModelServe: GDAL maximum cache size is 15115 MB
2021-04-05 07:10:58 (INFO) TensorflowModelServe: OTB will use at most 32 threads
2021-04-05 07:10:58.748436: I tensorflow/cc/saved_model/reader.cc:31] Reading SavedModel from: /SR/sr4rs_mini-mtp-2.5_savedmodel
2021-04-05 07:10:59.268936: I tensorflow/cc/saved_model/reader.cc:54] Reading meta graph with tags { serve }
2021-04-05 07:10:59.269015: I tensorflow/cc/saved_model/loader.cc:264] Reading SavedModel debug info (if present) from: /SR/sr4rs_mini-mtp-2.5_savedmodel
2021-04-05 07:10:59.269182: I tensorflow/core/platform/cpu_feature_guard.cc:142] Your CPU supports instructions that this TensorFlow binary was not compiled to use: SSE3 SSE4.1 SSE4.2 AVX AVX2 AVX512F FMA
2021-04-05 07:10:59.288526: I tensorflow/core/platform/profile_utils/cpu_utils.cc:94] CPU Frequency: 2200000000 Hz
2021-04-05 07:10:59.290216: I tensorflow/compiler/xla/service/service.cc:168] XLA service 0x204edc0 initialized for platform Host (this does not guarantee that XLA will be used). Devices:
2021-04-05 07:10:59.290255: I tensorflow/compiler/xla/service/service.cc:176] StreamExecutor device (0): Host, Default Version
2021-04-05 07:10:59.292973: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library libcuda.so.1
2021-04-05 07:10:59.482133: I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:981] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero
2021-04-05 07:10:59.485225: I tensorflow/compiler/xla/service/service.cc:168] XLA service 0x1fb37a0 initialized for platform CUDA (this does not guarantee that XLA will be used). Devices:
2021-04-05 07:10:59.485300: I tensorflow/compiler/xla/service/service.cc:176] StreamExecutor device (0): Quadro RTX 8000, Compute Capability 7.5
2021-04-05 07:10:59.485993: I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:981] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero
2021-04-05 07:10:59.492424: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1555] Found device 0 with properties:
pciBusID: 0000:14:00.0 name: Quadro RTX 8000 computeCapability: 7.5
coreClock: 1.62GHz coreCount: 72 deviceMemorySize: 44.49GiB deviceMemoryBandwidth: 581.23GiB/s
2021-04-05 07:10:59.492838: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library libcudart.so.10.1
2021-04-05 07:10:59.497695: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library libcublas.so.10
2021-04-05 07:10:59.500430: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library libcufft.so.10
2021-04-05 07:10:59.500982: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library libcurand.so.10
2021-04-05 07:10:59.503614: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library libcusolver.so.10
2021-04-05 07:10:59.505054: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library libcusparse.so.10
2021-04-05 07:10:59.510140: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library libcudnn.so.7
2021-04-05 07:10:59.510354: I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:981] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero
2021-04-05 07:10:59.513380: I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:981] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero
2021-04-05 07:10:59.516173: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1697] Adding visible gpu devices: 0
2021-04-05 07:10:59.516328: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library libcudart.so.10.1
2021-04-05 07:10:59.998655: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1096] Device interconnect StreamExecutor with strength 1 edge matrix:
2021-04-05 07:10:59.998732: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1102] 0
2021-04-05 07:10:59.998741: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1115] 0: N
2021-04-05 07:10:59.999937: I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:981] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero
2021-04-05 07:11:00.002218: I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:981] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero
2021-04-05 07:11:00.004378: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1241] Created TensorFlow device (/job:localhost/replica:0/task:0/device:GPU:0 with 42866 MB memory) -> physical GPU (device: 0, name: Quadro RTX 8000, pci bus id: 0000:14:00.0, compute capability: 7.5)
2021-04-05 07:11:01.324388: I tensorflow/cc/saved_model/loader.cc:203] Restoring SavedModel bundle.
2021-04-05 07:11:03.661090: I tensorflow/core/profiler/lib/profiler_session.cc:225] Profiler session started.
2021-04-05 07:11:03.661183: I tensorflow/core/profiler/internal/gpu/cupti_tracer.cc:1259] Profiler found 1 GPUs
2021-04-05 07:11:03.661775: W tensorflow/stream_executor/platform/default/dso_loader.cc:55] Could not load dynamic library 'libcupti.so.10.1'; dlerror: libcupti.so.10.1: cannot open shared object file: No such file or directory; LD_LIBRARY_PATH: /usr/local/nvidia/lib:/usr/local/nvidia/lib64:/work/otb/superbuild_install/lib/:/work/tf/installdir/lib/
2021-04-05 07:11:03.661803: E tensorflow/core/profiler/internal/gpu/cupti_tracer.cc:1307] function cupti_interface_->Subscribe( &subscriber_, (CUpti_CallbackFunc)ApiCallback, this)failed with error CUPTI could not be loaded or symbol could not be found.
2021-04-05 07:11:03.661841: E tensorflow/core/profiler/internal/gpu/cupti_tracer.cc:1346] function cupti_interface_->ActivityRegisterCallbacks( AllocCuptiActivityBuffer, FreeCuptiActivityBuffer)failed with error CUPTI could not be loaded or symbol could not be found.
2021-04-05 07:11:04.507595: E tensorflow/core/profiler/internal/gpu/cupti_tracer.cc:1329] function cupti_interface_->EnableCallback( 0 , subscriber_, CUPTI_CB_DOMAIN_DRIVER_API, cbid)failed with error CUPTI could not be loaded or symbol could not be found.
2021-04-05 07:11:04.507696: I tensorflow/core/profiler/internal/gpu/device_tracer.cc:88] GpuTracer has collected 0 callback api events and 0 activity events.
2021-04-05 07:11:04.527949: I tensorflow/cc/saved_model/loader.cc:333] SavedModel load for tags { serve }; Status: success: OK. Took 5779516 microseconds.
2021-04-05 07:11:04 (INFO) TensorflowModelServe: Source info :
2021-04-05 07:11:04 (INFO) TensorflowModelServe: Receptive field : [160, 160]
2021-04-05 07:11:04 (INFO) TensorflowModelServe: Placeholder name : lr_input
2021-04-05 07:11:05 (INFO) TensorflowModelServe: Output spacing ratio: 0.25
2021-04-05 07:11:05 (INFO) TensorflowModelServe: The TensorFlow model is used in fully convolutional mode
2021-04-05 07:11:05 (INFO) TensorflowModelServe: Output field of expression: [512, 512]
2021-04-05 07:11:05 (INFO) TensorflowModelServe: Tiling disabled
2021-04-05 07:11:05 (WARNING): Streaming configuration through extended filename is used. Any previous streaming configuration (ram value, streaming mode ...) will be ignored.
2021-04-05 07:11:05 (WARNING): Streaming configuration through extended filename is used. Any previous streaming configuration (ram value, streaming mode ...) will be ignored.
2021-04-05 07:11:05 (INFO): File prueba.tif will be written in 64 blocks of 512x512 pixels
Writing 1 output images ...: 0% [ ]2021-04-05 07:11:06.730618: W tensorflow/core/framework/op_kernel.cc:1655] OP_REQUIRES failed at conv_ops.cc:530 : Invalid argument: input depth must be evenly divisible by filter depth: 3 vs 4
Traceback (most recent call last):
File "sr.py", line 78, in
infer.ExecuteAndWriteOutput()
File "/work/otb/superbuild_install/lib/otb/python/otbApplication.py", line 2801, in ExecuteAndWriteOutput
return _otbApplication.Application_ExecuteAndWriteOutput(self)
RuntimeError: Exception thrown in otbApplication Application_ExecuteAndWriteOutput: /work/otb/otb/Modules/Remote/otbtf/include/otbTensorflowMultisourceModelBase.hxx:97:
itk::ERROR: TensorflowMultisourceModelFilter(0xb7cf620): Can't run the tensorflow session !
Tensorflow error message:
Invalid argument: 2 root error(s) found.
(0) Invalid argument: input depth must be evenly divisible by filter depth: 3 vs 4
[[{{node gen/encoder/conv1_9x9/Conv2D}}]]
[[output_64/_1075]]
(1) Invalid argument: input depth must be evenly divisible by filter depth: 3 vs 4
[[{{node gen/encoder/conv1_9x9/Conv2D}}]]
0 successful operations.
0 derived errors ignored.
OTB Filter debug message:
Output image buffered region: ImageRegion (0x7fff4f96e690)
Dimension: 2
Index: [0, 0]
Size: [512, 512]

Input #0:
Requested region: ImageRegion (0x7fff4f96e6c0)
Dimension: 2
Index: [64, 64]
Size: [160, 160]

Tensor shape ("lr_input": {1, 160, 160, 3}
User placeholders:

root@2f1d9d7e2789:/SR# python sr.py --input matched_SGtoPNOA_8bits.tif --savedmodel /SR/sr4rs_mini-mtp-2.5_savedmodel --output SGx4.tif --pad 64
2021-04-05 07:11:27 (INFO) ReadImageInfo:
Image general information:
Number of bands : 3
Data type : unsigned_char
No data flags :
Band 1: 0
Band 2: 0
Band 3: 0
Start index : [0,0]
Size : [1284,1223]
Origin : [38417.6,4.70833e+06]
Spacing : [10,-10]
Estimated ground spacing (in meters): [9.95252,9.98852]

Image acquisition information:
Sensor :
Image identification number:
Image projection : PROJCS["ETRS89 / UTM zone 30N",
GEOGCS["ETRS89",
DATUM["European_Terrestrial_Reference_System_1989",
SPHEROID["GRS 1980",6378137,298.257222101,
AUTHORITY["EPSG","7019"]],
TOWGS84[0,0,0,0,0,0,0],
AUTHORITY["EPSG","6258"]],
PRIMEM["Greenwich",0,
AUTHORITY["EPSG","8901"]],
UNIT["degree",0.0174532925199433,
AUTHORITY["EPSG","9122"]],
AUTHORITY["EPSG","4258"]],
PROJECTION["Transverse_Mercator"],
PARAMETER["latitude_of_origin",0],
PARAMETER["central_meridian",-3],
PARAMETER["scale_factor",0.9996],
PARAMETER["false_easting",500000],
PARAMETER["false_northing",0],
UNIT["metre",1,
AUTHORITY["EPSG","9001"]],
AXIS["Easting",EAST],
AXIS["Northing",NORTH],
AUTHORITY["EPSG","25830"]]

Image default RGB composition:
[R, G, B] = [0,1,2]

Ground control points information:
Number of GCPs = 0
GCPs projection =

2021-04-05 07:11:27.754635: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library libcudart.so.10.1
2021-04-05 07:11:27 (INFO) TensorflowModelServe: Default RAM limit for OTB is 256 MB
2021-04-05 07:11:27 (INFO) TensorflowModelServe: GDAL maximum cache size is 15115 MB
2021-04-05 07:11:27 (INFO) TensorflowModelServe: OTB will use at most 32 threads
2021-04-05 07:11:27.796086: I tensorflow/cc/saved_model/reader.cc:31] Reading SavedModel from: /SR/sr4rs_mini-mtp-2.5_savedmodel
2021-04-05 07:11:28.319189: I tensorflow/cc/saved_model/reader.cc:54] Reading meta graph with tags { serve }
2021-04-05 07:11:28.319256: I tensorflow/cc/saved_model/loader.cc:264] Reading SavedModel debug info (if present) from: /SR/sr4rs_mini-mtp-2.5_savedmodel
2021-04-05 07:11:28.319368: I tensorflow/core/platform/cpu_feature_guard.cc:142] Your CPU supports instructions that this TensorFlow binary was not compiled to use: SSE3 SSE4.1 SSE4.2 AVX AVX2 AVX512F FMA
2021-04-05 07:11:28.338710: I tensorflow/core/platform/profile_utils/cpu_utils.cc:94] CPU Frequency: 2200000000 Hz
2021-04-05 07:11:28.340415: I tensorflow/compiler/xla/service/service.cc:168] XLA service 0x277bce0 initialized for platform Host (this does not guarantee that XLA will be used). Devices:
2021-04-05 07:11:28.340449: I tensorflow/compiler/xla/service/service.cc:176] StreamExecutor device (0): Host, Default Version
2021-04-05 07:11:28.342910: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library libcuda.so.1
2021-04-05 07:11:28.541756: I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:981] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero
2021-04-05 07:11:28.580486: I tensorflow/compiler/xla/service/service.cc:168] XLA service 0x26e08b0 initialized for platform CUDA (this does not guarantee that XLA will be used). Devices:
2021-04-05 07:11:28.580578: I tensorflow/compiler/xla/service/service.cc:176] StreamExecutor device (0): Quadro RTX 8000, Compute Capability 7.5
2021-04-05 07:11:28.580943: I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:981] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero
2021-04-05 07:11:28.584156: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1555] Found device 0 with properties:
pciBusID: 0000:14:00.0 name: Quadro RTX 8000 computeCapability: 7.5
coreClock: 1.62GHz coreCount: 72 deviceMemorySize: 44.49GiB deviceMemoryBandwidth: 581.23GiB/s
2021-04-05 07:11:28.584355: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library libcudart.so.10.1
2021-04-05 07:11:28.587459: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library libcublas.so.10
2021-04-05 07:11:28.589788: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library libcufft.so.10
2021-04-05 07:11:28.590268: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library libcurand.so.10
2021-04-05 07:11:28.592864: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library libcusolver.so.10
2021-04-05 07:11:28.594259: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library libcusparse.so.10
2021-04-05 07:11:28.599444: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library libcudnn.so.7
2021-04-05 07:11:28.599624: I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:981] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero
2021-04-05 07:11:28.602641: I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:981] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero
2021-04-05 07:11:28.605493: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1697] Adding visible gpu devices: 0
2021-04-05 07:11:28.605622: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library libcudart.so.10.1
2021-04-05 07:11:29.078497: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1096] Device interconnect StreamExecutor with strength 1 edge matrix:
2021-04-05 07:11:29.078561: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1102] 0
2021-04-05 07:11:29.078581: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1115] 0: N
2021-04-05 07:11:29.078960: I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:981] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero
2021-04-05 07:11:29.081111: I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:981] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero
2021-04-05 07:11:29.083328: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1241] Created TensorFlow device (/job:localhost/replica:0/task:0/device:GPU:0 with 42866 MB memory) -> physical GPU (device: 0, name: Quadro RTX 8000, pci bus id: 0000:14:00.0, compute capability: 7.5)
2021-04-05 07:11:30.376168: I tensorflow/cc/saved_model/loader.cc:203] Restoring SavedModel bundle.
2021-04-05 07:11:32.615952: I tensorflow/core/profiler/lib/profiler_session.cc:225] Profiler session started.
2021-04-05 07:11:32.616028: I tensorflow/core/profiler/internal/gpu/cupti_tracer.cc:1259] Profiler found 1 GPUs
2021-04-05 07:11:32.616584: W tensorflow/stream_executor/platform/default/dso_loader.cc:55] Could not load dynamic library 'libcupti.so.10.1'; dlerror: libcupti.so.10.1: cannot open shared object file: No such file or directory; LD_LIBRARY_PATH: /usr/local/nvidia/lib:/usr/local/nvidia/lib64:/work/otb/superbuild_install/lib/:/work/tf/installdir/lib/
2021-04-05 07:11:32.616612: E tensorflow/core/profiler/internal/gpu/cupti_tracer.cc:1307] function cupti_interface_->Subscribe( &subscriber_, (CUpti_CallbackFunc)ApiCallback, this)failed with error CUPTI could not be loaded or symbol could not be found.
2021-04-05 07:11:32.616626: E tensorflow/core/profiler/internal/gpu/cupti_tracer.cc:1346] function cupti_interface_->ActivityRegisterCallbacks( AllocCuptiActivityBuffer, FreeCuptiActivityBuffer)failed with error CUPTI could not be loaded or symbol could not be found.
2021-04-05 07:11:33.403085: E tensorflow/core/profiler/internal/gpu/cupti_tracer.cc:1329] function cupti_interface_->EnableCallback( 0 , subscriber_, CUPTI_CB_DOMAIN_DRIVER_API, cbid)failed with error CUPTI could not be loaded or symbol could not be found.
2021-04-05 07:11:33.403168: I tensorflow/core/profiler/internal/gpu/device_tracer.cc:88] GpuTracer has collected 0 callback api events and 0 activity events.
2021-04-05 07:11:33.420199: I tensorflow/cc/saved_model/loader.cc:333] SavedModel load for tags { serve }; Status: success: OK. Took 5624117 microseconds.
2021-04-05 07:11:33 (INFO) TensorflowModelServe: Source info :
2021-04-05 07:11:33 (INFO) TensorflowModelServe: Receptive field : [160, 160]
2021-04-05 07:11:33 (INFO) TensorflowModelServe: Placeholder name : lr_input
2021-04-05 07:11:33 (INFO) TensorflowModelServe: Output spacing ratio: 0.25
2021-04-05 07:11:33 (INFO) TensorflowModelServe: The TensorFlow model is used in fully convolutional mode
2021-04-05 07:11:33 (INFO) TensorflowModelServe: Output field of expression: [512, 512]
2021-04-05 07:11:33 (INFO) TensorflowModelServe: Tiling disabled
2021-04-05 07:11:34 (WARNING): Streaming configuration through extended filename is used. Any previous streaming configuration (ram value, streaming mode ...) will be ignored.
2021-04-05 07:11:34 (WARNING): Streaming configuration through extended filename is used. Any previous streaming configuration (ram value, streaming mode ...) will be ignored.
2021-04-05 07:11:34 (INFO): File SGx4.tif will be written in 64 blocks of 512x512 pixels
Writing 1 output images ...: 0% [ ]2021-04-05 07:11:35.582924: W tensorflow/core/framework/op_kernel.cc:1655] OP_REQUIRES failed at conv_ops.cc:530 : Invalid argument: input depth must be evenly divisible by filter depth: 3 vs 4
Traceback (most recent call last):
File "sr.py", line 78, in
infer.ExecuteAndWriteOutput()
File "/work/otb/superbuild_install/lib/otb/python/otbApplication.py", line 2801, in ExecuteAndWriteOutput
return _otbApplication.Application_ExecuteAndWriteOutput(self)
RuntimeError: Exception thrown in otbApplication Application_ExecuteAndWriteOutput: /work/otb/otb/Modules/Remote/otbtf/include/otbTensorflowMultisourceModelBase.hxx:97:
itk::ERROR: TensorflowMultisourceModelFilter(0x135a98e0): Can't run the tensorflow session !
Tensorflow error message:
Invalid argument: 2 root error(s) found.
(0) Invalid argument: input depth must be evenly divisible by filter depth: 3 vs 4
[[{{node gen/encoder/conv1_9x9/Conv2D}}]]
(1) Invalid argument: input depth must be evenly divisible by filter depth: 3 vs 4
[[{{node gen/encoder/conv1_9x9/Conv2D}}]]
[[output_64/_1075]]
0 successful operations.
0 derived errors ignored.
OTB Filter debug message:
Output image buffered region: ImageRegion (0x7ffc4d6f8a40)
Dimension: 2
Index: [0, 0]
Size: [512, 512]

Input #0:
Requested region: ImageRegion (0x7ffc4d6f8a70)
Dimension: 2
Index: [64, 64]
Size: [160, 160]

Tensor shape ("lr_input": {1, 160, 160, 3}
User placeholders:**

I have tried changing some parameter like the pad and it has not worked.

Any idea what is happening?

Thank so much!

@remicres
Copy link
Owner

remicres commented Apr 5, 2021

Hi @raialvaro ,

  • The input depth must be evenly divisible by filter depth: 3 vs 4 thing looks like you have trained a net on 3 bands, and you input some 4 channels image (or the other way).

  • Else, without your code I can't tell 😉 Could you paste some diff here?

@raialvaro
Copy link
Author

Here I attach your original sr.py code. I have only added the choice of the GPU device 1, Quadro RTX 8000, 48 GB


import argparse
import otbApplication
import constants
import logging

import os

os.environ['CUDA_VISIBLE_DEVICES'] = '1'

logging.basicConfig(format='%(asctime)s %(levelname)-8s %(message)s', level=logging.WARNING,
datefmt='%Y-%m-%d %H:%M:%S')

parser = argparse.ArgumentParser()

def get_encoding():
"""
Get the encoding of input image pixels
"""
infos = otbApplication.Registry.CreateApplication('ReadImageInfo')
infos.SetParameterString("in", params.input)
infos.Execute()
return infos.GetImageBasePixelType("in")

encodings = {"auto": get_encoding,
"uint8": lambda x: otbApplication.ImagePixelType_uint8,
"uint16": lambda x: otbApplication.ImagePixelType_uint16,
"int16": lambda x: otbApplication.ImagePixelType_int16,
"float": lambda x: otbApplication.ImagePixelType_float}

parser.add_argument("--input", help="Input LR image ", required=True)
parser.add_argument("--savedmodel", help="Input SavedModel ", required=True)
parser.add_argument("--output", help="Output HR image", required=True)
parser.add_argument('--encoding', type=str, default="auto", const="auto", nargs="?", choices=encodings.keys(),
help="Output HR image encoding")
parser.add_argument('--pad', type=int, default=64, const=64, nargs="?", choices=constants.pads,
help="Margin size for blocking artefacts removal")
parser.add_argument('--ts', default=512, type=int, help="Tile size")
params = parser.parse_args()

if name == "main":

gen_fcn = params.pad
efield = params.ts  # OTBTF expression field
if efield % min(constants.factors) != 0:
    logging.fatal("Please chose a tile size that is consistent with the network.")
    quit()
ratio = 1.0 / float(max(constants.factors))  # OTBTF Spacing ratio
rfield = int((efield + 2 * gen_fcn) * ratio)  # OTBTF receptive field

# pixel encoding
encoding_fn = encodings[params.encoding]
encoding = encoding_fn()

# call otbtf
logging.info("Receptive field: {}, Expression field: {}".format(rfield, efield))
ph = "{}{}".format(constants.outputs_prefix, params.pad)
infer = otbApplication.Registry.CreateApplication("TensorflowModelServe")
infer.SetParameterStringList("source1.il", [params.input])
infer.SetParameterInt("source1.rfieldx", rfield)
infer.SetParameterInt("source1.rfieldy", rfield)
infer.SetParameterString("source1.placeholder", constants.lr_input_name)
infer.SetParameterString("model.dir", params.savedmodel)
infer.SetParameterString("model.fullyconv", "on")
infer.SetParameterStringList("output.names", [ph])
infer.SetParameterInt("output.efieldx", efield)
infer.SetParameterInt("output.efieldy", efield)
infer.SetParameterFloat("output.spcscale", ratio)
infer.SetParameterInt("optim.tilesizex", efield)
infer.SetParameterInt("optim.tilesizey", efield)
infer.SetParameterInt("optim.disabletiling", 1)
out_fn = "{}{}&gdal:co:COMPRESS=DEFLATE".format(params.output, "?" if "?" not in params.output else "")
out_fn += "&streaming:type=tiled&streaming:sizemode=height&streaming:sizevalue={}".format(efield)
infer.SetParameterString("out", out_fn)
infer.SetParameterOutputImagePixelType("out", encoding)
infer.ExecuteAndWriteOutput()*

Below, it shows the image and its characteristics

image

image

image

any other information you need, I will be happy to help you.

Thanks so much!

@remicres
Copy link
Owner

remicres commented Apr 5, 2021

Hi @raialvaro ,
I need the diff with the original code to see the changes you made.

cd /path/to/sr4rs
git diff

@raialvaro
Copy link
Author

image
image

that's correct?

I'm sorry for my low experience 😞

@remicres
Copy link
Owner

remicres commented Apr 6, 2021

Thank you. I don't see anything in the code (by the way, you are right to set the CUDA_VISIBLE_DEVICES!).

Can you check that you input image has the same properties as your lr_patches? (i.e. same dynamic, number of channels, physical spacing, etc.)

@raialvaro
Copy link
Author

Maybe this interests @remicres .

I think your code is written in a version of Tensorflow below 2.X while your docker OTBTF version has version 2.1.1.

image

I adapted the code to this version and got it not to give sintasix error.

Can you check that you input image has the same properties as your lr_patches? (i.e. same dynamic, number of channels, physical spacing, etc.)

At the moment I am testing the image that I have indicated above for the weights of yours that you have recently shared sr4rs_mini-mtp-2.5_savedmodel and it is the error that has arisen in the first section #21 (comment)

That is why I ask how the input image should be so that I can obtain a super resolution image with the sr.py script

Thanks for your help and your time!

@remicres
Copy link
Owner

remicres commented Apr 6, 2021

Channels

The pre-trained model applies to a 4-channels image.
The input image must be Sentinel-2 (or Landsat) 10m spacing channels stacked in the following order:

  1. Red (Sentinel-2 channel 4)
  2. Green (Sentinel-2 channel 3)
  3. Blue (Sentinel-2 channel 2)
  4. Near infra-red (Sentinel-2 channel 8)

To perform such layer stack you can use the OTB application named ConcatenateImages.

Dynamic

Keep the original Sentinel-2 images dynamic, no transformation needed!
It should be something like [0, 10000] approximately (I believe images are encoded using int16)

Example

Here is some script you should be able to follow, from the docker image pull, to the HR image generation.

# 1. Get latest OTBTF docker image and enter the docker image.
# Use the nice and lightweight builds done by Vincent@LaTelescop.
# Here is an example with the otbtf gpu:2.3-dev image, using NVIDIA runtime 
docker run -ti --runtime=nvidia registry.gitlab.com/latelescop/docker/otbtf/gpu:2.3-dev bash

# Download and unzip the pre-trained SavedModel1
wget https://nextcloud.inrae.fr/s/JLsak68H2KYzPyG/download
unzip download

# Clone SR4RS
git clone https://github.com/remicres/sr4rs.git

# Use SR4RS to create an HR image
cd sr4rs/code
python sr4rs/code/sr.py \
--savedmodel sr4rs_mini-mtp-2.5_savedmodel \
--input /path/to/some/S2_image/stacked_channels_4328_10m.tif \
--output test.tif

@remicres remicres added the help wanted Extra attention is needed label Apr 6, 2021
@remicres remicres pinned this issue Apr 6, 2021
@raialvaro
Copy link
Author

thank you very much, @remicres . It has been very helpful!!!

I had not realized that my sentinel image had only the RGB bands.

@remicres
Copy link
Owner

remicres commented Apr 7, 2021

Thanks. I've added the example in the README !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants