Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -7,9 +7,10 @@ import time
|
|
7 |
import numpy as np
|
8 |
|
9 |
#vae = AutoencoderKL.from_pretrained("madebyollin/sdxl-vae-fp16-fix", torch_dtype=torch.float16)
|
10 |
-
|
11 |
-
|
12 |
-
clip_slider = CLIPSliderXL(
|
|
|
13 |
|
14 |
@spaces.GPU
|
15 |
def generate(slider_x, slider_y, prompt, seed, iterations, steps,
|
@@ -91,27 +92,51 @@ with gr.Blocks(css=css) as demo:
|
|
91 |
avg_diff_y_1 = gr.State()
|
92 |
avg_diff_y_2 = gr.State()
|
93 |
|
94 |
-
with gr.
|
95 |
-
with gr.
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
115 |
|
|
|
116 |
if __name__ == "__main__":
|
117 |
demo.launch()
|
|
|
7 |
import numpy as np
|
8 |
|
9 |
#vae = AutoencoderKL.from_pretrained("madebyollin/sdxl-vae-fp16-fix", torch_dtype=torch.float16)
|
10 |
+
pipe = StableDiffusionXLPipeline.from_pretrained("sd-community/sdxl-flash").to("cuda", torch.float16)
|
11 |
+
pipe.scheduler = EulerDiscreteScheduler.from_config(pipe.scheduler.config)
|
12 |
+
clip_slider = CLIPSliderXL(pipe, device=torch.device("cuda"))
|
13 |
+
|
14 |
|
15 |
@spaces.GPU
|
16 |
def generate(slider_x, slider_y, prompt, seed, iterations, steps,
|
|
|
92 |
avg_diff_y_1 = gr.State()
|
93 |
avg_diff_y_2 = gr.State()
|
94 |
|
95 |
+
with gr.Tab():
|
96 |
+
with gr.Row():
|
97 |
+
with gr.Column():
|
98 |
+
slider_x = gr.Dropdown(label="Slider X concept range", allow_custom_value=True, multiselect=True, max_choices=2)
|
99 |
+
slider_y = gr.Dropdown(label="Slider X concept range", allow_custom_value=True, multiselect=True, max_choices=2)
|
100 |
+
prompt = gr.Textbox(label="Prompt")
|
101 |
+
submit = gr.Button("Submit")
|
102 |
+
with gr.Group(elem_id="group"):
|
103 |
+
x = gr.Slider(minimum=-10, value=0, maximum=10, elem_id="x", interactive=False)
|
104 |
+
y = gr.Slider(minimum=-10, value=0, maximum=10, elem_id="y", interactive=False)
|
105 |
+
output_image = gr.Image(elem_id="image_out")
|
106 |
+
|
107 |
+
with gr.Accordion(label="advanced options", open=False):
|
108 |
+
iterations = gr.Slider(label = "num iterations", minimum=0, value=100, maximum=300)
|
109 |
+
steps = gr.Slider(label = "num inference steps", minimum=1, value=8, maximum=30)
|
110 |
+
seed = gr.Slider(minimum=0, maximum=np.iinfo(np.int32).max, label="Seed", interactive=True, randomize=True)
|
111 |
+
|
112 |
+
submit.click(fn=generate,
|
113 |
+
inputs=[slider_x, slider_y, prompt, seed, iterations, steps, x_concept_1, x_concept_2, y_concept_1, y_concept_2, avg_diff_x_1, avg_diff_x_2, avg_diff_y_1, avg_diff_y_2],
|
114 |
+
outputs=[x, y, x_concept_1, x_concept_2, y_concept_1, y_concept_2, avg_diff_x_1, avg_diff_x_2, avg_diff_y_1, avg_diff_y_2, output_image])
|
115 |
+
x.change(fn=update_x, inputs=[x,y, prompt, seed, steps, avg_diff_x_1, avg_diff_x_2, avg_diff_y_1, avg_diff_y_2], outputs=[output_image])
|
116 |
+
y.change(fn=update_y, inputs=[x,y, prompt, seed, steps, avg_diff_x_1, avg_diff_x_2, avg_diff_y_1, avg_diff_y_2], outputs=[output_image])
|
117 |
+
with gr.Tab(label="IP Apater"):
|
118 |
+
with gr.Row():
|
119 |
+
with gr.Column():
|
120 |
+
slider_x_a = gr.Dropdown(label="Slider X concept range", allow_custom_value=True, multiselect=True, max_choices=2)
|
121 |
+
slider_y_a = gr.Dropdown(label="Slider X concept range", allow_custom_value=True, multiselect=True, max_choices=2)
|
122 |
+
prompt_a = gr.Textbox(label="Prompt")
|
123 |
+
submit_a = gr.Button("Submit")
|
124 |
+
with gr.Group(elem_id="group"):
|
125 |
+
x_a = gr.Slider(minimum=-10, value=0, maximum=10, elem_id="x", interactive=False)
|
126 |
+
y_a = gr.Slider(minimum=-10, value=0, maximum=10, elem_id="y", interactive=False)
|
127 |
+
output_image_a = gr.Image(elem_id="image_out")
|
128 |
+
|
129 |
+
with gr.Accordion(label="advanced options", open=False):
|
130 |
+
iterations_a = gr.Slider(label = "num iterations", minimum=0, value=100, maximum=300)
|
131 |
+
steps_a = gr.Slider(label = "num inference steps", minimum=1, value=8, maximum=30)
|
132 |
+
seed_a = gr.Slider(minimum=0, maximum=np.iinfo(np.int32).max, label="Seed", interactive=True, randomize=True)
|
133 |
+
|
134 |
+
submit.click(fn=generate,
|
135 |
+
inputs=[slider_x_a, slider_y_a, prompt_a, seed_a, iterations_a, steps_a, x_concept_1, x_concept_2, y_concept_1, y_concept_2, avg_diff_x_1, avg_diff_x_2, avg_diff_y_1, avg_diff_y_2],
|
136 |
+
outputs=[x_a, y_a, x_concept_1, x_concept_2, y_concept_1, y_concept_2, avg_diff_x_1, avg_diff_x_2, avg_diff_y_1, avg_diff_y_2, output_image_a])
|
137 |
+
x.change(fn=update_x, inputs=[x_a,y_a, prompt_a, seed_a, steps_a, avg_diff_x_1, avg_diff_x_2, avg_diff_y_1, avg_diff_y_2], outputs=[output_image_a])
|
138 |
+
y.change(fn=update_y, inputs=[x_a,y_a, prompt, seed_a, steps_a, avg_diff_x_1, avg_diff_x_2, avg_diff_y_1, avg_diff_y_2], outputs=[output_image_a])
|
139 |
|
140 |
+
|
141 |
if __name__ == "__main__":
|
142 |
demo.launch()
|