BBBBchan / CorrMatch

Official code for "CorrMatch: Label Propagation via Correlation Matching for Semi-Supervised Semantic Segmentation"
128 stars 8 forks source link

关于代码中的Region Propagation部分 #11

Closed qingy735 closed 6 months ago

qingy735 commented 6 months ago

你好,请问代码中关于Region Propagation部分的实现在哪个地方呢?这部分理解不是很清楚,希望能告知

BBBBchan commented 6 months ago

您好,感谢您的关注。 Region Propagation的实现在corrmatch.py中的209-223行,具体实现如下所示:

for img_idx in range(b_sample):
        for segment_idx in range(c_sample):

            segment = segments[img_idx, segment_idx]
            segment_ori = corr_map_u_w_cutmixed1[img_idx, segment_idx]
            high_conf_ratio = torch.sum(segment)/torch.sum(segment_ori)
            if torch.sum(segment) == 0 or high_conf_ratio < thresh_global:
                continue
            unique_cls, count = torch.unique(mask_u_w_cutmixed1[img_idx][segment==1], return_counts=True)

            if torch.max(count) / torch.sum(count) > thresh_global:
                top_class = unique_cls[torch.argmax(count)]
                mask_u_w_cutmixed1[img_idx][segment_ori==1] = top_class
                conf_fliter_u_w_without_cutmix[img_idx] = conf_fliter_u_w_without_cutmix[img_idx] | segment_ori
    conf_fliter_u_w_without_cutmix = conf_fliter_u_w_without_cutmix | conf_fliter_u_w
qingy735 commented 6 months ago

十分感谢