Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[test_gqn_tfr_provider] Command line options? #21

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 33 additions & 15 deletions tests/test_gqn_tfr_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,28 +9,46 @@
sys.path.append(TF_GQN_HOME)

import tensorflow as tf
import numpy as np
import argparse

from data_provider.gqn_tfr_provider import DataReader

# TODO(ogroth): make CLI parameters!
ROOT_PATH = '/tmp/data/gqn-dataset'
DATASET_NAME = 'rooms_ring_camera'
CTX_SIZE = 5 # number of context (image, pose) pairs for a given query pose
BATCH_SIZE = 36
parser = argparse.ArgumentParser(description='Test the DataReader')
parser.add_argument(
'--data_dir', type=str, default='/tmp/data/gqn-dataset',
help='The path to the gqn-dataset directory.'
)
parser.add_argument(
'--dataset', type=str, default='rooms_ring_camera',
help='The name of the GQN dataset to use. \
Available names are: \
jaco | mazes | rooms_free_camera_no_object_rotations | \
rooms_free_camera_with_object_rotations | rooms_ring_camera | \
shepard_metzler_5_parts | shepard_metzler_7_parts'
)
parser.add_argument(
'--context_size', type=int, default=5,
help='Number of context (image, pose) pairs for a given query pose'
)
parser.add_argument(
'--batch_size', type=int, default=36,
help='Batch size'
)
FLAGS = parser.parse_args()


# graph definition
data_reader = DataReader(dataset=DATASET_NAME, context_size=CTX_SIZE, root=ROOT_PATH)
data = data_reader.read(batch_size=BATCH_SIZE)
data_reader = DataReader(dataset=FLAGS.dataset, context_size=FLAGS.context_size, root=FLAGS.data_dir)
data = data_reader.read(batch_size=FLAGS.batch_size)

# fetch one batch of data
with tf.train.SingularMonitoredSession() as sess:
d = sess.run(data)
# print shapes of fetched objects
print("Shapes of fetched tensors:")
print("Query camera poses: %s" % str(d.query.query_camera.shape))
print("Target images: %s" % str(d.target.shape))
print("Context camera poses: %s" % str(d.query.context.cameras.shape))
print("Context frames: %s" % str(d.query.context.frames.shape))
d = sess.run(data)
# print shapes of fetched objects
print("Shapes of fetched tensors:")
print("Query camera poses: %s" % str(d.query.query_camera.shape))
print("Target images: %s" % str(d.target.shape))
print("Context camera poses: %s" % str(d.query.context.cameras.shape))
print("Context frames: %s" % str(d.query.context.frames.shape))

print("TEST PASSED!")