NVIDIA / semantic-segmentation

Nvidia Semantic Segmentation monorepo
BSD 3-Clause "New" or "Revised" License
1.76k stars 388 forks source link

Custom Dataset and meaning of centroid file #106

Open GuessWhosBack opened 3 years ago

GuessWhosBack commented 3 years ago

Hey, I was trying to adapt the code to train with my dataset. My dataset at the moment is rather small and contains only 6 classes. I wrote my own dataloader similar to the one from mapillary. It all works fine until I come across the centroid file. It works just running without it (just setting class_uniform_pct: 0). Thats why I wanted to ask if someone can explain the meaning of this file in a few sentences?

The apparent problem I ran into is that because of my dataset being small there a some classes where the centroid file has no centroids for: Found 4 centroids while it should be 6. Is there a way to adjust building this file to cover all classes? ( maybe setting class_uniform_til to something small like 256)

I have around 500 Pictures roughly 860x480 containing 6 classes.

ajtao commented 3 years ago

The centroid file is something that's created once for a given dataset for the purpose of uniform class sampling. Uniform sampling (enabled with class_uniform_pct > 0) asks that every class be sampled by the dataloader equally. In order to do this, we have to build a centroid file which describes, for each file, what classes are contained in a given image, and where the centroid for those classes is. If you have created your dataloader using the mapillary dataloader as a guide, then everything should work. The only thing i might suggest is changing class_uniform_tile to 860x480. The tile size means how many sets of distinct regions/hotspots to consider in a given image. In cityscapes, the tile size is 1024, which results in 2 tiles for 2k x 1k images.

GuessWhosBack commented 3 years ago

Thanks, for the quick response and clarification. I have resolved the initial issue which was actually in my conversion from rgb labels to grayscale. I have changed the class_uniform_tile according to your suggestion and it works just fine. Thank you!

GuessWhosBack commented 3 years ago

Hey I am not sure if this is a Bug or not but in this line https://github.com/NVIDIA/semantic-segmentation/blob/f535ad7e9490edd95b8eadfc766be1bb38381ed0/datasets/uniform.py#L257 building the centroid file is called without the class_uniform_tile argument which basically means uniform file may be given a different name but is always build with 1024 (https://github.com/NVIDIA/semantic-segmentation/blob/f535ad7e9490edd95b8eadfc766be1bb38381ed0/datasets/uniform.py#L189) maybe this got fixed already but cost me some time to figure out..

Raj-08 commented 2 years ago

definately a bug !

Raj-08 commented 2 years ago

what was tile size you used ? I am now calling the argument tile_size=600 , my image size is 800 * 600

How did you use it ?

Raj-08 commented 2 years ago

Hi @GuessWhosBack