-
Notifications
You must be signed in to change notification settings - Fork 19.5k
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
ImageDataGenerator.flow() with tf tensor of images/labels, ex: TFRecord #5356
Comments
This actually seems to apply to many of the model API's methods as well. I did search for a relevant issue, hopefully it isn't a duplicate. |
#5368 is a related, but slightly different issue for feeding tensors directly into a model using a tensorflow based implementation of flow() to handle TFRecords. |
The Keras preprocessing is entirely outside of the symbolic graph - it operates on image data not tensors. Personally I don't think there should be any support for this (preprocessing, IMO, should not be a part of a model; no need to worry about training/test time manipulations of the graph to turn on/off augmentation; no forcing of the model itself to read from disk and being limited by what/how it reads; no concerns about the GPU doing stuff the CPU should be handling in parallel, etc., etc.). I've not seen any discussion about adding a new form of preprocessing within the graph itself, and most of the discussion around it has been confusion about what that actually means in terms of symbolic computing. |
@patyork So am I correct that this means what I'd like to do is simply not possible with the current code as-is, and I must convert my images to numpy arrays before training?
I'm not sure if you're specifically talking about training, but in general this is a heavily application dependent decision that should be left up to the user. Consider a soft realtime deploy-time processing pipeline that first uses a spatial transformer network to transform an image into a space on which another network then makes decisions.... You wouldn't want to go to python for actually applying the transformation, it would add significantly to latency.
I find that the python code can become the limiting factor for many use cases, isn't this the purpose of the queues built into tensorflow, for example? |
That's correct. You could, alternatively, use whatever preprocessing code TF provides (https://www.tensorflow.org/api_docs/python/image/) and write any missing functionality you need using TF functions. |
Thanks. Yes, I could also either use tensorflow only code or a lib like tensorpack/tensorlayer. Should this issue then become a feature request for additional discussion, or perhaps this issue is best closed immediately. |
I created some hypothetical example code that solves this in #6891 (comment). Also related is #6538 and #6928. I'm closing this in favor of those. |
|
Check that you are up-to-date with the master branch of Keras. You can update with:
pip install git+git://github.com/fchollet/keras.git --upgrade --no-deps
If running on TensorFlow, check that you are up-to-date with the latest version. The installation instructions can be found here.
Provide a link to a GitHub Gist of a Python script that can reproduce your issue (or just copy the script here if it is short).
ImageDataGenerator.flow() expects numpy arrays and does not accept but TF tensors containing the same image data. Should this be updated to accept TF tensors of images and labels, and are there any plans to do so?
Proposed example code of loading such data from a TFRecord for semantic segmentation:
The text was updated successfully, but these errors were encountered: