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
4e1906be
"git@developer.sourcefind.cn:OpenDAS/mmdetection3d.git" did not exist on "82a0c215ec1faf71f06e7e6ff3358c8479bcccce"
Commit
4e1906be
authored
Nov 13, 2015
by
lucasb-eyer
Browse files
Add language to code-blocks in README.md
parent
dfb60dc5
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
8 deletions
+8
-8
README.md
README.md
+8
-8
No files found.
README.md
View file @
4e1906be
...
@@ -29,7 +29,7 @@ Usage
...
@@ -29,7 +29,7 @@ Usage
For images, the easiest way to use this library is using the
`DenseCRF2D`
class:
For images, the easiest way to use this library is using the
`DenseCRF2D`
class:
```
```
python
import
numpy
as
np
import
numpy
as
np
import
densecrf
as
dcrf
import
densecrf
as
dcrf
...
@@ -41,7 +41,7 @@ Unary potential
...
@@ -41,7 +41,7 @@ Unary potential
You can then set a fixed unary potential in the following way:
You can then set a fixed unary potential in the following way:
```
```
python
U
=
np
.
array
(...)
# Get the unary in some way.
U
=
np
.
array
(...)
# Get the unary in some way.
print
(
U
.
shape
)
# -> (640, 480, 3)
print
(
U
.
shape
)
# -> (640, 480, 3)
print
(
U
.
dtype
)
# -> dtype('float32')
print
(
U
.
dtype
)
# -> dtype('float32')
...
@@ -62,7 +62,7 @@ Pairwise potentials
...
@@ -62,7 +62,7 @@ Pairwise potentials
The two-dimensional case has two utility methods for adding the most-common pairwise potentials:
The two-dimensional case has two utility methods for adding the most-common pairwise potentials:
```
```
python
# This adds the color-independent term, features are the locations only.
# This adds the color-independent term, features are the locations only.
d
.
addPairwiseGaussian
(
sxy
=
(
3
,
3
),
compat
=
3
,
kernel
=
dcrf
.
DIAG_KERNEL
,
normalization
=
dcrf
.
NORMALIZE_SYMMETRIC
)
d
.
addPairwiseGaussian
(
sxy
=
(
3
,
3
),
compat
=
3
,
kernel
=
dcrf
.
DIAG_KERNEL
,
normalization
=
dcrf
.
NORMALIZE_SYMMETRIC
)
...
@@ -74,7 +74,7 @@ d.addPairwiseBilateral(sxy=(80,80), srgb=(13,13,13), rgbim=im, compat=10, kernel
...
@@ -74,7 +74,7 @@ d.addPairwiseBilateral(sxy=(80,80), srgb=(13,13,13), rgbim=im, compat=10, kernel
Both of these methods have shortcuts and default-arguments such that the most
Both of these methods have shortcuts and default-arguments such that the most
common use-case can be simplified to:
common use-case can be simplified to:
```
```
python
d
.
addPairwiseGaussian
(
sxy
=
3
,
compat
=
3
)
d
.
addPairwiseGaussian
(
sxy
=
3
,
compat
=
3
)
d
.
addPairwiseBilateral
(
sxy
=
80
,
srgb
=
13
,
rgbim
=
im
,
compat
=
10
)
d
.
addPairwiseBilateral
(
sxy
=
80
,
srgb
=
13
,
rgbim
=
im
,
compat
=
10
)
```
```
...
@@ -109,13 +109,13 @@ Inference
...
@@ -109,13 +109,13 @@ Inference
The easiest way to do inference is to simply call:
The easiest way to do inference is to simply call:
```
```
python
Q
=
d
.
inference
(
n_iterations
=
5
)
Q
=
d
.
inference
(
n_iterations
=
5
)
```
```
And the MAP prediction is then:
And the MAP prediction is then:
```
```
python
map
=
np
.
argmax
(
Q
,
axis
=
0
).
reshape
((
640
,
480
))
map
=
np
.
argmax
(
Q
,
axis
=
0
).
reshape
((
640
,
480
))
```
```
...
@@ -124,7 +124,7 @@ Step-by-step inference
...
@@ -124,7 +124,7 @@ Step-by-step inference
If for some reason you want to run the inference loop manually, you can do so:
If for some reason you want to run the inference loop manually, you can do so:
```
```
python
Q
,
tmp1
,
tmp2
=
d
.
startInference
()
Q
,
tmp1
,
tmp2
=
d
.
startInference
()
for
i
in
range
(
5
):
for
i
in
range
(
5
):
print
(
"KL-divergence at {}: {}"
.
format
(
i
,
d
.
klDivergence
(
Q
)))
print
(
"KL-divergence at {}: {}"
.
format
(
i
,
d
.
klDivergence
(
Q
)))
...
@@ -140,7 +140,7 @@ potentials `addPairwiseGaussian` and `addPairwiseBilateral` are missing.
...
@@ -140,7 +140,7 @@ potentials `addPairwiseGaussian` and `addPairwiseBilateral` are missing.
Instead, you need to use the generic
`addPairwiseEnergy`
method like this:
Instead, you need to use the generic
`addPairwiseEnergy`
method like this:
```
```
python
d
=
dcrf
.
DenseCRF
(
100
,
3
)
# npoints, nlabels
d
=
dcrf
.
DenseCRF
(
100
,
3
)
# npoints, nlabels
feats
=
np
.
array
(...)
# Get the pairwise features from somewhere.
feats
=
np
.
array
(...)
# Get the pairwise features from somewhere.
...
...
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