MCPcopy Create free account
hub / github.com/MiniMax-AI/VTP / LPIPS

Class LPIPS

tools/test_reconstruction_hf.py:65–79  ·  view source on GitHub ↗

LPIPS metric wrapper.

Source from the content-addressed store, hash-verified

63
64
65class LPIPS:
66 """LPIPS metric wrapper."""
67
68 def __init__(self, device='cuda'):
69 self.device = device
70 self.model = LPIPS_VTP().to(device).eval()
71
72 def __call__(self, img1: torch.Tensor, img2: torch.Tensor) -> torch.Tensor:
73 """Calculate LPIPS between two images.
74
75 Args:
76 img1, img2: Images in range [-1, 1] with shape (B, C, H, W)
77 """
78 with torch.no_grad():
79 return self.model(img1, img2)
80
81
82def get_ssim_metric(device):

Callers 1

test_reconstructionFunction · 0.70

Calls

no outgoing calls

Tested by 1

test_reconstructionFunction · 0.56