lanha / DSen2

Super-Resolution of Sentinel-2 Images: Learning a Globally Applicable Deep Neural Network
GNU General Public License v3.0
235 stars 71 forks source link

Unable to generate output.tif #32

Closed themousepotato closed 3 years ago

themousepotato commented 4 years ago

I tried executing the following command and it generates an output.tif of 8 bytes but I'm unable to read it.

(image-sr-tf) navaneeth@mousebox:~/workspace/image-super-resolution/DSen2/testing$ python s2_tiles_supres.py /home/navaneeth/Documents/acads/sem7/btp/farm-pin-crop-detection-challenge-dataset/2017-01-01/S2A_MSIL1C_20170101T082332_N0204_R121_T34JEP_20170101T084543.SAFE/MTD_MSIL1C.xml output_file.tif --roi_x_y "100,100,2000,2000"
2020-11-13 14:24:36.412933: I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library libcudart.so.10.1
Selected UTM Zone: UTM 34S
Selected pixel region: xmin=96, ymin=96, xmax=1997, ymax=1997:
Image size: width=1902 x height=1902
Selected 10m bands: B4 B3 B2 B8
Selected 20m bands: B5 B6 B7 B8A B11 B12
Selected 60m bands:
Loading selected data from: Bands B2, B3, B4, B8 with 10m resolution, UTM 34S
Loading selected data from: Bands B5, B6, B7, B8A, B11, B12 with 20m resolution, UTM 34S
Super-resolving the 20m data into 10m bands
2020-11-13 14:24:52.184602: I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library libcuda.so.1
2020-11-13 14:24:52.259091: I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:982] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero
2020-11-13 14:24:52.260615: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1716] Found device 0 with properties: 
pciBusID: 0000:01:00.0 name: GeForce GTX 1070 with Max-Q Design computeCapability: 6.1
coreClock: 1.2655GHz coreCount: 16 deviceMemorySize: 7.93GiB deviceMemoryBandwidth: 238.66GiB/s
2020-11-13 14:24:52.260718: I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library libcudart.so.10.1
2020-11-13 14:24:52.310705: I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library libcublas.so.10
2020-11-13 14:24:52.339329: I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library libcufft.so.10
2020-11-13 14:24:52.345411: I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library libcurand.so.10
2020-11-13 14:24:52.396905: I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library libcusolver.so.10
2020-11-13 14:24:52.404364: I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library libcusparse.so.10
2020-11-13 14:24:52.485774: I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library libcudnn.so.7
2020-11-13 14:24:52.486194: I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:982] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero
2020-11-13 14:24:52.487896: I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:982] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero
2020-11-13 14:24:52.489278: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1858] Adding visible gpu devices: 0
2020-11-13 14:24:52.489955: I tensorflow/core/platform/cpu_feature_guard.cc:142] This TensorFlow binary is optimized with oneAPI Deep Neural Network Library (oneDNN)to use the following CPU instructions in performance-critical operations:  AVX2 FMA
To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags.
2020-11-13 14:24:52.535152: I tensorflow/core/platform/profile_utils/cpu_utils.cc:104] CPU Frequency: 2199995000 Hz
2020-11-13 14:24:52.536521: I tensorflow/compiler/xla/service/service.cc:168] XLA service 0x555c184b9e20 initialized for platform Host (this does not guarantee that XLA will be used). Devices:
2020-11-13 14:24:52.536593: I tensorflow/compiler/xla/service/service.cc:176]   StreamExecutor device (0): Host, Default Version
2020-11-13 14:24:52.982174: I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:982] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero
2020-11-13 14:24:52.983673: I tensorflow/compiler/xla/service/service.cc:168] XLA service 0x555c18144840 initialized for platform CUDA (this does not guarantee that XLA will be used). Devices:
2020-11-13 14:24:52.983747: I tensorflow/compiler/xla/service/service.cc:176]   StreamExecutor device (0): GeForce GTX 1070 with Max-Q Design, Compute Capability 6.1
2020-11-13 14:24:52.985240: I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:982] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero
2020-11-13 14:24:52.986439: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1716] Found device 0 with properties: 
pciBusID: 0000:01:00.0 name: GeForce GTX 1070 with Max-Q Design computeCapability: 6.1
coreClock: 1.2655GHz coreCount: 16 deviceMemorySize: 7.93GiB deviceMemoryBandwidth: 238.66GiB/s
2020-11-13 14:24:52.986554: I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library libcudart.so.10.1
2020-11-13 14:24:52.986660: I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library libcublas.so.10
2020-11-13 14:24:52.986743: I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library libcufft.so.10
2020-11-13 14:24:52.986819: I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library libcurand.so.10
2020-11-13 14:24:52.986894: I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library libcusolver.so.10
2020-11-13 14:24:52.986969: I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library libcusparse.so.10
2020-11-13 14:24:52.987044: I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library libcudnn.so.7
2020-11-13 14:24:52.987260: I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:982] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero
2020-11-13 14:24:52.988569: I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:982] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero
2020-11-13 14:24:52.989690: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1858] Adding visible gpu devices: 0
2020-11-13 14:24:52.990359: I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library libcudart.so.10.1
2020-11-13 14:24:54.821179: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1257] Device interconnect StreamExecutor with strength 1 edge matrix:
2020-11-13 14:24:54.821250: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1263]      0 
2020-11-13 14:24:54.821271: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1276] 0:   N 
2020-11-13 14:24:54.823144: I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:982] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero
2020-11-13 14:24:54.824157: I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:982] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero
2020-11-13 14:24:54.824989: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1402] Created TensorFlow device (/job:localhost/replica:0/task:0/device:GPU:0 with 7173 MB memory) -> physical GPU (device: 0, name: GeForce GTX 1070 with Max-Q Design, pci bus id: 0000:01:00.0, compute capability: 6.1)
Symbolic Model Created.
Predicting using file: ../models/s2_032_lr_1e-04.hdf5
WARNING:tensorflow:AutoGraph could not transform <function Model.make_predict_function.<locals>.predict_function at 0x7f4bc1feb378> and will run it as-is.
Please report this to the TensorFlow team. When filing the bug, set the verbosity to 10 (on Linux, `export AUTOGRAPH_VERBOSITY=10`) and attach the full output.
Cause: 'arguments' object has no attribute 'posonlyargs'
To silence this warning, decorate the function with @tf.autograph.experimental.do_not_convert
2020-11-13 14:24:56.199285: I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library libcudnn.so.7
2020-11-13 14:24:58.658132: I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library libcublas.so.10
 1/10 [==>...........................] - ETA: 0sWARNING:tensorflow:Callbacks method `on_predict_batch_end` is slow compared to the batch time (batch time: 0.0111s vs `on_predict_batch_end` time: 0.3125s). Check your callbacks.
10/10 [==============================] - 3s 285ms/step
(6, 1902, 1902)
ERROR 4: Unable to open output_file.tif to obtain file list.
Writing the super-resolved bands in output_file.tif
SRB5 (705 nm)
SRB6 (740 nm)
SRB7 (783 nm)
SRB8A (865 nm)
SRB11 (1610 nm)
SRB12 (2190 nm)
lanha commented 4 years ago

Hello, this seems to be a problem with GDAL, not the core DSen2 method. Did you try debugging the gdal.Create() method? Do you have permission to write to the requested file?

themousepotato commented 4 years ago

Could you please elaborate? FYI I can still successfully run the demoDSen2.py file.

aleny91 commented 3 years ago

Hi! The problem seems to be related to the fact that the dataset created is not closed after writing the different bands. I suggest you to add result_dataset = None and, by checking also GDAL debugging logs, you will see something like that:

GDAL: Flushing dirty blocks: 0...10...20...30...40...50...60...70...80...90...100 - done. GDAL: GDALClose(/path/to/output.tif, this=0x557a15655d10)

Hope it helps.

adamleonardhubble commented 3 years ago

32ef14510648b08d461bbfdf4542f816 The program executes fine, no problems at a glance. However, the image generated (.tif) is simply a black image of size: 165MB. What is happening? How do I get this to correctly work?

`(c:\dsen2) C:\DSen2\DSen2-master\testing>python s2_tiles_supres.py C:\DSen2\DSen2-master\output\S2A_MSIL1C_20170216T015741_N0204_R060_T52SFB_20170216T015924.SAFE\MTD_MSIL1C.xml C:\DSen2\DSen2-master\output\output.tif --roi_x_y "100,100,2000,2000" 2021-06-27 21:54:15.211953: I tensorflow/stream_executor/platform/default/dso_loader.cc:53] Successfully opened dynamic library cudart64_110.dll Selected UTM Zone: UTM 52N Selected pixel region: xmin=96, ymin=96, xmax=1997, ymax=1997: Image size: width=1902 x height=1902 Selected 10m bands: B4 B3 B2 B8 Selected 20m bands: B5 B6 B7 B8A B11 B12 Selected 60m bands: Loading selected data from: Bands B2, B3, B4, B8 with 10m resolution, UTM 52N Loading selected data from: Bands B5, B6, B7, B8A, B11, B12 with 20m resolution, UTM 52N Super-resolving the 20m data into 10m bands 2021-06-27 21:54:21.558217: I tensorflow/stream_executor/platform/default/dso_loader.cc:53] Successfully opened dynamic library nvcuda.dll 2021-06-27 21:54:21.579561: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1733] Found device 0 with properties: pciBusID: 0000:03:00.0 name: NVIDIA GeForce GTX 970 computeCapability: 5.2 coreClock: 1.253GHz coreCount: 13 deviceMemorySize: 4.00GiB deviceMemoryBandwidth: 208.91GiB/s 2021-06-27 21:54:21.579748: I tensorflow/stream_executor/platform/default/dso_loader.cc:53] Successfully opened dynamic library cudart64_110.dll 2021-06-27 21:54:21.589145: I tensorflow/stream_executor/platform/default/dso_loader.cc:53] Successfully opened dynamic library cublas64_11.dll 2021-06-27 21:54:21.590339: I tensorflow/stream_executor/platform/default/dso_loader.cc:53] Successfully opened dynamic library cublasLt64_11.dll 2021-06-27 21:54:21.594958: I tensorflow/stream_executor/platform/default/dso_loader.cc:53] Successfully opened dynamic library cufft64_10.dll 2021-06-27 21:54:21.596431: I tensorflow/stream_executor/platform/default/dso_loader.cc:53] Successfully opened dynamic library curand64_10.dll 2021-06-27 21:54:21.599532: I tensorflow/stream_executor/platform/default/dso_loader.cc:53] Successfully opened dynamic library cusolver64_11.dll 2021-06-27 21:54:21.604102: I tensorflow/stream_executor/platform/default/dso_loader.cc:53] Successfully opened dynamic library cusparse64_11.dll 2021-06-27 21:54:21.604948: I tensorflow/stream_executor/platform/default/dso_loader.cc:53] Successfully opened dynamic library cudnn64_8.dll 2021-06-27 21:54:21.605083: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1871] Adding visible gpu devices: 0 2021-06-27 21:54:21.605896: I tensorflow/core/platform/cpu_feature_guard.cc:142] This TensorFlow binary is optimized with oneAPI Deep Neural Network Library (oneDNN) to use the following CPU instructions in performance-critical operations: AVX AVX2 To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags. 2021-06-27 21:54:21.606660: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1733] Found device 0 with properties: pciBusID: 0000:03:00.0 name: NVIDIA GeForce GTX 970 computeCapability: 5.2 coreClock: 1.253GHz coreCount: 13 deviceMemorySize: 4.00GiB deviceMemoryBandwidth: 208.91GiB/s 2021-06-27 21:54:21.608467: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1871] Adding visible gpu devices: 0 2021-06-27 21:54:22.067331: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1258] Device interconnect StreamExecutor with strength 1 edge matrix: 2021-06-27 21:54:22.067438: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1264] 0 2021-06-27 21:54:22.069050: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1277] 0: N 2021-06-27 21:54:22.069858: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1418] Created TensorFlow device (/job:localhost/replica:0/task:0/device:GPU:0 with 2776 MB memory) -> physical GPU (device: 0, name: NVIDIA GeForce GTX 970, pci bus id: 0000:03:00.0, compute capability: 5.2) Symbolic Model Created. Predicting using file: ../models/s2_032_lr_1e-04.hdf5 2021-06-27 21:54:22.588953: I tensorflow/compiler/mlir/mlir_graph_optimization_pass.cc:176] None of the MLIR Optimization Passes are enabled (registered 2) 2021-06-27 21:54:28.943358: I tensorflow/stream_executor/platform/default/dso_loader.cc:53] Successfully opened dynamic library cudnn64_8.dll 2021-06-27 21:54:29.218264: I tensorflow/stream_executor/cuda/cuda_dnn.cc:359] Loaded cuDNN version 8100 2021-06-27 21:54:29.838396: I tensorflow/stream_executor/platform/default/dso_loader.cc:53] Successfully opened dynamic library cublas64_11.dll 2021-06-27 21:54:30.161958: I tensorflow/stream_executor/platform/default/dso_loader.cc:53] Successfully opened dynamic library cublasLt64_11.dll 2021-06-27 21:54:30.325501: W tensorflow/core/common_runtime/bfc_allocator.cc:271] Allocator (GPU_0_bfc) ran out of memory trying to allocate 2.27GiB with freed_by_count=0. The caller indicates that this is not a failure, but may mean that there could be performance gains if more memory were available. 2021-06-27 21:54:30.593855: W tensorflow/core/common_runtime/bfc_allocator.cc:271] Allocator (GPU_0_bfc) ran out of memory trying to allocate 2.27GiB with freed_by_count=0. The caller indicates that this is not a failure, but may mean that there could be performance gains if more memory were available. 2021-06-27 21:54:31.153012: W tensorflow/core/common_runtime/bfc_allocator.cc:271] Allocator (GPU_0_bfc) ran out of memory trying to allocate 2.41GiB with freed_by_count=0. The caller indicates that this is not a failure, but may mean that there could be performance gains if more memory were available. 10/10 [==============================] - 12s 397ms/step (6, 1902, 1902) Writing the super-resolved bands in C:\DSen2\DSen2-master\output\output.tif SRB5 (705 nm) SRB6 (740 nm) SRB7 (783 nm) SRB8A (865 nm) SRB11 (1610 nm) SRB12 (2190 nm)

(c:\dsen2) C:\DSen2\DSen2-master\testing>`