divamgupta / image-segmentation-keras

Implementation of Segnet, FCN, UNet , PSPNet and other models in Keras.
https://divamgupta.com/image-segmentation/2019/06/06/deep-learning-semantic-segmentation-keras.html
MIT License
2.91k stars 1.16k forks source link

annotating data set #224

Open temi92 opened 4 years ago

temi92 commented 4 years ago

Hi, Is there support for VOC data set or COCO dataset when annotating images using tools like labelme Kind Regards.

jspaezp commented 4 years ago

Hello @temi92

I was having the same question a while ago, I was not able to find a solution for it but ended up hacking my way into it ...

labelme_json_to_dataset {name_of_my_dataset_annotations}.json 

this script ... source code here https://github.com/wkentaro/labelme/blob/master/labelme/cli/json_to_dataset.py

which generates 4 files

  1. img.png
  2. label.png
  3. label_viz.png
  4. label_names.png

Then, i read the label.png, I realized the masks were encoded in the red channel (which is not recognized by this package) so I had to convert them to grayscale, normalize the value (so the class has a value of 1 and saved the grayscale image as rgb again.

This process gave me images usable for the command line version of this (amazing) package.

Nonetheless, in retrospect ... I feel like the best way to do this would have been to write my own function and use the internal functions that carry out the mask generation.

This function is likely what you want to use after parsing the json: https://github.com/wkentaro/labelme/blob/5b9be06ee1ad75165a4584a9609600e570bcdf5f/labelme/utils/shape.py#L19

I guess the question would be if it would be in the interest of the maintainer @divamgupta to have such function implemented and added to this package ... something that takes as an imput either a coco/labelme json and outputs the masks in a keras-retinanet compatible/expected format.

Kindest wishes, Sebastian

jspaezp commented 4 years ago

An additional workaround is show here: https://github.com/divamgupta/image-segmentation-keras/issues/117

temi92 commented 4 years ago

hi @jspaezp thanks for the response!!. after doing some more research, i came across this https://github.com/wkentaro/labelme/tree/master/examples/semantic_segmentation it seems it supports input as labelme json (gotten after image annotation) and outputs .png masks which am hoping can then be used with your package perhaps. I am happy to create a PR that perhaps potentially supports mask generation.

MikeMpapa commented 3 years ago

@temi92 did that work after all?