Zdafeng / SwinFIR

Other
73 stars 4 forks source link

About your mixup method. #1

Closed Lacunainfo closed 9 months ago

Lacunainfo commented 10 months ago

the method 'mixup' you called, it seems like channel-shuffle.

Can you guide me what you exactly meant for?

def mixup(lq, gt, alpha=1.2):
    if random.random() < 0.5:
       return lq, gt

    v = np.random.beta(alpha, alpha)
    r_index = torch.randperm(lq.size(0)).to(gt.device)

    lq = v * lq + (1 - v) * lq[r_index, :]
    gt = v * gt + (1 - v) * gt[r_index, :]

    return lq, gt
Zdafeng commented 9 months ago

The dimension of input is [B, C, H, W], so 'mixup' is performed in batch dimension.