Models: [deeplab] extract boundingboxes from segmenation map

Created on 10 Apr 2018  路  10Comments  路  Source: tensorflow/models

i wonder if there is already an implementation or an util to extract boundingboxes from the segmentation masks produced by deeplab's model?

I wanted to investigate the seg_maps that are the ouput of the tf session when running deeplabv3_mnv2 (https://github.com/GustavZ/realtime_segmenation), but printing the map results in a kind of reduced/simplified array in the form of

[[0 0 0 ... 0 0 0]
[0 0 0 ... 0 0 0]
[0 0 0 ... 0 0 0]
...
[0 0 0 ... 0 0 0]
[0 0 0 ... 0 0 0]
[0 0 0 ... 0 0 0]]

So i can't really figure out how to extract bounding boxes from this. But in my understanding it should be possible to create a box around each connected object segment in the mask, right?

Has anybody experience with it, or give me a hint on how to proceed?

help wanted feature

Most helpful comment

@alasin this is not solving the issue for multiple objects of the same class in one image/frame.
I implemented a labeling algorithm using scikit-image. It works perfectly well as you can see on my project https://github.com/GustavZ/realtime_segmenation (have a look at the small demo-gif where there are two chairs correctly detected/segmented)

All 10 comments

Unfortunately, I am not aware of any util for that. However, any contribution is welcome.

did it

Hi @GustavZ did you manage to get bounding boxes working? if so how did you manage it.

Cheers

@crazyfrog-github yes
@aquariusjay would this be interesting as pull request?

Sure, it will be great to have it.
Thanks a lot for looking into this!

ALright.
One more thing: deeplab is not capable of doing instance segmentation, right?

No, since the model only performs semantic segmentation right now.

@GustavZ @aquariusjay I'm doing this for my task:

bboxes = {}
for i in range(num_labels):`
    rows, cols = np.where(seg_masks == i)
    tl_x, tl_y = np.min(cols), np.min(rows)
    br_x, br_y = np.max(cols), np.max(rows)
    bboxes[i] = [tl_x, tl_y, br_x, br_y]

@alasin this is not solving the issue for multiple objects of the same class in one image/frame.
I implemented a labeling algorithm using scikit-image. It works perfectly well as you can see on my project https://github.com/GustavZ/realtime_segmenation (have a look at the small demo-gif where there are two chairs correctly detected/segmented)

Hi There,
We are checking to see if you still need help on this, as this seems to be considerably old issue. Please update this issue with the latest information, code snippet to reproduce your issue and error you are seeing.
If we don't hear from you in the next 7 days, this issue will be closed automatically. If you don't need help on this issue any more, please consider closing this.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Mostafaghelich picture Mostafaghelich  路  3Comments

rakashi picture rakashi  路  3Comments

frankkloster picture frankkloster  路  3Comments

jacknlliu picture jacknlliu  路  3Comments

kamal4493 picture kamal4493  路  3Comments