Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Please help me on customizing training datasets #795

Closed
pvti opened this issue Feb 3, 2020 · 2 comments
Closed

Please help me on customizing training datasets #795

pvti opened this issue Feb 3, 2020 · 2 comments
Labels
documentation Problems about existing documentation or comments

Comments

@pvti
Copy link

pvti commented Feb 3, 2020

❓ How to use Detectron2

Hi guys, thanks for reading.
I'm currently working on instance segmentation with only one class "X" and I get troubles on training model.
I have a data set with n sample, each one is a pair of an original RGB image and a binary mask image.
I've read the docs very carefully: the Detectron2's official tutorial (Use custom datasets) and the Colab Notebook with the example on training ballon dataset. Also, I searched for code to transform binary-mask datasets to COCO-form dataset, like this
But I still can't handle my case. So I was wondering if you can give me some recommendations (is there any code available? what should I do?)
Below is a sample of my data: a pair of original image and a a binary mask segmented image.
original
mask

Any help is highly appreciated!

@ppwwyyxx ppwwyyxx added the documentation Problems about existing documentation or comments label Feb 3, 2020
@information-security
Copy link

information-security commented Feb 3, 2020

@pvtien96 You can use Canny algorithm to detect edges of your masks then get location of white pixels:

Unknown-2

import numpy as np
import cv2 as cv

img = cv.imread('PATH TO YOUR MASK IMAGE', 0)
edges = cv.Canny(img,100,200),
annotations = np.argwhere(edges == 255)

annotations contains X,Y location of your polygon. Keep in mind that this method works only if you have one object per image and there is no overlapping. In those cases you need to do more tweaking.

@ppwwyyxx
Copy link
Contributor

ppwwyyxx commented Feb 5, 2020

As our documentation says, you can provide per-pixel segmentation mask in COCO's RLE format.

You can convert a uint8 segmentation mask of 0s and 1s into an RLE by pycocotools.mask.encode(np.asarray(mask, order="F")). We'll add this to the docs as well.

@ppwwyyxx ppwwyyxx closed this as completed Feb 5, 2020
@ppwwyyxx ppwwyyxx added the usage label Feb 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Problems about existing documentation or comments
Projects
None yet
Development

No branches or pull requests

3 participants