Spaces:
Runtime error
Runtime error
import gradio as gr | |
from PIL import Image | |
demo_inf_ofa = gr.Interface.load(name="spaces/ICML2022/OFA") #"spaces/freddyaboulton/blocks_inputs") | |
#demo_inf_lama = gr.Interface.load(name="spaces/CVPR/lama-example") #gr.Blocks.load | |
#img = gr.Interface.load("spaces/multimodalart/latentdiffusion")(ent[0],'50','256','256','1',10)[0] | |
#assert demo_inf("Foo", "bar") == "Foo bar" | |
def get_lama(img1, img2): | |
Img1 = Image.open(img1) | |
Img2 = Image.open(img2) | |
img, mask = gr.Interface.load(name="spaces/CVPR/lama-example")(Img1, Img2, "automatic (U2net)") | |
return img | |
#def txt_fun(txt1, txt2): | |
# return demo_inf(txt1, txt2) | |
#original = Image.open("./c4.jpg") | |
#output_img_path = demo_inf("./c4.jpg", fn_index=1) | |
#output = Image.open(output_img_path) | |
#assert original.size == output.size | |
def img_fun1(img_in): | |
return demo_inf(img_in) #, fn_index=1) | |
#original = Image.open("./c4.jpg") | |
#output_img_path = demo_inf("./c4.jpg", fn_index=1) | |
#output = Image.open(output_img_path) | |
#assert original.size == output.size | |
def img_fun(img_in): | |
original = Image.open("./c4.jpg") | |
print("after line1") | |
output_img_path = demo_inf("./c4.jpg", fn_index=1) | |
print("after line1") | |
output = Image.open(output_img_path) | |
print("after line1") | |
return output | |
demo = gr.Blocks() | |
with demo: | |
gr.Markdown("<h1><center>Testing</center></h1>") | |
gr.Markdown( | |
"""Testing Inference for Gradio. Work in Progress.""" | |
) | |
with gr.Row(): | |
in_image = gr.Image(type='file') #(visible=False) type='numpy' | |
in_image_mask = gr.Image(type='file') #, source="canvas") #, visible=False) #type='numpy', | |
out_image = gr.outputs.Image(type='file') #(type='file') | |
#in_text1 = gr.Textbox() | |
#in_text2 = gr.Textbox() | |
#out_text = gr.Textbox() | |
b1 = gr.Button("Image Button") | |
#b2 = gr.Button("Text Button") | |
b1.click(get_lama,inputs=[in_image, in_image_mask], outputs=out_image) | |
#b2.click(txt_fun, inputs=[in_text1, in_text2], outputs=out_text) | |
#examples=examples | |
demo.launch(enable_queue=True, debug=True) |