ValueError from custom image preprocessing function

keras
python

#1

I posted this issue in-depth over on stackoverflow with no luck, so I am hoping to get some answers here! You can see my full code on stackoverflow, but I have reproduced the main issue and code here.

In brief, I have a custom keras preprocessing function I use to call some python code. The both accepts and returns a tensor of rank 3. The custom function (both in R and python) runs on its own, however as part of the keras::image_data_generator and keras::flow_images_from_data pipeline, I get the error:

Error in py_iter_next(it, completed) : 
  ValueError: output array is read-only

When I step through the python code to check the flags on the output image, it gives a WRITABLE: True flag. Any help figuring out why this might be would be greatly appreciated! Thanks!