Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
bob.learn.pytorch
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
5
Issues
5
List
Boards
Labels
Milestones
Merge Requests
2
Merge Requests
2
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
bob
bob.learn.pytorch
Commits
1555d2a8
Commit
1555d2a8
authored
Nov 29, 2017
by
Guillaume HEUSCH
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[script] added script to read and visualize save data during DR-GAN training
parent
f6583e54
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
82 additions
and
0 deletions
+82
-0
bob/learn/pytorch/scripts/read_training_hdf5.py
bob/learn/pytorch/scripts/read_training_hdf5.py
+82
-0
No files found.
bob/learn/pytorch/scripts/read_training_hdf5.py
0 → 100644
View file @
1555d2a8
#!/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
()
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment