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
keras.preprocessing.image.load_img should support byte objects #11684
Comments
The thing is that as far as I remember, |
I'm definitely aware of how to load an image in to memory from anywhere, the issue was opened primarily because some inference needs would need to also use image.preprocessing class, but the class seems extremely geared towards local filesystem resources instead of remote ones. You can leave this closed - I've already refactored a workaround. Thanks! |
@wmelton Can you please share what the workaround is? |
+1 @wmelton plese share the workaround. |
load image from path:
load image from bytes:
|
Please make sure that the boxes below are checked before you submit your issue.
If your issue is an implementation question, please ask your question on StackOverflow or on the Keras Slack channel instead of opening a GitHub issue.
Thank you!
Check that you are up-to-date with the master branch of Keras. You can update with:
pip install git+git://github.com/keras-team/keras.git --upgrade --no-deps
Check that your version of TensorFlow is up-to-date. 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).
Hello,
When building a predictor that uses a local file, the following function call works perfectly:
keras.preprocessing.image.load_img(img_file, target_size=target_size)
However, the
keras.preprocessing.image
class does not appear to have a similar mechanism for utilizing image bytes objects that have already been loaded into memory for real-time prediction.It appears to be hard-coded to call pil_image.open(path), which doesn't work if image object is already read in to memory.
For example, if you loaded an image in to memory from a URL and then tried to pass it to the preprocessing class, you will get errors.
Currently the above will result in an error such as:
AttributeError: 'int' object has no attribute 'read'
Here is the full Trace:
multiprocessing.pool.RemoteTraceback:
Again - this is presumably because load_img is trying to read the file again from disk rather than understanding it has already been read and is in byte form.
The text was updated successfully, but these errors were encountered: