File size: 1,133 Bytes
7ed6fbe
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
43f78ff
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import gradio as gr
import numpy as np
from playform import playform,playform_load 


@playform
def sepia(input_img,url_params):
    #print('inside fn',url_params)
    sepia_filter = np.array([
        [0.393, 0.769, 0.189], 
        [0.349, 0.686, 0.168], 
        [0.272, 0.534, 0.131]
    ])
    sepia_img = input_img.dot(sepia_filter.T)
    sepia_img /= sepia_img.max()
    return sepia_img,url_params

with gr.Blocks() as demo:
    
    #code block needed to get url parameters
    url_params = gr.JSON({}, visible=False, label="URL Params")
    demo.load(lambda x: x,inputs = [url_params],outputs=[url_params],_js=playform_load)
    #end code block needed to get url parameters
     

    with gr.Row():
        with gr.Column():
            img_input = gr.Image(shape=(200, 200))
        with gr.Column():
            img_output = gr.Image(shape=(200, 200))
    
    btn = gr.Button("submit")
    btn.click(fn=sepia, inputs=[img_input, url_params], outputs=[img_output,url_params])
    #btn.click(fn=sepia, inputs=img_input, outputs=img_output)



if __name__=='__main__':
    demo.launch(share=False,debug=True,inline= False)