LiheYoung / UniMatch

[CVPR 2023] Revisiting Weak-to-Strong Consistency in Semi-Supervised Semantic Segmentation
https://arxiv.org/abs/2208.09910
MIT License
453 stars 59 forks source link

For domain adaptation #71

Closed tanveer6715 closed 1 year ago

tanveer6715 commented 1 year ago

I am using UniMatch for domain adaptation according to your above suggestions as mentioned in #55 . But I am facing problems and errors.

  1. As you said we should cutmix labeled data (source domain) on unlabeled dataset (target domain) but I didnt understand it should be done before training or during training. In the UniMatch, from the unlabeled data cutmix box is obtained here.

https://github.com/LiheYoung/UniMatch/blob/583e32492b0ac150e0946b65864d2dcc642220b8/dataset/semi.py#L49

  1. Then during the training the unlabeled is cutmixed here. Will you guide how to obtain cutmix from label data and cutmixed with unlabeled data as in semisupervised learning label and unlabeled data is processed and trained separately. Will it be done before or during the training. Also cutmixed of unlabeled data on the unlabeled data as UniMatch can affect the model performance for domain adaptation.

https://github.com/LiheYoung/UniMatch/blob/583e32492b0ac150e0946b65864d2dcc642220b8/unimatch.py#L142

LiheYoung commented 1 year ago

In domain adaptation, CutMix between labeled and unlabeled images is done before training, the same as semi-supervised learning. The only difference is that you should replace the img_u_s_mix with img_x (the label is directly from GT label, there is no need to predict on img_u_w_mix).

tanveer6715 commented 1 year ago

Sorry to bother you again but it is confusing as img_u_s_mix is corresponded to the unlabeled dataloader as here:

https://github.com/LiheYoung/UniMatch/blob/583e32492b0ac150e0946b65864d2dcc642220b8/unimatch.py#L123C1-L133C53

The model predict on the weakly augmented unlabeled image. Then how img_x will work here for domain adaptation?

https://github.com/LiheYoung/UniMatch/blob/583e32492b0ac150e0946b65864d2dcc642220b8/unimatch.py#L135C1-L172C88

LiheYoung commented 1 year ago

You can check this paper first: https://github.com/vikolss/DACS, for the methodology of mixing labeled and unlabeled images.

Briefly, we previously mix img_u_s and img_u_s_mix, right? Now you need to mix img_u_s and img_x instead. The img_u_s_mix and img_u_w_mix are no longer required. As for the pseudo label of mixed img_u_s and img_x, its unlabeled region is predicted on img_u_w by our model, and the labeled region directly borrows GT label from mask_x.

tanveer6715 commented 1 year ago

Thank you for your quick and brief explanation. Now I got some idea for domain adaptation. I will ask further if I need some details but I hope it helps.

LiheYoung commented 1 year ago

Closed for inactivity.