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
5dee7231
Commit
5dee7231
authored
Nov 14, 2016
by
Yuxin Wu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
--output argument for HED
parent
6087698d
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
8 deletions
+13
-8
examples/HED/hed.py
examples/HED/hed.py
+11
-6
tensorpack/utils/gpu.py
tensorpack/utils/gpu.py
+2
-2
No files found.
examples/HED/hed.py
View file @
5dee7231
...
...
@@ -180,7 +180,7 @@ def get_config():
max_epoch
=
100
,
)
def
run
(
model_path
,
image_path
):
def
run
(
model_path
,
image_path
,
output
):
pred_config
=
PredictConfig
(
model
=
Model
(),
session_init
=
get_model_loader
(
model_path
),
...
...
@@ -191,10 +191,14 @@ def run(model_path, image_path):
assert
im
is
not
None
im
=
cv2
.
resize
(
im
,
(
im
.
shape
[
1
]
//
16
*
16
,
im
.
shape
[
0
]
//
16
*
16
))
outputs
=
predict_func
([[
im
.
astype
(
'float32'
)]])
if
output
is
None
:
for
k
in
range
(
6
):
pred
=
outputs
[
k
][
0
]
cv2
.
imwrite
(
"out{}.png"
.
format
(
'-fused'
if
k
==
5
else
str
(
k
+
1
)),
pred
*
255
)
else
:
pred
=
outputs
[
5
][
0
]
cv2
.
imwrite
(
output
,
pred
*
255
)
if
__name__
==
'__main__'
:
parser
=
argparse
.
ArgumentParser
()
...
...
@@ -202,6 +206,7 @@ if __name__ == '__main__':
parser
.
add_argument
(
'--load'
,
help
=
'load model'
)
parser
.
add_argument
(
'--view'
,
help
=
'view dataset'
,
action
=
'store_true'
)
parser
.
add_argument
(
'--run'
,
help
=
'run model on images'
)
parser
.
add_argument
(
'--output'
,
help
=
'fused output filename. default to out-fused.png'
)
args
=
parser
.
parse_args
()
if
args
.
gpu
:
os
.
environ
[
'CUDA_VISIBLE_DEVICES'
]
=
args
.
gpu
...
...
@@ -209,7 +214,7 @@ if __name__ == '__main__':
if
args
.
view
:
view_data
()
elif
args
.
run
:
run
(
args
.
load
,
args
.
run
)
run
(
args
.
load
,
args
.
run
,
args
.
output
)
else
:
config
=
get_config
()
if
args
.
load
:
...
...
tensorpack/utils/gpu.py
View file @
5dee7231
...
...
@@ -16,12 +16,12 @@ def change_gpu(val):
def
get_nr_gpu
():
env
=
os
.
environ
.
get
(
'CUDA_VISIBLE_DEVICES'
,
None
)
assert
env
is
not
None
# TODO
assert
env
is
not
None
,
'gpu not set!'
# TODO
return
len
(
env
.
split
(
','
))
def
get_gpus
():
""" return a list of GPU physical id"""
env
=
os
.
environ
.
get
(
'CUDA_VISIBLE_DEVICES'
,
None
)
assert
env
is
not
None
# TODO
assert
env
is
not
None
,
'gpu not set!'
# TODO
return
map
(
int
,
env
.
strip
()
.
split
(
','
))
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