Skip to main content

tfrecord/
lib.rs

1//! The crate provides the functionality to serialize and deserialize TFRecord data format from TensorFlow.
2//!
3//! # Cargo Features
4//!
5//! Optional features:
6//! - `full`: Enable all features.
7//! - `async`: Enable async/await feature.
8//!
9//! Third-party crate supports:
10//! - `with-serde`: Enable interoperability with [serde](https://crates.io/crates/serde) to serialize and deserialize example types.
11//! - `with-tch`: Enable [tch](https://crates.io/crates/tch) types support.
12//! - `with-image`: Enable [image](https://crates.io/crates/image) types support.
13//! - `with-ndarray`: Enable [ndarray](https://crates.io/crates/ndarray) types support.
14//!
15//! # Manualy ProtocolBuffer Code Generation
16//!
17//! The crate compiles the pre-generated ProtocolBuffer code from TensorFlow. In the case of TensorFlow version update, you may generate the code manually. It accepts several ways to access the TensorFlow source code specified by `TFRECORD_BUILD_METHOD` environment variable. The generated code is placed under `prebuild_src` directory. See the examples below and change `X.Y.Z` to actual TensorFlow version.
18//!
19//! ## Build from a source tarball
20//!
21//! ```sh
22//! export TFRECORD_BUILD_METHOD="src_file:///home/myname/tensorflow-X.Y.Z.tar.gz"
23//! cargo build --release --features generate_protobuf_src
24//! ```
25//!
26//! ## Build from a source directory
27//!
28//! ```sh
29//! export TFRECORD_BUILD_METHOD="src_dir:///home/myname/tensorflow-X.Y.Z"
30//! cargo build --release --features generate_protobuf_src
31//! ```
32//!
33//! ## Build from a URL
34//!
35//! ```sh
36//! export TFRECORD_BUILD_METHOD="url://https://github.com/tensorflow/tensorflow/archive/vX.Y.Z.tar.gz"
37//! cargo build --release --features generate_protobuf_src
38//! ```
39//!
40//! ## Build from installed TensorFlow on system
41//!
42//! The build script will search `${install_prefix}/include/tensorflow` directory for protobuf documents.
43//!
44//! ```sh
45//! export TFRECORD_BUILD_METHOD="install_prefix:///usr"
46//! cargo build --release --features generate_protobuf_src
47//! ```
48
49// mods
50
51pub mod error;
52pub mod event;
53pub mod event_writer;
54pub mod indexer;
55pub mod io;
56pub mod protobuf;
57pub mod protobuf_ext;
58pub mod record;
59pub mod record_reader;
60pub mod record_writer;
61mod utils;
62
63// re-exports
64
65pub use error::*;
66pub use event::*;
67pub use event_writer::*;
68pub use protobuf::{Event, Example, Feature, HistogramProto, Summary};
69pub use protobuf_ext::*;
70pub use record::*;
71pub use record_reader::*;
72pub use record_writer::*;