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

how to configure image annotation that use RGB code as class identifier #383

Open
ramdhan1989 opened this issue Aug 8, 2020 · 0 comments

Comments

@ramdhan1989
Copy link

ramdhan1989 commented Aug 8, 2020

my image annotation is in RGB color. notebook example in this repo is using label encoding image (CamVid dataset). I got problem when trying to convert to label encoding image so that I can continue to the next code hopefully without any further code modification.
this is the example of label annotation :
https://drive.google.com/file/d/1h1Ezc1QobHVlttF3P53yH2V8e5bMq8yL/view?usp=sharing

this is the code
CLASSES = ['pipeline','person','road','house','car','cargo truck','oil truck','motorcycle'] #all clasess
label_values = [[255, 0, 0],[0, 0, 255],[255, 255, 0],[0, 255, 255],[255, 0, 255],[128, 0, 128],[128, 128, 0],[0, 0, 128]]
classes = ['pipeline','person','road','house','car'] #select only certain classes
class_values = [CLASSES.index(cls.lower()) for cls in classes]
mask = cv2.cvtColor(cv2.imread('.../example_annot.png'), cv2.COLOR_BGR2RGB)
semantic_map = []
for colour in [label_values[index] for index in class_values ]:
equality = np.equal(mask, colour)
class_map = np.all(equality, axis = -1)
semantic_map.append(class_map)
mask2 = np.float32(np.stack(semantic_map, axis=-1))
mask3 = np.argmax(mask2, axis = -1)
masks = [(mask3 == v) for v in class_values]
mask4 = np.stack(masks, axis=-1).astype('float')

mask is shown below
Duri_D1F1_segment_2_209

let's focus on pipeline class (red color in original image) as shown by mask2 (plt.imshow(mask2[:,:,0])) below
image

now check label encoding image result as shown by mask3
image

the pipeline object is gone !
recheck from mask4 for pipeline class
image

mask4[:,:,0] now become background rather than pipeline class

I don't understand what heppened here. is there anyone can explain it ?
I would like to have advice also how to deal with image annot that use RGB code as class identifier that easly to adapt with whole script provided in this repo ?

thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant