Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
seminar-breakout
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Shashank Suhas
seminar-breakout
Commits
c653458c
Commit
c653458c
authored
Jan 04, 2016
by
Yuxin Wu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix logdir
parent
d2262d1d
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
41 additions
and
25 deletions
+41
-25
example_cifar10.py
example_cifar10.py
+1
-1
scripts/dump_train_config.py
scripts/dump_train_config.py
+28
-13
tensorpack/callbacks/validation_callback.py
tensorpack/callbacks/validation_callback.py
+2
-1
tensorpack/dataflow/imgaug/noname.py
tensorpack/dataflow/imgaug/noname.py
+2
-3
tensorpack/utils/logger.py
tensorpack/utils/logger.py
+7
-7
tensorpack/utils/utils.py
tensorpack/utils/utils.py
+1
-0
No files found.
example_cifar10.py
View file @
c653458c
...
...
@@ -88,7 +88,7 @@ def get_model(inputs, is_training):
def
get_config
():
basename
=
os
.
path
.
basename
(
__file__
)
log_dir
=
os
.
path
.
join
(
'train_log'
,
basename
[:
basename
.
rfind
(
'.'
)])
logger
.
set_logger_
dir
(
log_dir
)
logger
.
set_logger_
file
(
os
.
path
.
join
(
log_dir
,
'training.log'
)
)
dataset_train
=
dataset
.
Cifar10
(
'train'
)
augmentors
=
[
...
...
scripts/dump_train_config.py
View file @
c653458c
...
...
@@ -7,29 +7,44 @@ import argparse
import
cv2
import
tensorflow
as
tf
import
imp
import
tqdm
import
os
from
tensorpack.utils
import
logger
from
tensorpack.utils.utils
import
mkdir_p
parser
=
argparse
.
ArgumentParser
()
parser
.
add_argument
(
dest
=
'config'
)
parser
.
add_argument
(
dest
=
'output
'
)
parser
.
add_argument
(
'-n'
,
'--number'
,
help
=
'number of images to
take
'
,
parser
.
add_argument
(
'-o'
,
'--output'
,
help
=
'output directory to dump dataset image
'
)
parser
.
add_argument
(
'-n'
,
'--number'
,
help
=
'number of images to
dump
'
,
default
=
10
,
type
=
int
)
args
=
parser
.
parse_args
()
mkdir_p
(
args
.
output
)
index
=
0
# TODO: as an argument?
get_config_func
=
imp
.
load_source
(
'config_script'
,
args
.
config
)
.
get_config
config
=
get_config_func
()
cnt
=
0
for
dp
in
config
.
dataset
.
get_data
():
imgbatch
=
dp
[
index
]
if
cnt
>
args
.
number
:
break
for
bi
,
img
in
enumerate
(
imgbatch
):
cnt
+=
1
fname
=
os
.
path
.
join
(
args
.
output
,
'{:03d}-{}.png'
.
format
(
cnt
,
bi
))
cv2
.
imwrite
(
fname
,
img
*
255.0
)
if
args
.
output
:
mkdir_p
(
args
.
output
)
cnt
=
0
index
=
0
# TODO: as an argument?
for
dp
in
config
.
dataset
.
get_data
():
imgbatch
=
dp
[
index
]
if
cnt
>
args
.
number
:
break
for
bi
,
img
in
enumerate
(
imgbatch
):
cnt
+=
1
fname
=
os
.
path
.
join
(
args
.
output
,
'{:03d}-{}.png'
.
format
(
cnt
,
bi
))
cv2
.
imwrite
(
fname
,
img
)
NR_DP_TEST
=
100
logger
.
info
(
"Testing dataflow speed:"
)
with
tqdm
.
tqdm
(
total
=
NR_DP_TEST
,
leave
=
True
,
unit
=
'data points'
)
as
pbar
:
for
idx
,
dp
in
enumerate
(
config
.
dataset
.
get_data
()):
if
idx
>
NR_DP_TEST
:
break
pbar
.
update
()
tensorpack/callbacks/validation_callback.py
View file @
c653458c
...
...
@@ -4,6 +4,7 @@
# Author: Yuxin Wu <ppwwyyxx@gmail.com>
import
tensorflow
as
tf
import
itertools
from
tqdm
import
tqdm
from
..utils
import
*
...
...
@@ -47,7 +48,7 @@ class ValidationError(PeriodicCallback):
cost_sum
=
0
with
tqdm
(
total
=
self
.
ds
.
size
())
as
pbar
:
for
dp
in
self
.
ds
.
get_data
():
feed
=
dict
(
zip
(
self
.
input_vars
,
dp
))
feed
=
dict
(
itertools
.
i
zip
(
self
.
input_vars
,
dp
))
batch_size
=
dp
[
0
]
.
shape
[
0
]
# assume batched input
...
...
tensorpack/dataflow/imgaug/noname.py
View file @
c653458c
...
...
@@ -17,18 +17,17 @@ class Flip(ImageAugmentor):
horiz, vert: True/False
"""
if
horiz
and
vert
:
self
.
code
=
-
1
raise
ValueError
(
"Please use two Flip, with both 0.5 prob"
)
elif
horiz
:
self
.
code
=
1
elif
vert
:
self
.
code
=
0
else
:
raise
Runtim
eError
(
"Are you kidding?"
)
raise
Valu
eError
(
"Are you kidding?"
)
self
.
prob
=
prob
self
.
_init
()
def
_augment
(
self
,
img
):
# TODO XXX prob is wrong for both mode
if
self
.
_rand_range
()
<
self
.
prob
:
img
.
arr
=
cv2
.
flip
(
img
.
arr
,
self
.
code
)
if
img
.
coords
:
...
...
tensorpack/utils/logger.py
View file @
c653458c
...
...
@@ -52,11 +52,11 @@ def set_file(path):
filename
=
path
,
encoding
=
'utf-8'
,
mode
=
'w'
)
logger
.
addHandler
(
hdl
)
global
LOG_
DIR
LOG_
DIR
=
"train_
log"
def
set_logger_
dir
(
dir
name
):
global
LOG_
DIR
LOG_
DIR
=
dir
name
mkdir_p
(
LOG_DIR
)
set_file
(
os
.
path
.
join
(
LOG_DIR
,
'training.log'
)
)
global
LOG_
FILE
LOG_
FILE
=
"train_log/log.
log"
def
set_logger_
file
(
file
name
):
global
LOG_
FILE
LOG_
FILE
=
file
name
mkdir_p
(
os
.
path
.
dirname
(
LOG_FILE
)
)
set_file
(
LOG_FILE
)
tensorpack/utils/utils.py
View file @
c653458c
...
...
@@ -20,6 +20,7 @@ def expand_dim_if_necessary(var, dp):
def
mkdir_p
(
dirname
):
assert
dirname
is
not
None
if
dirname
==
''
:
return
try
:
...
...
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