当前位置:   article > 正文

计算LPIPS

计算lpips
import lpips
import os
import utils_image as util
loss_fn_alex = lpips.LPIPS(net='vgg')#也可以选择alex
inputpath = r'E:\testresult'#(alex:0.1009) (vgg:0.1879)
gtpath=r'F:\eval_normal'
imgs=os.listdir(path)
losssum=0.0
count=0
for img in imgs:
    ig=util.imread_uint(inputpath +'/'+img,3)
    input=util.uint2tensor3(ig)
    #print(path+'/'+img,pathgt + '/normal' + img[3:])
    gt = util.imread_uint(gtpath+ '/' + img, 3)
    #gt = util.imread_uint(pathgt + '/normal' + img[3:], 3)
    input = util.uint2tensor3(ig)
    gt = util.uint2tensor3(gt)
    loss=loss_fn_alex(input,gt)
    losssum=losssum+loss
    count+=1
    print(img,loss.item())
print(losssum/count)
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/菜鸟追梦旅行/article/detail/192919
推荐阅读
相关标签
  

闽ICP备14008679号