Spaces:
Build error
Build error
simayhosmeyve
commited on
Commit
•
7848c2f
1
Parent(s):
58cb8e5
Update app.py
Browse files
app.py
CHANGED
@@ -490,27 +490,6 @@ plt.show()
|
|
490 |
# return psnr
|
491 |
|
492 |
def result(Input,Choice,Step):
|
493 |
-
if Choice=="Coloring":
|
494 |
-
pre_trained = tf.keras.models.load_model("gradio_pix2pix.h5")
|
495 |
-
size0 = Input.shape[0]
|
496 |
-
size1 = Input.shape[1]
|
497 |
-
start = Input
|
498 |
-
Input = cv2.resize(Input, (256,256), interpolation = cv2.INTER_AREA)
|
499 |
-
Input = cv2.cvtColor(Input , cv2.COLOR_BGR2GRAY)
|
500 |
-
Input = np.array(Input).reshape(1,256,256,1)
|
501 |
-
prediction = pre_trained(Input,training=True)
|
502 |
-
Input = prediction[0]
|
503 |
-
Input = (Input+1)*127.5
|
504 |
-
Input = np.uint8(Input)
|
505 |
-
Input = cv2.resize(Input, (size1,size0), interpolation = cv2.INTER_AREA)
|
506 |
-
finish = Input
|
507 |
-
mse = np.mean((start - finish) ** 2)
|
508 |
-
MAX = np.iinfo(start.dtype).max
|
509 |
-
if mse == 0:
|
510 |
-
Psnr = 100
|
511 |
-
else:
|
512 |
-
Psnr = 20 * math.log10(MAX / math.sqrt(mse))
|
513 |
-
return Input,Psnr
|
514 |
|
515 |
if Choice=="Indoor-Coloring":
|
516 |
if Step == 1:
|
@@ -541,7 +520,14 @@ def result(Input,Choice,Step):
|
|
541 |
return Input,Psnr
|
542 |
|
543 |
if Choice=="Outdoor-Coloring":
|
544 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
545 |
size0 = Input.shape[0]
|
546 |
size1 = Input.shape[1]
|
547 |
start = Input
|
@@ -583,6 +569,6 @@ def result(Input,Choice,Step):
|
|
583 |
|
584 |
import gradio as gr
|
585 |
|
586 |
-
iface = gr.Interface(fn=result, inputs=[gr.inputs.Image(type="numpy",image_mode="RGB"),gr.inputs.Radio(
|
587 |
,css=""" body {background-color: rgba(127,191,63,0.48)} """,title="Image Enhancement",article=""" <a href="https://docs.google.com/document/d/19k6dyR5x_hd1M0yoU8i49dlDWvFmtnBT/edit?usp=sharing&ouid=115743073712072785012&rtpof=true&sd=true" download="example.docx"><img src="https://img.icons8.com/external-itim2101-lineal-color-itim2101/64/000000/external-article-blogger-and-influencer-itim2101-lineal-color-itim2101-1.png" alt="Article"></a>""",examples=[["dog.jpg","Coloring"],["woman.png","Coloring"]])
|
588 |
iface.launch(debug="True",show_tips="True",inbrowser=True)
|
|
|
490 |
# return psnr
|
491 |
|
492 |
def result(Input,Choice,Step):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
493 |
|
494 |
if Choice=="Indoor-Coloring":
|
495 |
if Step == 1:
|
|
|
520 |
return Input,Psnr
|
521 |
|
522 |
if Choice=="Outdoor-Coloring":
|
523 |
+
|
524 |
+
if Step == 1:
|
525 |
+
pre_trained = tf.keras.models.load_model("outdoor_1.h5")
|
526 |
+
if Step == 2:
|
527 |
+
pre_trained = tf.keras.models.load_model("outdoor_2.h5")
|
528 |
+
if Step == 3:
|
529 |
+
pre_trained = tf.keras.models.load_model("outdoor_3.h5")
|
530 |
+
|
531 |
size0 = Input.shape[0]
|
532 |
size1 = Input.shape[1]
|
533 |
start = Input
|
|
|
569 |
|
570 |
import gradio as gr
|
571 |
|
572 |
+
iface = gr.Interface(fn=result, inputs=[gr.inputs.Image(type="numpy",image_mode="RGB"),gr.inputs.Radio("Indoor-Coloring","Outdoor-Coloring","Enhancement","Repair","Repair and Color"]),gr.inputs.Slider(minimum=1,maximum=3,default=3,step=1)], outputs=[gr.outputs.Image( type="auto", label="Output"),gr.outputs.Textbox(type="number",label="Psnr")],theme="grass",live=True
|
573 |
,css=""" body {background-color: rgba(127,191,63,0.48)} """,title="Image Enhancement",article=""" <a href="https://docs.google.com/document/d/19k6dyR5x_hd1M0yoU8i49dlDWvFmtnBT/edit?usp=sharing&ouid=115743073712072785012&rtpof=true&sd=true" download="example.docx"><img src="https://img.icons8.com/external-itim2101-lineal-color-itim2101/64/000000/external-article-blogger-and-influencer-itim2101-lineal-color-itim2101-1.png" alt="Article"></a>""",examples=[["dog.jpg","Coloring"],["woman.png","Coloring"]])
|
574 |
iface.launch(debug="True",show_tips="True",inbrowser=True)
|