Unverified Commit 6b2d1269 authored by Neal Wu's avatar Neal Wu Committed by GitHub
Browse files

Merge pull request #3324 from andrefaraujo/master

Fix file reading issue for python3 code
parents 26584e08 0d7ce10e
...@@ -12,7 +12,6 @@ ...@@ -12,7 +12,6 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
# ============================================================================== # ==============================================================================
"""Python interface for DatumProto. """Python interface for DatumProto.
DatumProto is protocol buffer used to serialize tensor with arbitrary shape. DatumProto is protocol buffer used to serialize tensor with arbitrary shape.
...@@ -93,7 +92,7 @@ def ReadFromFile(file_path): ...@@ -93,7 +92,7 @@ def ReadFromFile(file_path):
Returns: Returns:
data: Numpy array. data: Numpy array.
""" """
with tf.gfile.FastGFile(file_path, 'r') as f: with tf.gfile.FastGFile(file_path, 'rb') as f:
return ParseFromString(f.read()) return ParseFromString(f.read())
......
...@@ -12,7 +12,6 @@ ...@@ -12,7 +12,6 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
# ============================================================================== # ==============================================================================
"""Python interface for DelfFeatures proto. """Python interface for DelfFeatures proto.
Support read and write of DelfFeatures from/to numpy arrays and file. Support read and write of DelfFeatures from/to numpy arrays and file.
...@@ -169,7 +168,7 @@ def ReadFromFile(file_path): ...@@ -169,7 +168,7 @@ def ReadFromFile(file_path):
attention: [N] float array with attention scores. attention: [N] float array with attention scores.
orientations: [N] float array with orientations. orientations: [N] float array with orientations.
""" """
with tf.gfile.FastGFile(file_path, 'r') as f: with tf.gfile.FastGFile(file_path, 'rb') as f:
return ParseFromString(f.read()) return ParseFromString(f.read())
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment