Spaces:
Build error
Build error
simayhosmeyve
commited on
Commit
•
3e0dffb
1
Parent(s):
6065091
Update app.py
Browse files
app.py
CHANGED
@@ -481,7 +481,15 @@ plt.show()
|
|
481 |
#plt.imsave(name,pre)
|
482 |
#cv2.imshow(pre)
|
483 |
|
484 |
-
def
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
485 |
if Choice=="Coloring":
|
486 |
pre_trained = tf.keras.models.load_model("gradio_pix2pix.h5")
|
487 |
size0 = Input.shape[0]
|
@@ -490,11 +498,12 @@ def result(Input,Choice,Step=300):
|
|
490 |
Input = cv2.cvtColor(Input , cv2.COLOR_BGR2GRAY)
|
491 |
Input = np.array(Input).reshape(1,256,256,1)
|
492 |
prediction = pre_trained(Input,training=True)
|
493 |
-
|
494 |
-
|
495 |
-
|
496 |
-
|
497 |
-
|
|
|
498 |
|
499 |
if Choice=="Enhancement":
|
500 |
pre_trained2 = tf.keras.models.load_model("gradio_pix2pix.h5")
|
@@ -510,15 +519,6 @@ def result(Input,Choice,Step=300):
|
|
510 |
Input = cv2.resize(Input, (size1,size0), interpolation = cv2.INTER_AREA)
|
511 |
return Input
|
512 |
|
513 |
-
def ssim(original,predict):
|
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 |
-
print(psnr)
|
521 |
-
return psnr
|
522 |
|
523 |
#lst = cv2.imread('/content/drive/MyDrive/ColabNotebooks/enhance/low-sat.jpg')
|
524 |
#r = result(lst)
|
|
|
481 |
#plt.imsave(name,pre)
|
482 |
#cv2.imshow(pre)
|
483 |
|
484 |
+
def ssim(original,predict):
|
485 |
+
ssim = tf.image.ssim(original, predict, max_val=1.0, filter_size=11, filter_sigma=1.5, k1=0.01, k2=0.03)
|
486 |
+
return ssim
|
487 |
+
|
488 |
+
def psnr(Input,Output,Choice):
|
489 |
+
psnr = tf.image.psnr(Input, Output, max_val=255)
|
490 |
+
return psnr
|
491 |
+
|
492 |
+
def result(Input,Choice):
|
493 |
if Choice=="Coloring":
|
494 |
pre_trained = tf.keras.models.load_model("gradio_pix2pix.h5")
|
495 |
size0 = Input.shape[0]
|
|
|
498 |
Input = cv2.cvtColor(Input , cv2.COLOR_BGR2GRAY)
|
499 |
Input = np.array(Input).reshape(1,256,256,1)
|
500 |
prediction = pre_trained(Input,training=True)
|
501 |
+
Output = prediction[0]
|
502 |
+
Output = (Output+1)*127.5
|
503 |
+
Output = np.uint8(Output)
|
504 |
+
Output = cv2.resize(Output, (size1,size0), interpolation = cv2.INTER_AREA)
|
505 |
+
psnr = psnr(Input,Output,"Coloring")
|
506 |
+
return Output,psnr
|
507 |
|
508 |
if Choice=="Enhancement":
|
509 |
pre_trained2 = tf.keras.models.load_model("gradio_pix2pix.h5")
|
|
|
519 |
Input = cv2.resize(Input, (size1,size0), interpolation = cv2.INTER_AREA)
|
520 |
return Input
|
521 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
522 |
|
523 |
#lst = cv2.imread('/content/drive/MyDrive/ColabNotebooks/enhance/low-sat.jpg')
|
524 |
#r = result(lst)
|