Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Update lpips.py
copy 'normalize_tensor' function from 'lpips/__init__.py', figure 'NameError: name 'normalize_tensor' is not defined' ERROR while run '
  • Loading branch information
samggggflynn authored Oct 11, 2023
commit a818cadf6cce854c51b6f0fa2e96aa8c2b011522
3 changes: 3 additions & 0 deletions third_parties/lpips/lpips.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@

from . import *

def normalize_tensor(in_feat,eps=1e-10):
norm_factor = torch.sqrt(torch.sum(in_feat**2,dim=1,keepdim=True))
return in_feat/(norm_factor+eps)

def spatial_average(in_tens, keepdim=True):
return in_tens.mean([2,3],keepdim=keepdim)
Expand Down