Skip to content

Commit

Permalink
Fix docs
Browse files Browse the repository at this point in the history
  • Loading branch information
aebruno committed Apr 19, 2018
1 parent 9645670 commit 3cbf810
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 23 deletions.
23 changes: 12 additions & 11 deletions README.rst
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
===============================================================================
terf - Tensorflow TFRecords file format Reader/Writer
terf - TensorFlow TFRecords file format Reader/Writer
===============================================================================

|godoc|

terf is a Go library for reading/writing Tensorflow TFRecord files. The goals
of this project are two fold:
terf is a Go library for reading/writing TensorFlow `TFRecords files
<https://www.tensorflow.org/versions/r1.1/api_guides/python/python_io#tfrecords_format_details>`_.
The goals of this project are two fold:

1. Read/Write Tensorflow TFRecord files in Go
2. Provide an easy way to generate example image datasets for use in Tensorflow
1. Read/Write TensorFlow TFRecords files in Go
2. Provide an easy way to generate example image datasets for use in TensorFlow

With terf you can easily build, inspect, and extract image datasets from the
command line without having to install Tensorflow. terf was developed for use
command line without having to install TensorFlow. terf was developed for use
with `MARCO <https://marco.ccr.buffalo.edu>`_ but should work with most image
datasets. The TFRecord file format is based on the imagenet dataset from the
inception research model in Tensorflow.
datasets. The TFRecords file format is based on the imagenet dataset from the
inception research model in TensorFlow.

-------------------------------------------------------------------------------
Install
Expand All @@ -35,7 +36,7 @@ Create an image dataset
~~~~~~~~~~~~~~~~~~~~~~~~~

You have a directory of images that have been labeled and you want to build an
image dataset that can be used in Tensorflow. First step is to generate a CSV
image dataset that can be used in TensorFlow. First step is to generate a CSV
file in the following format::

image_path,image_id,label_id,label_text,label_raw,source
Expand All @@ -55,7 +56,7 @@ To build the image dataset run the following command::

$ ./terf -d build --input images.csv --output train_directory/ --size 1024

This will convert the image data into a sharded data set of TFRecord files in
This will convert the image data into a sharded data set of TFRecords files in
the train/ output directory::
train_directory/train-00000-of-00024
Expand Down Expand Up @@ -154,7 +155,7 @@ Parse TFRecords file in Go:
count := 0
for {
// example will be a Tensorflow Example proto
// example will be a TensorFlow Example proto
example, err := r.Next()
if err == io.EOF {
break
Expand Down
18 changes: 9 additions & 9 deletions image.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ import (
_ "image/png"
)

// Image is an Example image for training/validating in Tensorflow
// Image is an Example image for training/validating in TensorFlow
type Image struct {
// Unique ID for the image
ID int
Expand Down Expand Up @@ -74,7 +74,7 @@ type Image struct {
Raw []byte
}

// Int64Feature is a helper function for encoding Tensorflow Example proto
// Int64Feature is a helper function for encoding TensorFlow Example proto
// Int64 features
func Int64Feature(val int64) *protobuf.Feature {
return &protobuf.Feature{
Expand All @@ -86,7 +86,7 @@ func Int64Feature(val int64) *protobuf.Feature {
}
}

// FloatFeature is a helper function for encoding Tensorflow Example proto
// FloatFeature is a helper function for encoding TensorFlow Example proto
// Float features
func FloatFeature(val float32) *protobuf.Feature {
return &protobuf.Feature{
Expand All @@ -98,7 +98,7 @@ func FloatFeature(val float32) *protobuf.Feature {
}
}

// BytesFeature is a helper function for encoding Tensorflow Example proto
// BytesFeature is a helper function for encoding TensorFlow Example proto
// Bytes features
func BytesFeature(val []byte) *protobuf.Feature {
return &protobuf.Feature{
Expand All @@ -111,7 +111,7 @@ func BytesFeature(val []byte) *protobuf.Feature {
}

// ExampleFeatureInt64 is a helper function for decoding proto Int64 feature
// from a Tensorflow Example. If key is not found it returns default value
// from a TensorFlow Example. If key is not found it returns default value
func ExampleFeatureInt64(example *protobuf.Example, key string) int {
// TODO: return error if key is not found?
f, ok := example.Features.Feature[key]
Expand All @@ -128,7 +128,7 @@ func ExampleFeatureInt64(example *protobuf.Example, key string) int {
}

// ExampleFeatureFloat is a helper function for decoding proto Float feature
// from a Tensorflow Example. If key is not found it returns default value
// from a TensorFlow Example. If key is not found it returns default value
func ExampleFeatureFloat(example *protobuf.Example, key string) float64 {
// TODO: return error if key is not found?
f, ok := example.Features.Feature[key]
Expand All @@ -145,7 +145,7 @@ func ExampleFeatureFloat(example *protobuf.Example, key string) float64 {
}

// ExampleFeatureBytes is a helper function for decoding proto Bytes feature
// from a Tensorflow Example. If key is not found it returns default value
// from a TensorFlow Example. If key is not found it returns default value
func ExampleFeatureBytes(example *protobuf.Example, key string) []byte {
// TODO: return error if key is not found?
f, ok := example.Features.Feature[key]
Expand Down Expand Up @@ -266,7 +266,7 @@ func (i *Image) MarshalCSV(baseDir string) []string {
}
}

// UnmarshalExample decodes data from a Tensorflow example proto into Image i.
// UnmarshalExample decodes data from a TensorFlow example proto into Image i.
// This is the inverse of MarshalExample.
func (i *Image) UnmarshalExample(example *protobuf.Example) error {

Expand All @@ -285,7 +285,7 @@ func (i *Image) UnmarshalExample(example *protobuf.Example) error {
return nil
}

// MarshalExample converts the Image to a Tensorflow Example proto.
// MarshalExample converts the Image to a TensorFlow Example proto.
// The Example proto schema is as follows:
//
// image/height: integer, image height in pixels
Expand Down
4 changes: 2 additions & 2 deletions terf_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ func ExampleReader() {

count := 0
for {
// example will be a Tensorflow Example proto
// example will be a TensorFlow Example proto
example, err := r.Next()
if err == io.EOF {
break
Expand Down Expand Up @@ -169,7 +169,7 @@ func ExampleReader_compressed() {

count := 0
for {
// example will be a Tensorflow Example proto
// example will be a TensorFlow Example proto
example, err := r.Next()
if err == io.EOF {
break
Expand Down
2 changes: 1 addition & 1 deletion writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
// You should have received a copy of the GNU General Public License
// along with terf. If not, see <http://www.gnu.org/licenses/>.

// Package terf implements a reader/writer for Tensorflow TFRecord files
// Package terf implements a reader/writer for TensorFlow TFRecords files
package terf

import (
Expand Down

0 comments on commit 3cbf810

Please sign in to comment.