Commit 1555d2a8 authored by Guillaume HEUSCH's avatar Guillaume HEUSCH

[script] added script to read and visualize save data during DR-GAN training

parent f6583e54
#!/usr/bin/env python
# encoding: utf-8
""" Read data saved during the training of a DR-GAN
Usage:
%(prog)s [--datadir=<path>] [--verbose ...]
Options:
-h, --help Show this screen.
-V, --version Show version.
-d, --datadir=<path> The dir where the training data reside
-v, --verbose Increase the verbosity (may appear multiple times).
Example:
To read and display the training data:
$ %(prog)s --datadir ./drgan
See '%(prog)s --help' for more information.
"""
import os, sys
import pkg_resources
import bob.core
logger = bob.core.log.setup("bob.learn.pytorch")
from docopt import docopt
version = pkg_resources.require('bob.learn.pytorch')[0].version
import numpy
import bob.io.base
def main(user_input=None):
# Parse the command-line arguments
if user_input is not None:
arguments = user_input
else:
arguments = sys.argv[1:]
prog = os.path.basename(sys.argv[0])
completions = dict(prog=prog, version=version,)
args = docopt(__doc__ % completions,argv=arguments,version='Train DR-GAN (%s)' % version,)
# verbosity
verbosity_level = args['--verbose']
bob.core.log.set_verbosity_level(logger, verbosity_level)
# get the arguments
data_dir = args['--datadir']
# get the data
for f in os.listdir(data_dir):
if f.endswith(".hdf5"):
filename = os.path.join(data_dir, f)
print filename
# read the data
f = bob.io.base.HDF5File(filename) #read only
id_example = f.read('id')
real_example = f.read('real_example')
generated_example = f.read('generated_example')
real_pose = f.read('real_pose')
target_pose = f.read('target_pose')
from matplotlib import pyplot
fig, axarr = pyplot.subplots(1,2)
fig.suptitle("ID = {}".format(id_example))
axarr[0].set_title("Real pose = {}".format(real_pose))
axarr[0].imshow(numpy.rollaxis(numpy.rollaxis(real_example, 2),2))
axarr[1].set_title("Target pose = {}".format(target_pose))
axarr[1].imshow(numpy.rollaxis(numpy.rollaxis(generated_example, 2),2))
pyplot.show()
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