| 44 | return self.lpips(torch.FloatTensor(img1).to(self.device), torch.FloatTensor(img2).to(self.device)).item() |
| 45 | |
| 46 | class fid_wrapper: |
| 47 | def __init__(self): |
| 48 | self.device = "cuda" if torch.cuda.is_available() else "cpu" |
| 49 | self.fid = FrechetInceptionDistance(feature=64) |
| 50 | |
| 51 | @torch.no_grad() |
| 52 | def __call__(self, pred_imgs, gt_imgs): |
| 53 | self.fid.reset() |
| 54 | self.fid.update(torch.tensor(rearrange(gt_imgs, 'n w h c -> n c w h')), real=True) |
| 55 | self.fid.update(torch.tensor(rearrange(pred_imgs, 'n w h c -> n c w h')), real=False) |
| 56 | return self.fid.compute().item() |
| 57 | |
| 58 | def pair_wise_score(pred_imgs, gt_imgs, metric, is_sucess): |
| 59 | # pred_imgs: n, w, h, 3 |
no outgoing calls
no test coverage detected