abeja-inc / platform-template-image-segmentation

MIT License
0 stars 0 forks source link

Be careful when reading the output mask from Annotation tool #15

Open sandonair007 opened 5 years ago

sandonair007 commented 5 years ago

Motivation

Train a segmentation model on Platform, when dataset annotation is from ABEJA Annotation Tool.

Problem

Generally we use combined mask (multiple colors exist in one png image) as the target. Though we have pre-defined label-color map dict for the annotation job, mixed colors often appear along the margin of different color blocks, which results in unknown label ids when converting png to label array using PIL.Image.Palette. Finally the training ends up with errors like:

2019-10-09T19:56:12+09:00: /pytorch/aten/src/THCUNN/SpatialClassNLLCriterion.cu:103: void cunn_SpatialClassNLLCriterion_updateOutput_kernel(T *, T *, T *, long *, T *, int, int, int, int, int, long) [with T = float, AccumT = float]: block: [1,0,0], thread: [194,0,0] Assertion `t >= 0 && t < n_classes` failed.

Example

image The above image shows the original mask.

image

The white dots denote the pixels where mix color exists (new label id will be created.)

Solutions

keigohtr commented 5 years ago

I have confirmed the label image Annotation-tool outputs includes the mixed color because some label's area are over wrapped.

This situation is unnatural for a general segmentation dataset. I think they, Annotation-tool, should fix this.

toshilow commented 5 years ago

I researched about combined logic in annotation tool. it looks like the layers are correctly overcoated.

In Annotation Screen shot

スクリーンショット 2019-10-31 15 48 42

Convined image data 064426-d4685914-3a29-4af1-b849-883090540422

Zoom up image by drawing tool (Pixelmator Pro)

スクリーンショット 2019-10-31 15 59 26
sandonair007 commented 5 years ago

Thank you for the update. My example is from https://abeja-datalake-production.s3.amazonaws.com/3fa7-1888808746696/20191007/012627-0cebbeb0-d4d9-48ab-9518-293f14ff25a8?AWSAccessKeyId=ASIASVXDTXMFUXFWVE7T&Signature=XzQ0PiWeaUOxMe4GAuzJs2axo6o%3D&x-amz-security-token=AgoJb3JpZ2luX2VjEMX%2F%2F%2F%2F%2F%2F%2F%2F%2F%2FwEaDmFwLW5vcnRoZWFzdC0xIkcwRQIhAI%2B34S5fSN7u2hium9Jkul%2FnTdk3IVQX49vjyQ17wAORAiAddrf0qjES%2FsHvaVMwBw1xfKhvsmRK9oSttUF6c4jt9yqvAgjO%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F8BEAEaDDE4NDA4NzE5ODQ3NSIMbr%2B%2Bib2sQbBqUzDbKoMCt0wfWgvueSwZyEanElGDwPVS1xEiOR1nXzkqN9BjeSFtMDpRJ189RcJZ7KAEXWJZd2wor6QmSDIt6j7SZpc8gCUBXXRniZp8TkaR8%2F655n9EpAGszAtDjV%2BYZJh3UmPiI9dy86JkawhT8RPnl%2FtfGzHBPaUsPkvYTiXBZ0rB7XpiBFpAAZLWoN9%2BKmaQ30rKIB8Dsrn4Fr1lqh4VNSMjO12MydQPhEaX%2BujGBk2J8auAAKz7P9OEx66P%2BTBiU56jTFT8cNNxomlc0lcC2ngo3JRClQK4zXhFjKTNFTibKnKDNRixGf%2F0RnUjiqrAKP6s7L8LW6DkYAYHECrrT%2B8DZsWumjD40OntBTq0AcDu7jiBvsjL5u7LckIW%2FmJcBSZkM0oSLv9sOqhdzJD5D2VBzBWNZ%2Bt40ooBHpuCNDsrxjWJG5BzLAGnf8Z06Z%2BhzVY8odqcQDxYkIQTiGIDajn8nKZ7mhKMq9TL3hn%2Bd09orS7klK%2BQl%2FMuZiX9LT8tJVw5XFfKUrPOihXA0nStk9%2BdH3wNAowgU9TcwzjoE1ZY2z88kjK%2Fg1nyO6QDg6AMbaDV5JVMtqPx9mzIep8EToBk9Q%3D%3D&Expires=1572510555

| organization_id | 1815063019817 | | datalake_channel_id | 1888808746696 | | file_id | 20191007T012627-0cebbeb0-d4d9-48ab-9518-293f14ff25a8 |