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)