Spaces:
Running
on
Zero
Running
on
Zero
Fabrice-TIERCELIN
commited on
Commit
•
4ddbfd8
1
Parent(s):
dc32ed8
Avoid the user to manually change the seed
Browse files
app.py
CHANGED
@@ -1,5 +1,6 @@
|
|
1 |
import gradio as gr
|
2 |
import spaces
|
|
|
3 |
import os
|
4 |
os.environ["HF_HUB_ENABLE_HF_TRANSFER"] = "1"
|
5 |
|
@@ -80,6 +81,7 @@ def generate(
|
|
80 |
style_image="https://github.com/okaris/omni-zero/assets/1448702/64dc150b-f683-41b1-be23-b6a52c771584",
|
81 |
identity_image="https://github.com/okaris/omni-zero/assets/1448702/ba193a3a-f90e-4461-848a-560454531c58",
|
82 |
base_image="https://github.com/okaris/omni-zero/assets/1448702/2ca63443-c7f3-4ba6-95c1-2a341414865f",
|
|
|
83 |
seed=42,
|
84 |
negative_prompt="blurry, out of focus",
|
85 |
guidance_scale=3.0,
|
@@ -133,6 +135,9 @@ def generate(
|
|
133 |
if face_embedding_base_image is not None:
|
134 |
target_kps = face_kps_base_image
|
135 |
|
|
|
|
|
|
|
136 |
pipeline.set_ip_adapter_scale([identity_image_strength,
|
137 |
{
|
138 |
"down": { "block_2": [0.0, 0.0] },
|
@@ -192,7 +197,7 @@ with gr.Blocks() as demo:
|
|
192 |
with gr.Row():
|
193 |
identity_image = gr.Image(label="Identity Image")
|
194 |
with gr.Row():
|
195 |
-
identity_image_strength = gr.Slider(label="
|
196 |
with gr.Accordion("Advanced options", open=False):
|
197 |
with gr.Row():
|
198 |
with gr.Column(min_width=140):
|
@@ -200,6 +205,7 @@ with gr.Blocks() as demo:
|
|
200 |
base_image = gr.Image(label="Base Image")
|
201 |
with gr.Row():
|
202 |
base_image_strength = gr.Slider(label="Strength",step=0.01, minimum=0.0, maximum=1.0, value=0.15, min_width=120)
|
|
|
203 |
# with gr.Column(min_width=140):
|
204 |
# with gr.Row():
|
205 |
# depth_image = gr.Image(label="depth_image", value=None)
|
@@ -207,8 +213,8 @@ with gr.Blocks() as demo:
|
|
207 |
# depth_image_strength = gr.Slider(label="depth_image_strength",step=0.01, minimum=0.0, maximum=1.0, value=0.5)
|
208 |
|
209 |
with gr.Row():
|
|
|
210 |
seed = gr.Slider(label="Seed",step=1, minimum=0, maximum=10000000, value=42)
|
211 |
-
number_of_images = gr.Slider(label="Number of Outputs",step=1, minimum=1, maximum=4, value=1)
|
212 |
with gr.Row():
|
213 |
guidance_scale = gr.Slider(label="Guidance Scale",step=0.1, minimum=0.0, maximum=14.0, value=3.0)
|
214 |
number_of_steps = gr.Slider(label="Number of Steps",step=1, minimum=1, maximum=50, value=10)
|
@@ -218,7 +224,7 @@ with gr.Blocks() as demo:
|
|
218 |
out = gr.Gallery(label="Output(s)")
|
219 |
with gr.Row():
|
220 |
# clear = gr.Button("Clear")
|
221 |
-
submit = gr.Button("Generate")
|
222 |
|
223 |
submit.click(generate, inputs=[
|
224 |
prompt,
|
@@ -226,6 +232,7 @@ with gr.Blocks() as demo:
|
|
226 |
style_image,
|
227 |
identity_image,
|
228 |
base_image,
|
|
|
229 |
seed,
|
230 |
negative_prompt,
|
231 |
guidance_scale,
|
|
|
1 |
import gradio as gr
|
2 |
import spaces
|
3 |
+
import random
|
4 |
import os
|
5 |
os.environ["HF_HUB_ENABLE_HF_TRANSFER"] = "1"
|
6 |
|
|
|
81 |
style_image="https://github.com/okaris/omni-zero/assets/1448702/64dc150b-f683-41b1-be23-b6a52c771584",
|
82 |
identity_image="https://github.com/okaris/omni-zero/assets/1448702/ba193a3a-f90e-4461-848a-560454531c58",
|
83 |
base_image="https://github.com/okaris/omni-zero/assets/1448702/2ca63443-c7f3-4ba6-95c1-2a341414865f",
|
84 |
+
randomize_seed=True
|
85 |
seed=42,
|
86 |
negative_prompt="blurry, out of focus",
|
87 |
guidance_scale=3.0,
|
|
|
135 |
if face_embedding_base_image is not None:
|
136 |
target_kps = face_kps_base_image
|
137 |
|
138 |
+
if randomize_seed:
|
139 |
+
seed = random.randint(0, 10000000)
|
140 |
+
|
141 |
pipeline.set_ip_adapter_scale([identity_image_strength,
|
142 |
{
|
143 |
"down": { "block_2": [0.0, 0.0] },
|
|
|
197 |
with gr.Row():
|
198 |
identity_image = gr.Image(label="Identity Image")
|
199 |
with gr.Row():
|
200 |
+
identity_image_strength = gr.Slider(label="Strength",step=0.01, minimum=0.0, maximum=1.0, value=1.0)
|
201 |
with gr.Accordion("Advanced options", open=False):
|
202 |
with gr.Row():
|
203 |
with gr.Column(min_width=140):
|
|
|
205 |
base_image = gr.Image(label="Base Image")
|
206 |
with gr.Row():
|
207 |
base_image_strength = gr.Slider(label="Strength",step=0.01, minimum=0.0, maximum=1.0, value=0.15, min_width=120)
|
208 |
+
number_of_images = gr.Slider(label="Number of Outputs",step=1, minimum=1, maximum=4, value=1)
|
209 |
# with gr.Column(min_width=140):
|
210 |
# with gr.Row():
|
211 |
# depth_image = gr.Image(label="depth_image", value=None)
|
|
|
213 |
# depth_image_strength = gr.Slider(label="depth_image_strength",step=0.01, minimum=0.0, maximum=1.0, value=0.5)
|
214 |
|
215 |
with gr.Row():
|
216 |
+
randomize_seed = gr.Checkbox(label="Randomize seed", value=True, info="If checked, result is always different")
|
217 |
seed = gr.Slider(label="Seed",step=1, minimum=0, maximum=10000000, value=42)
|
|
|
218 |
with gr.Row():
|
219 |
guidance_scale = gr.Slider(label="Guidance Scale",step=0.1, minimum=0.0, maximum=14.0, value=3.0)
|
220 |
number_of_steps = gr.Slider(label="Number of Steps",step=1, minimum=1, maximum=50, value=10)
|
|
|
224 |
out = gr.Gallery(label="Output(s)")
|
225 |
with gr.Row():
|
226 |
# clear = gr.Button("Clear")
|
227 |
+
submit = gr.Button("Generate", variant="primary")
|
228 |
|
229 |
submit.click(generate, inputs=[
|
230 |
prompt,
|
|
|
232 |
style_image,
|
233 |
identity_image,
|
234 |
base_image,
|
235 |
+
randomize_seed,
|
236 |
seed,
|
237 |
negative_prompt,
|
238 |
guidance_scale,
|