Skip to content
This repository has been archived by the owner on Nov 23, 2023. It is now read-only.

questions of function "ignores_from_label" in layers.py #15

Open
BlueWinters opened this issue Nov 4, 2019 · 1 comment
Open

questions of function "ignores_from_label" in layers.py #15

BlueWinters opened this issue Nov 4, 2019 · 1 comment

Comments

@BlueWinters
Copy link

BlueWinters commented Nov 4, 2019

As the comments in the function of "ignores_from_label" in layers.py say:

"""Retrieves ignorable pixels from the ground-truth labels. This function returns a binary map in which 1 denotes ignored pixels and 0 means not ignored ones. For those ignored pixels, they are not only the pixels with label value >= num_classes, but also the corresponding neighboring pixels, which are on the the eight cornerls from a (2size+1)x(2size+1) patch.

In my option, it means that it will filter some invalid labels in the input(e.g the 255 in Pascal VOC).
But it seems like that the code is not correct. I made some simple attempts:

N = s * s - 1
tensor = tf.constant(np.random.randint(0, 2, 25, dtype=np.int32), dtype=tf.int32)
tensor = tf.reshape(tensor, (1, 5, 5))
ignore = ignores_from_label(tensor, num_classes=5, size=1)
with tf.Session() as sess:
    sess.run(tf.global_variables_initializer())
    print(np.reshape(sess.run(tensor), (5, 5)))
    print('------------------')
    print(tensor.get_shape().as_list())
    out = np.reshape(sess.run(ignore), (5, 5, N))
    for n in range(N):
        print(n)
        print(out[:, :, n].astype(np.int32))
            print(n)
            print(out[:, :, n].astype(np.int32))

the output is:

[[1 1 0 1 0]
 [0 1 1 0 0]
 [0 0 1 0 0]
 [1 1 1 1 0]
 [1 0 1 1 0]]

[1, 5, 5]
0
[[1 1 1 1 1]
 [1 0 0 0 1]
 [1 0 0 0 1]
 [1 0 0 0 1]
 [1 1 1 1 1]]
1
[[1 1 1 1 1]
 [0 0 0 0 0]
 [0 0 0 0 0]
 [0 0 0 0 0]
 [1 1 1 1 1]]
2
[[1 1 1 1 1]
 [1 0 0 0 1]
 [1 0 0 0 1]
 [1 0 0 0 1]
 [1 1 1 1 1]]
3
[[1 0 0 0 1]
 [1 0 0 0 1]
 [1 0 0 0 1]
 [1 0 0 0 1]
 [1 0 0 0 1]]
4
[[1 0 0 0 1]
 [1 0 0 0 1]
 [1 0 0 0 1]
 [1 0 0 0 1]
 [1 0 0 0 1]]
5
[[1 1 1 1 1]
 [1 0 0 0 1]
 [1 0 0 0 1]
 [1 0 0 0 1]
 [1 1 1 1 1]]
6
[[1 1 1 1 1]
 [0 0 0 0 0]
 [0 0 0 0 0]
 [0 0 0 0 0]
 [1 1 1 1 1]]
7
[[1 1 1 1 1]
 [1 0 0 0 1]
 [1 0 0 0 1]
 [1 0 0 0 1]
 [1 1 1 1 1]]

The result is unexpected. Does it means to ignore the boundary pixels of the image?

@xychenunc
Copy link

Do not understand why you think the results are unexpected. What is your expectation of the outputs?

# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants