rstudio / keras3

R Interface to Keras
https://keras3.posit.co/
Other
838 stars 283 forks source link

issue with geotiffs? #1218

Open jebyrnes opened 3 years ago

jebyrnes commented 3 years ago

I'm working on a deep learning with Landsat data project with resnet-50. I developed the model using a png dataset, and it works great! But, when I transfered over to loading in geotiffs, I get the following error:

Error in py_call_impl(callable, dots$args, dots$keywords) : 
  UnidentifiedImageError: cannot identify image file <_io.BytesIO object at 0x000001A3618AB408>

I am wondering if this is because I am using geotiffs, which have additional metadata, and not a regular tiff? I also noticed that, in python, there is a library for spatial data generators - https://pypi.org/project/keras-spatial/

1) Is this really an error that using geotiffs would throw (or would it even be thrown by normal tiffs)?

2) If the solution is to use the python library above for an data generator, how can I fold this into R keras/tensorflow?

t-kalinowski commented 3 years ago

Hi, thanks for filing. How are you loading your data and feeding it to the model right now? As far as i know, geotiffs are not explicitly supported, but I'm guessing it will be straightforward to adapt your data pipeline to process geotiffs. Can you please post a minimal code snippet where I can see a) your data pipeline that works with pngs, and b) how you tried to adapt the data pipeline to make it work with geotiffs?

jebyrnes commented 3 years ago

Honestly, I was just reading them in with flow_images_from_directory - it looks like diging into the python that tensorflow does not currently support TIFFs, so, we wrote our own generator that makes arrays from tiffs. Somewhat annoying, but it seems to work?