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
145fb01d
Commit
145fb01d
authored
Oct 05, 2016
by
Yuxin Wu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
small fix
parent
2168a020
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
26 additions
and
27 deletions
+26
-27
examples/HED/README.md
examples/HED/README.md
+4
-0
examples/HED/hed.py
examples/HED/hed.py
+21
-26
tensorpack/RL/gymenv.py
tensorpack/RL/gymenv.py
+1
-1
No files found.
examples/HED/README.md
0 → 100644
View file @
145fb01d
## Holistically-Nested Edge Detection
Reproduce the HED paper by Saining Xie and Zhuowen Tu. See
[
https://arxiv.org/abs/1504.06375
](
https://arxiv.org/abs/1504.06375
)
.
examples/HED/hed.py
View file @
145fb01d
...
@@ -22,9 +22,10 @@ HED is a fully-convolutional architecture. This code generally would also work
...
@@ -22,9 +22,10 @@ HED is a fully-convolutional architecture. This code generally would also work
for other FCN tasks such as semantic segmentation and detection.
for other FCN tasks such as semantic segmentation and detection.
Usage:
Usage:
This script only needs the original BSDS dataset and applies augmentation on the fly.
It will automatically download the dataset to $TENSORPACK_DATASET/ if not there.
It requires pretrained vgg16 model. See the docs in `examples/load-vgg16.py`
It requires pretrained vgg16 model. See the docs in `examples/load-vgg16.py`
for instructions to convert from vgg16 caffe model.
for instructions to convert from vgg16 caffe model.
It only needs the original BSDS dataset and applies augmentation on the fly.
To view augmented images:
To view augmented images:
./hed.py --view
./hed.py --view
...
@@ -35,11 +36,11 @@ Usage:
...
@@ -35,11 +36,11 @@ Usage:
To inference (produce heatmap at each level):
To inference (produce heatmap at each level):
./hed.py --load pretrained.model --run a.jpg
./hed.py --load pretrained.model --run a.jpg
To view the loss:
To view the loss
curve
:
cat train_log/hed/stat.json | jq '.[] |
\
cat train_log/hed/stat.json | jq '.[] |
[.xentropy1,.xentropy2,.xentropy3,.xentropy4,.xentropy5,.xentropy6] |
\
[.xentropy1,.xentropy2,.xentropy3,.xentropy4,.xentropy5,.xentropy6] |
map(tostring) | join("
\t
") | .' -r |
\
map(tostring) | join("
\t
") | .' -r |
\
../../scripts/plot-point.py -
c 'y,y,y,y,y,y' --legend 1,2,3,4,5,final
../../scripts/plot-point.py -
-legend 1,2,3,4,5,final --decay 0.8
"""
"""
BATCH_SIZE
=
1
BATCH_SIZE
=
1
...
@@ -54,6 +55,7 @@ class Model(ModelDesc):
...
@@ -54,6 +55,7 @@ class Model(ModelDesc):
def
_build_graph
(
self
,
input_vars
,
is_training
):
def
_build_graph
(
self
,
input_vars
,
is_training
):
image
,
edgemap
=
input_vars
image
,
edgemap
=
input_vars
# TODO fix this
edgemap
=
tf
.
identity
(
edgemap
,
name
=
'edgemap-tmp'
)
edgemap
=
tf
.
identity
(
edgemap
,
name
=
'edgemap-tmp'
)
image
=
image
-
tf
.
constant
([
104
,
116
,
122
],
dtype
=
'float32'
)
image
=
image
-
tf
.
constant
([
104
,
116
,
122
],
dtype
=
'float32'
)
...
@@ -139,12 +141,10 @@ def get_data(name):
...
@@ -139,12 +141,10 @@ def get_data(name):
imgaug
.
Flip
(
horiz
=
True
),
imgaug
.
Flip
(
horiz
=
True
),
imgaug
.
Flip
(
vert
=
True
),
imgaug
.
Flip
(
vert
=
True
),
]
]
ds
=
AugmentImageComponents
(
ds
,
shape_aug
,
(
0
,
1
))
else
:
else
:
# this is the original image shape in bsds
# the original image shape (320x480) in bsds is already a multiple of 16
IMAGE_SHAPE
=
(
320
,
480
)
pass
#shape_aug = [imgaug.RandomCrop(IMAGE_SHAPE)]
shape_aug
=
[]
ds
=
AugmentImageComponents
(
ds
,
shape_aug
,
(
0
,
1
))
def
f
(
m
):
def
f
(
m
):
m
[
m
>=
0.49
]
=
1
m
[
m
>=
0.49
]
=
1
m
[
m
<
0.49
]
=
0
m
[
m
<
0.49
]
=
0
...
@@ -185,7 +185,6 @@ def get_config():
...
@@ -185,7 +185,6 @@ def get_config():
return
TrainConfig
(
return
TrainConfig
(
dataset
=
dataset_train
,
dataset
=
dataset_train
,
optimizer
=
tf
.
train
.
AdamOptimizer
(
lr
,
epsilon
=
1e-3
),
optimizer
=
tf
.
train
.
AdamOptimizer
(
lr
,
epsilon
=
1e-3
),
#optimizer=tf.train.MomentumOptimizer(lr, 0.9),
callbacks
=
Callbacks
([
callbacks
=
Callbacks
([
StatPrinter
(),
StatPrinter
(),
ModelSaver
(),
ModelSaver
(),
...
@@ -215,7 +214,6 @@ def run(model_path, image_path):
...
@@ -215,7 +214,6 @@ def run(model_path, image_path):
cv2
.
imwrite
(
"out{}.png"
.
format
(
cv2
.
imwrite
(
"out{}.png"
.
format
(
'-fused'
if
k
==
5
else
str
(
k
+
1
)),
pred
*
255
)
'-fused'
if
k
==
5
else
str
(
k
+
1
)),
pred
*
255
)
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
parser
=
argparse
.
ArgumentParser
()
parser
=
argparse
.
ArgumentParser
()
parser
.
add_argument
(
'--gpu'
,
help
=
'comma separated list of GPU(s) to use.'
)
# nargs='*' in multi mode
parser
.
add_argument
(
'--gpu'
,
help
=
'comma separated list of GPU(s) to use.'
)
# nargs='*' in multi mode
...
@@ -227,18 +225,15 @@ if __name__ == '__main__':
...
@@ -227,18 +225,15 @@ if __name__ == '__main__':
if
args
.
view
:
if
args
.
view
:
ds
=
get_data
(
'train'
)
ds
=
get_data
(
'train'
)
view_data
(
ds
)
view_data
(
ds
)
sys
.
exit
()
elif
args
.
run
:
if
args
.
run
:
run
(
args
.
load
,
args
.
run
)
run
(
args
.
load
,
args
.
run
)
sys
.
exit
()
else
:
if
args
.
gpu
:
if
args
.
gpu
:
os
.
environ
[
'CUDA_VISIBLE_DEVICES'
]
=
args
.
gpu
os
.
environ
[
'CUDA_VISIBLE_DEVICES'
]
=
args
.
gpu
config
=
get_config
()
config
=
get_config
()
if
args
.
load
:
if
args
.
load
:
config
.
session_init
=
get_model_loader
(
args
.
load
)
config
.
session_init
=
get_model_loader
(
args
.
load
)
if
args
.
gpu
:
if
args
.
gpu
:
config
.
nr_tower
=
len
(
args
.
gpu
.
split
(
','
))
config
.
nr_tower
=
len
(
args
.
gpu
.
split
(
','
))
SyncMultiGPUTrainer
(
config
)
.
train
()
SyncMultiGPUTrainer
(
config
)
.
train
()
tensorpack/RL/gymenv.py
View file @
145fb01d
...
@@ -77,4 +77,4 @@ if __name__ == '__main__':
...
@@ -77,4 +77,4 @@ if __name__ == '__main__':
r
,
o
=
env
.
action
(
act
)
r
,
o
=
env
.
action
(
act
)
env
.
current_state
()
env
.
current_state
()
if
r
!=
0
or
o
:
if
r
!=
0
or
o
:
print
r
,
o
print
(
r
,
o
)
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