simayhosmeyve commited on
Commit
6dfc4e1
1 Parent(s): f4620cc

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -12
app.py CHANGED
@@ -190,14 +190,6 @@ import numpy as np
190
  #contrast = cv2.imread("/content/drive/MyDrive/ColabNotebooks/enhance/After_clahe_equalizer_with_gamma.png",0)
191
 
192
  #print(original.dtype)
193
- def psnr(img1, img2, MAX=None):
194
- if MAX is None:
195
- MAX = np.iinfo(img1.dtype).max
196
- mse = np.mean((img1 - img2) ** 2)
197
- if mse == 0:
198
- return 100
199
- return 20 * math.log10(MAX / math.sqrt(mse))
200
-
201
 
202
  #db = psnr(original, contrast)
203
  #print(db)
@@ -522,11 +514,20 @@ def ssim(original,predict):
522
  ssim = tf.image.ssim(original, predict, max_val=1.0, filter_size=11, filter_sigma=1.5, k1=0.01, k2=0.03)
523
  return ssim
524
 
525
- def psnr(Input,Choice):
526
- Output = result(Input,Choice)
527
- psnr = tf.image.psnr(Input, Output, max_val=255)
528
- return psnr
529
 
 
 
 
 
 
 
 
 
 
530
  #lst = cv2.imread('/content/drive/MyDrive/ColabNotebooks/enhance/low-sat.jpg')
531
  #r = result(lst)
532
  #cv2.imshow(r)
 
190
  #contrast = cv2.imread("/content/drive/MyDrive/ColabNotebooks/enhance/After_clahe_equalizer_with_gamma.png",0)
191
 
192
  #print(original.dtype)
 
 
 
 
 
 
 
 
193
 
194
  #db = psnr(original, contrast)
195
  #print(db)
 
514
  ssim = tf.image.ssim(original, predict, max_val=1.0, filter_size=11, filter_sigma=1.5, k1=0.01, k2=0.03)
515
  return ssim
516
 
517
+ #def psnr(Input,Choice):
518
+ # Output = result(Input,Choice)
519
+ # psnr = tf.image.psnr(Input, Output, max_val=255)
520
+ # return psnr
521
 
522
+ def psnr(Input, Choice, MAX=None):
523
+ Output = result(Input,Choice)
524
+ if MAX is None:
525
+ MAX = np.iinfo(Input.dtype).max
526
+ mse = np.mean((Input - Output) ** 2)
527
+ if mse == 0:
528
+ return 100
529
+ return 20 * math.log10(MAX / math.sqrt(mse))
530
+
531
  #lst = cv2.imread('/content/drive/MyDrive/ColabNotebooks/enhance/low-sat.jpg')
532
  #r = result(lst)
533
  #cv2.imshow(r)