0

Since colab won't allow me to use tiffile.imread() by giving error 'ValueError: <COMPRESSION.LZW: 5> requires the 'imagecodecs' package', I use gdal.open().ReadAsArray() to read tif file and generate input data for model to inference. This results in:

enter image description here

When I use tiffile.imread() to read the same tif.file in another platform and created input with the same procedures as above. The model prediction finally goes to:

enter image description here

The results from the second image makes sense for the classes I want to predict. I just want to the reason that caused this difference. It seems gdal changed the order of pixels?

1 Answers1

0

This finally works for me. Since I cannot use tiffile.imread() in colab, I tried gdal and rasterio, but the image shape would be channel first. The problem for the first figure is caused by

np.reshape() 

which did not change the axis of data dimension. Then I used codes below and the issue is addressed.

with rio.open("gdrive/My Drive/file.tif") as ds:
  arr=ds.read()
np.moveaxis(arr, 0, -1)