Spaces:
Runtime error
Runtime error
Commit
·
0e4499d
1
Parent(s):
2fdbee9
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,76 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
import re
|
3 |
+
import numpy as np
|
4 |
+
import torch
|
5 |
+
import os
|
6 |
+
from gradio_client import Client
|
7 |
+
|
8 |
+
client = Client(os.environ['DEMO_URL'])
|
9 |
+
def run(image_input1,image_input2,image_input3,
|
10 |
+
audio_input1,audio_input2,audio_input3,instruction,
|
11 |
+
alpha,h0,h1,h2,norm,refinement,num_steps=50,seed=0):
|
12 |
+
return client(image_input1,image_input2,image_input3,
|
13 |
+
audio_input1,audio_input2,audio_input3,instruction,
|
14 |
+
alpha,h0,h1,h2,norm,refinement,num_steps=50,seed=0)
|
15 |
+
|
16 |
+
#demo = gr.Interface(fn=greet, inputs="text", outputs="text")
|
17 |
+
examples = [
|
18 |
+
# [
|
19 |
+
# "assets/demo/an antique shop.jpg",None,None,
|
20 |
+
# "assets/demo/clock ticking.wav",None,None,
|
21 |
+
# 'add [audio1] to [image1]',
|
22 |
+
# 1.0,0.4,0.6,0.4,
|
23 |
+
# 20,0.3,25
|
24 |
+
# ],
|
25 |
+
]
|
26 |
+
|
27 |
+
if __name__ == "__main__":
|
28 |
+
with gr.Blocks() as demo:
|
29 |
+
gr.Markdown("InstructAny2Any")
|
30 |
+
gr.Markdown("Input Image")
|
31 |
+
with gr.Row():
|
32 |
+
image_input1 = gr.Image(type='filepath')
|
33 |
+
image_input2 = gr.Image(type='filepath')
|
34 |
+
image_input3 = gr.Image(type='filepath')
|
35 |
+
gr.Markdown("Input Audio")
|
36 |
+
with gr.Row():
|
37 |
+
audio_input1 = gr.Audio(type='filepath')
|
38 |
+
audio_input2 = gr.Audio(type='filepath')
|
39 |
+
audio_input3 = gr.Audio(type='filepath')
|
40 |
+
gr.Markdown("Instruction")
|
41 |
+
with gr.Row():
|
42 |
+
instruction = gr.Textbox()
|
43 |
+
with gr.Row():
|
44 |
+
alpha = gr.Slider(minimum=0.0,maximum=1.0,value=1.0,step=0.05,label='alpha')
|
45 |
+
refinement = gr.Slider(minimum=0.0,maximum=1.0,value=0.3,step=0.1,label='refinement')
|
46 |
+
seed = gr.Slider(minimum=0.0,maximum=4096.0,value=0,step=1.0,label='seed')
|
47 |
+
with gr.Row():
|
48 |
+
norm = gr.Slider(minimum=0.0,maximum=20.0,value=20.0,step=1.0,label='norm')
|
49 |
+
num_steps = gr.Slider(minimum=10.0,maximum=50.0,value=25.0,step=1.0,label='steps')
|
50 |
+
h0 = gr.Slider(minimum=0.0,maximum=3.0,value=0.4,step=0.05,label='h0')
|
51 |
+
h1 = gr.Slider(minimum=0.0,maximum=3.0,value=0.6,step=0.05,label='h1')
|
52 |
+
h2 = gr.Slider(minimum=0.0,maximum=3.0,value=0.4,step=0.05,label='h2')
|
53 |
+
with gr.Row():
|
54 |
+
launch_button = gr.Button("Run")
|
55 |
+
with gr.Row():
|
56 |
+
out_text = gr.Text(interactive=False)
|
57 |
+
with gr.Row():
|
58 |
+
out_img = gr.Image(interactive=False)
|
59 |
+
with gr.Row():
|
60 |
+
gr.Examples(
|
61 |
+
examples=examples,
|
62 |
+
inputs=[
|
63 |
+
image_input1,image_input2,image_input3,
|
64 |
+
audio_input1,audio_input2,audio_input3,instruction,
|
65 |
+
alpha,h0,h1,h2,norm,refinement,num_steps
|
66 |
+
],
|
67 |
+
# outputs=result,
|
68 |
+
# fn=process_example,
|
69 |
+
# cache_examples=CACHE_EXAMPLES,
|
70 |
+
)
|
71 |
+
launch_button.click(run,inputs=[
|
72 |
+
image_input1,image_input2,image_input3,
|
73 |
+
audio_input1,audio_input2,audio_input3,instruction,
|
74 |
+
alpha,h0,h1,h2,norm,refinement,num_steps
|
75 |
+
],outputs=[out_text,out_img])
|
76 |
+
demo.launch(show_api=False,share=True)
|