Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
bob.learn.tensorflow
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
11
Issues
11
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
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.tensorflow
Commits
c02d5c12
Commit
c02d5c12
authored
Nov 08, 2016
by
Tiago de Freitas Pereira
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Computed statistics
parent
c9174c0f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
57 additions
and
0 deletions
+57
-0
bob/learn/tensorflow/script/compute_statistics.py
bob/learn/tensorflow/script/compute_statistics.py
+57
-0
No files found.
bob/learn/tensorflow/script/compute_statistics.py
0 → 100644
View file @
c02d5c12
#!/usr/bin/env python
# vim: set fileencoding=utf-8 :
# @author: Tiago de Freitas Pereira <tiago.pereira@idiap.ch>
# @date: Wed 11 May 2016 09:39:36 CEST
"""
Script that computes statistics for image
Usage:
compute_statistics.py <base_path> --extension=<arg>
compute_statistics.py -h | --help
Options:
-h --help Show this screen.
--extension=<arg> [default: .hdf5]
"""
from
docopt
import
docopt
import
bob.io.base
import
os
import
numpy
import
bob.io.image
def
process_images
(
base_path
,
extension
,
shape
):
files
=
os
.
listdir
(
base_path
)
sum_data
=
numpy
.
zeros
(
shape
=
shape
)
count
=
0
for
f
in
files
:
path
=
os
.
path
.
join
(
base_path
,
f
)
if
os
.
path
.
isdir
(
path
):
c
,
s
=
process_images
(
path
,
extension
,
shape
)
count
+=
c
sum_data
+=
s
if
os
.
path
.
splitext
(
path
)[
1
]
==
extension
:
data
=
bob
.
io
.
base
.
load
(
path
)
count
+=
1
sum_data
+=
data
return
count
,
sum_data
def
main
():
args
=
docopt
(
__doc__
,
version
=
'Mnist training with TensorFlow'
)
BASE_PATH
=
args
[
'<base_path>'
]
EXTENSION
=
args
[
'--extension'
]
SHAPE
=
[
3
,
250
,
250
]
count
,
sum_data
=
process_images
(
BASE_PATH
,
EXTENSION
,
SHAPE
)
means
=
numpy
.
zeros
(
shape
=
SHAPE
)
for
s
in
range
(
SHAPE
[
0
]):
means
[
s
,
...]
=
sum_data
[
s
,
...]
/
float
(
count
)
bob
.
io
.
base
.
save
(
means
,
"means.hdf5"
)
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