简体   繁体   English

我可以使用Tensorflow转换/解码二进制的JPEG文件吗?

[英]Can I convert/decode a JPEG file that is in binary with Tensorflow?

I'm sending a JPEG file into an AWS Lambda function as binary in a POST request body, and I was wondering if Tensorflow has a way to convert this binary into an image that could be passed into: 我正在POST请求正文中将JPEG文件作为二进制文件发送到AWS Lambda函数中,我想知道Tensorflow是否有办法将该二进制文件转换为可以传递给以下文件的图像:

tf.image.encode_jpeg()  

Any help would be greatly appreciated. 任何帮助将不胜感激。

To convert a JPEG image to a tensor, you need to call tf.image.decode_jpeg() . 要将JPEG图像转换为张量,您需要调用tf.image.decode_jpeg() The following code should work: 下面的代码应该工作:

queue = tf.train.string_input_producer(['image.jpg'])
reader = tf.WholeFileReader()
_, jpg_data = reader.read(queue)
tensor = tf.image.decode_jpeg(jpg_data)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM