Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
pydensecrf
Commits
94d1cdda
Commit
94d1cdda
authored
May 12, 2016
by
lucasb-eyer
Browse files
Fix import in example and make a little more usable.
parent
f5fecadd
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
7 deletions
+12
-7
examples/inference.py
examples/inference.py
+7
-3
examples/utils_example.py
examples/utils_example.py
+5
-4
No files found.
examples/inference.py
View file @
94d1cdda
#!/usr/bin/python
#!/usr/bin/python
"""
"""
Usage: python dense_inference.py image annotations output
Adapted from the original C++ example: densecrf/examples/dense_inference.cpp
Adapted from the original C++ example: densecrf/examples/dense_inference.cpp
http://www.philkr.net/home/densecrf Version 2.2
http://www.philkr.net/home/densecrf Version 2.2
"""
"""
import
numpy
as
np
import
numpy
as
np
import
cv2
import
cv2
import
densecrf
as
dcrf
import
pydensecrf.
densecrf
as
dcrf
from
skimage.segmentation
import
relabel_sequential
from
skimage.segmentation
import
relabel_sequential
import
sys
import
sys
if
len
(
sys
.
argv
)
!=
4
:
print
(
"Usage: python {} IMAGE ANNO OUTPUT"
.
format
(
sys
.
argv
[
0
]))
print
(
""
)
print
(
"IMAGE and ANNO are inputs and OUTPUT is where the result should be written."
)
sys
.
exit
(
1
)
img
=
cv2
.
imread
(
sys
.
argv
[
1
],
1
)
img
=
cv2
.
imread
(
sys
.
argv
[
1
],
1
)
labels
=
relabel_sequential
(
cv2
.
imread
(
sys
.
argv
[
2
],
0
))[
0
].
flatten
()
labels
=
relabel_sequential
(
cv2
.
imread
(
sys
.
argv
[
2
],
0
))[
0
].
flatten
()
output
=
sys
.
argv
[
3
]
output
=
sys
.
argv
[
3
]
...
...
examples/utils_example.py
View file @
94d1cdda
"""
"""
Usage: python util_inference_example.py image annotations
Adapted from the inference.py to demonstate the usage of the util functions.
Adapted from the dense_inference.py to demonstate the usage of the util
functions.
"""
"""
import
sys
import
sys
...
@@ -15,6 +12,10 @@ from skimage.segmentation import relabel_sequential
...
@@ -15,6 +12,10 @@ from skimage.segmentation import relabel_sequential
from
pydensecrf.utils
import
compute_unary
,
create_pairwise_bilateral
,
\
from
pydensecrf.utils
import
compute_unary
,
create_pairwise_bilateral
,
\
create_pairwise_gaussian
create_pairwise_gaussian
if
len
(
sys
.
argv
)
!=
3
:
print
(
"Usage: python {} IMAGE ANNO"
.
format
(
sys
.
argv
[
0
]))
sys
.
exit
(
1
)
fn_im
=
sys
.
argv
[
1
]
fn_im
=
sys
.
argv
[
1
]
fn_anno
=
sys
.
argv
[
2
]
fn_anno
=
sys
.
argv
[
2
]
...
...
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