Tools for dealing with TFRecords
Project description
TFRecords
Tools for dealing with TFRecords
pip install tf-records
import tensorflow as tf
import tf.records as tfr
image = tf.ones([1024, 768, 3], dtype=tf.uint8)
label = tf.constant('cat')
spec = tfr.spec(
image=tfr.Tensor([1024, 768, 3], dtype='int'),
label='string'
)
serialized = tfr.serialize(spec, image=x, label=y)
# b'\n+\n\x10\n\x05label\x12\x07\n\x05\n\x03cat\n\x17\n\x05image\x1...'
tfr.parse.sample(spec, tf.constant(serialized))
# { 'image': <tf.Tensor: shape=(1024, 768, 3) ...>, 'label': <tf.Tensor: shape=() ...> }
# or you can parse multiple at once
tfr.parse.batch(spec, tf.constant([serialized, serialized]))
# { 'image': <tf.Tensor: shape=(2, 1024, 768, 3) ...>, 'label': <tf.Tensor: shape=(2,) ...> }
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Close
Hashes for tensorflow_records-0.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 516d956bde35970b941849b47fd97f531d5cdc997c7527b8824a78fdc4d062c0 |
|
MD5 | 10bd45afeef163b97ccb463870312635 |
|
BLAKE2b-256 | 4e1896bb0eaf74b02afd61e7c8d547c74dd4aed94f4f6b80ce20e83fcf929452 |