Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -1,3 +1,5 @@
|
|
|
|
|
|
1 |
import os
|
2 |
import gradio as gr
|
3 |
import numpy as np
|
@@ -19,7 +21,6 @@ pipe = DiffusionPipeline.from_pretrained("black-forest-labs/FLUX.1-dev", torch_d
|
|
19 |
torch.cuda.empty_cache()
|
20 |
|
21 |
MAX_SEED = np.iinfo(np.int32).max
|
22 |
-
MAX_IMAGE_SIZE = 2048
|
23 |
|
24 |
pipe.flux_pipe_call_that_returns_an_iterable_of_images = flux_pipe_call_that_returns_an_iterable_of_images.__get__(pipe)
|
25 |
|
@@ -57,27 +58,20 @@ def infer(name, pet, background, style, seed=42, randomize_seed=False, width=102
|
|
57 |
else:
|
58 |
prompt = place + "holding a signal that says " + name + "in a 3D style"
|
59 |
|
60 |
-
|
61 |
-
seed = random.randint(0, MAX_SEED)
|
62 |
generator = torch.Generator().manual_seed(seed)
|
63 |
|
64 |
for img in pipe.flux_pipe_call_that_returns_an_iterable_of_images(
|
65 |
prompt=prompt,
|
66 |
-
guidance_scale=
|
67 |
-
num_inference_steps=
|
68 |
-
width=
|
69 |
-
height=
|
70 |
generator=generator,
|
71 |
output_type="pil",
|
72 |
good_vae=good_vae,
|
73 |
):
|
74 |
yield img, seed
|
75 |
-
|
76 |
-
examples = [
|
77 |
-
"cat",
|
78 |
-
"dog",
|
79 |
-
"bunny"
|
80 |
-
]
|
81 |
|
82 |
css="""
|
83 |
#col-container {
|
@@ -127,67 +121,11 @@ with gr.Blocks(css=css) as demo:
|
|
127 |
)
|
128 |
|
129 |
result = gr.Image(label="Result", show_label=False)
|
130 |
-
|
131 |
-
with gr.Accordion("Advanced Settings", open=False):
|
132 |
-
|
133 |
-
seed = gr.Slider(
|
134 |
-
label="Seed",
|
135 |
-
minimum=0,
|
136 |
-
maximum=MAX_SEED,
|
137 |
-
step=1,
|
138 |
-
value=0,
|
139 |
-
)
|
140 |
-
|
141 |
-
randomize_seed = gr.Checkbox(label="Randomize seed", value=True)
|
142 |
-
|
143 |
-
with gr.Row():
|
144 |
-
|
145 |
-
width = gr.Slider(
|
146 |
-
label="Width",
|
147 |
-
minimum=256,
|
148 |
-
maximum=MAX_IMAGE_SIZE,
|
149 |
-
step=32,
|
150 |
-
value=1024,
|
151 |
-
)
|
152 |
-
|
153 |
-
height = gr.Slider(
|
154 |
-
label="Height",
|
155 |
-
minimum=256,
|
156 |
-
maximum=MAX_IMAGE_SIZE,
|
157 |
-
step=32,
|
158 |
-
value=1024,
|
159 |
-
)
|
160 |
-
|
161 |
-
with gr.Row():
|
162 |
-
|
163 |
-
guidance_scale = gr.Slider(
|
164 |
-
label="Guidance Scale",
|
165 |
-
minimum=1,
|
166 |
-
maximum=15,
|
167 |
-
step=0.1,
|
168 |
-
value=3.5,
|
169 |
-
)
|
170 |
-
|
171 |
-
num_inference_steps = gr.Slider(
|
172 |
-
label="Number of inference steps",
|
173 |
-
minimum=1,
|
174 |
-
maximum=50,
|
175 |
-
step=1,
|
176 |
-
value=28,
|
177 |
-
)
|
178 |
-
|
179 |
-
gr.Examples(
|
180 |
-
examples = examples,
|
181 |
-
fn = infer,
|
182 |
-
inputs = [prompt],
|
183 |
-
outputs = [result, seed],
|
184 |
-
cache_examples="lazy"
|
185 |
-
)
|
186 |
|
187 |
gr.on(
|
188 |
triggers=[run_button.click, prompt.submit],
|
189 |
fn = infer,
|
190 |
-
inputs = [prompt, pet, background, style
|
191 |
outputs = [result, seed]
|
192 |
)
|
193 |
|
|
|
1 |
+
# credits : https://huggingface.co/spaces/black-forest-labs/FLUX.1-dev
|
2 |
+
|
3 |
import os
|
4 |
import gradio as gr
|
5 |
import numpy as np
|
|
|
21 |
torch.cuda.empty_cache()
|
22 |
|
23 |
MAX_SEED = np.iinfo(np.int32).max
|
|
|
24 |
|
25 |
pipe.flux_pipe_call_that_returns_an_iterable_of_images = flux_pipe_call_that_returns_an_iterable_of_images.__get__(pipe)
|
26 |
|
|
|
58 |
else:
|
59 |
prompt = place + "holding a signal that says " + name + "in a 3D style"
|
60 |
|
61 |
+
seed = random.randint(0, MAX_SEED)
|
|
|
62 |
generator = torch.Generator().manual_seed(seed)
|
63 |
|
64 |
for img in pipe.flux_pipe_call_that_returns_an_iterable_of_images(
|
65 |
prompt=prompt,
|
66 |
+
guidance_scale=3,5,
|
67 |
+
num_inference_steps=28,
|
68 |
+
width=1024,
|
69 |
+
height=1024,
|
70 |
generator=generator,
|
71 |
output_type="pil",
|
72 |
good_vae=good_vae,
|
73 |
):
|
74 |
yield img, seed
|
|
|
|
|
|
|
|
|
|
|
|
|
75 |
|
76 |
css="""
|
77 |
#col-container {
|
|
|
121 |
)
|
122 |
|
123 |
result = gr.Image(label="Result", show_label=False)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
124 |
|
125 |
gr.on(
|
126 |
triggers=[run_button.click, prompt.submit],
|
127 |
fn = infer,
|
128 |
+
inputs = [prompt, pet, background, style],
|
129 |
outputs = [result, seed]
|
130 |
)
|
131 |
|