File size: 947 Bytes
db12400
b127fd6
bbf9a90
 
db12400
 
 
 
 
 
 
 
 
 
 
 
487cf8b
 
 
f90f58c
e6d116a
 
db12400
0d8ee1e
db12400
 
 
e6d116a
f90f58c
db12400
 
 
 
 
 
e6d116a
4a81b75
f90f58c
db12400
 
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
40
41
import gradio as gr
import os
token = os.environ.get('HF_TOKEN')
pix2pix = gr.Blocks.load(name="spaces/fffiloni/instruct-pix2pix-clone", api_key=token)

def infer(prompt,image):
    result = pix2pix(prompt,
        5.5,
        1.5,
        image,
        15,
        "",
        512,
        512,
        0,
        fn_index=0)
    print(result)
    print(result[0])
    print(result[0][0])
    # return "done"
    images = [os.path.join(result[0], img) for img in os.listdir(result[0])]
    return images[0]

with gr.Blocks() as demo:
    with gr.Column():
        prompt = gr.Textbox(placeholder="enter prompt")
        image = gr.Image(source="upload", type="filepath")
        image_out = gr.Image()
        #text_out = gr.Textbox()
        submit_btn = gr.Button("go")

    inputs = [
        prompt,
        image
    ]
    outputs = [image_out]
    #outputs = [text_out]
    submit_btn.click(infer, inputs, outputs)

demo.launch().queue()