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
c51df958
Commit
c51df958
authored
Oct 06, 2016
by
Yuxin Wu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
misc change in hed
parent
2a444073
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
6 deletions
+10
-6
examples/HED/hed.py
examples/HED/hed.py
+9
-3
tensorpack/dataflow/dataset/bsds500.py
tensorpack/dataflow/dataset/bsds500.py
+1
-3
No files found.
examples/HED/hed.py
View file @
c51df958
...
@@ -107,6 +107,11 @@ class Model(ModelDesc):
...
@@ -107,6 +107,11 @@ class Model(ModelDesc):
wrong
=
tf
.
cast
(
tf
.
not_equal
(
pred
,
edgemap
),
tf
.
float32
)
wrong
=
tf
.
cast
(
tf
.
not_equal
(
pred
,
edgemap
),
tf
.
float32
)
wrong
=
tf
.
reduce_mean
(
wrong
,
name
=
'train_error'
)
wrong
=
tf
.
reduce_mean
(
wrong
,
name
=
'train_error'
)
wd_w
=
tf
.
train
.
exponential_decay
(
2e-4
,
get_global_step_var
(),
80000
,
0.7
,
True
)
wd_cost
=
tf
.
mul
(
wd_w
,
regularize_cost
(
'.*/W'
,
tf
.
nn
.
l2_loss
),
name
=
'wd_cost'
)
costs
.
append
(
wd_cost
)
add_moving_summary
(
costs
+
[
wrong
])
add_moving_summary
(
costs
+
[
wrong
])
add_param_summary
([(
'.*/W'
,
[
'histogram'
])])
# monitor W
add_param_summary
([(
'.*/W'
,
[
'histogram'
])])
# monitor W
self
.
cost
=
tf
.
add_n
(
costs
,
name
=
'cost'
)
self
.
cost
=
tf
.
add_n
(
costs
,
name
=
'cost'
)
...
@@ -142,7 +147,7 @@ def get_data(name):
...
@@ -142,7 +147,7 @@ def get_data(name):
else
:
else
:
# the original image shape (321x481) in BSDS is not a multiple of 16
# the original image shape (321x481) in BSDS is not a multiple of 16
IMAGE_SHAPE
=
(
320
,
480
)
IMAGE_SHAPE
=
(
320
,
480
)
shape_aug
=
[
imgaug
.
Random
Crop
(
IMAGE_SHAPE
)]
shape_aug
=
[
imgaug
.
Center
Crop
(
IMAGE_SHAPE
)]
ds
=
AugmentImageComponents
(
ds
,
shape_aug
,
(
0
,
1
))
ds
=
AugmentImageComponents
(
ds
,
shape_aug
,
(
0
,
1
))
def
f
(
m
):
def
f
(
m
):
...
@@ -177,7 +182,7 @@ def view_data():
...
@@ -177,7 +182,7 @@ def view_data():
def
get_config
():
def
get_config
():
logger
.
auto_set_dir
()
logger
.
auto_set_dir
()
dataset_train
=
get_data
(
'train'
)
dataset_train
=
get_data
(
'train'
)
step_per_epoch
=
dataset_train
.
size
()
*
2
0
step_per_epoch
=
dataset_train
.
size
()
*
10
0
dataset_val
=
get_data
(
'val'
)
dataset_val
=
get_data
(
'val'
)
#dataset_test = get_data('test')
#dataset_test = get_data('test')
...
@@ -190,13 +195,14 @@ def get_config():
...
@@ -190,13 +195,14 @@ def get_config():
callbacks
=
Callbacks
([
callbacks
=
Callbacks
([
StatPrinter
(),
StatPrinter
(),
ModelSaver
(),
ModelSaver
(),
ScheduledHyperParamSetter
(
'learning_rate'
,
[(
25
,
3e-6
)]),
HumanHyperParamSetter
(
'learning_rate'
),
HumanHyperParamSetter
(
'learning_rate'
),
InferenceRunner
(
dataset_val
,
InferenceRunner
(
dataset_val
,
BinaryClassificationStats
(
'prediction'
,
'edgemap'
))
BinaryClassificationStats
(
'prediction'
,
'edgemap'
))
]),
]),
model
=
Model
(),
model
=
Model
(),
step_per_epoch
=
step_per_epoch
,
step_per_epoch
=
step_per_epoch
,
max_epoch
=
5
00
,
max_epoch
=
1
00
,
)
)
def
run
(
model_path
,
image_path
):
def
run
(
model_path
,
image_path
):
...
...
tensorpack/dataflow/dataset/bsds500.py
View file @
c51df958
...
@@ -73,16 +73,14 @@ class BSDS500(RNGDataFlow):
...
@@ -73,16 +73,14 @@ class BSDS500(RNGDataFlow):
gt
=
loadmat
(
gt_file
)[
'groundTruth'
][
0
]
gt
=
loadmat
(
gt_file
)[
'groundTruth'
][
0
]
n_annot
=
gt
.
shape
[
0
]
n_annot
=
gt
.
shape
[
0
]
gt
=
sum
(
gt
[
k
][
'Boundaries'
][
0
][
0
]
for
k
in
range
(
n_annot
))
gt
=
sum
(
gt
[
k
][
'Boundaries'
][
0
][
0
]
for
k
in
range
(
n_annot
))
#gt[gt <= 2] = 0
gt
=
gt
.
astype
(
'float32'
)
gt
=
gt
.
astype
(
'float32'
)
gt
/=
np
.
max
(
gt
)
gt
*=
1.0
/
n_annot
if
gt
.
shape
[
0
]
>
gt
.
shape
[
1
]:
if
gt
.
shape
[
0
]
>
gt
.
shape
[
1
]:
gt
=
gt
.
transpose
()
gt
=
gt
.
transpose
()
assert
gt
.
shape
==
(
IMG_H
,
IMG_W
)
assert
gt
.
shape
==
(
IMG_H
,
IMG_W
)
self
.
data
[
idx
]
=
im
self
.
data
[
idx
]
=
im
self
.
label
[
idx
]
=
gt
self
.
label
[
idx
]
=
gt
#self.label[self.label<0.9] = 0
def
size
(
self
):
def
size
(
self
):
return
self
.
data
.
shape
[
0
]
return
self
.
data
.
shape
[
0
]
...
...
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