lhoyer / DAFormer

[CVPR22] Official Implementation of DAFormer: Improving Network Architectures and Training Strategies for Domain-Adaptive Semantic Segmentation
Other
466 stars 92 forks source link

problem of ‘def get_rare_class_sample’ #36

Closed Xz-Alan closed 2 years ago

Xz-Alan commented 2 years ago

Thanks for your wonderful work, and Rare Class Sampling is a very good idea. But in get_rare_class_sample, idx i1 in the for loop is not updated, what is the significance of 10 loops? Is the code of Sample a new Random Crop missing in the loop?

I would appreciate it if you could answer it.

https://github.com/lhoyer/DAFormer/blob/9d17603046f76303fd8711173dcd13ae69ee547c/mmseg/datasets/uda_dataset.py#L85-L107

lhoyer commented 2 years ago

Thanks for your interest in our work. As explained in the comment of the referenced code self.source[i1] samples a new crop from i1. The cropping is included in the data loading pipeline, which is applied when calling self.source[i1]. Please, have a look at https://github.com/lhoyer/DAFormer/blob/9d17603046f76303fd8711173dcd13ae69ee547c/mmseg/datasets/custom.py#L184 for more details.

gaowq2017 commented 2 years ago

Thanks for your interest in our work. As explained in the comment of the referenced code self.source[i1] samples a new crop from i1. The cropping is included in the data loading pipeline, which is applied when calling self.source[i1]. Please, have a look at

https://github.com/lhoyer/DAFormer/blob/9d17603046f76303fd8711173dcd13ae69ee547c/mmseg/datasets/custom.py#L184

for more details.

I directly cancel these line of code when not use crop enhance method as follow: image Its OK? or others? Thanks

lhoyer commented 2 years ago

If you comment out these lines, the image is chosen to contain a rare class. However, there is no guarantee that the random crop of the image will contain this rare class as also a crop of the image that does not contain the rare class can be sampled.