Spaces:
Running
on
Zero
Running
on
Zero
UI/UX suggestions and not using hte turbo model for quality trade off
#2
by
multimodalart
HF Staff
- opened
app.py
CHANGED
@@ -63,7 +63,7 @@ class Generator:
|
|
63 |
# load dreamo
|
64 |
model_root = 'black-forest-labs/FLUX.1-dev'
|
65 |
dreamo_pipeline = DreamOPipeline.from_pretrained(model_root, torch_dtype=torch.bfloat16)
|
66 |
-
dreamo_pipeline.load_dreamo_model(device, use_turbo=
|
67 |
self.dreamo_pipeline = dreamo_pipeline.to(device)
|
68 |
|
69 |
@torch.no_grad()
|
@@ -107,7 +107,7 @@ def generate_image(
|
|
107 |
width=1024,
|
108 |
height=1024,
|
109 |
ref_res=512,
|
110 |
-
num_steps=
|
111 |
guidance=3.5,
|
112 |
true_cfg=1,
|
113 |
cfg_start_step=0,
|
@@ -185,11 +185,26 @@ If DreamO is helpful, please help to ⭐ the <a href='https://github.com/bytedan
|
|
185 |
If you have any questions or feedbacks, feel free to open a discussion or contact <b>[email protected]</b> and <b>[email protected]</b>
|
186 |
""" # noqa E501
|
187 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
188 |
|
189 |
def create_demo():
|
190 |
|
191 |
with gr.Blocks() as demo:
|
192 |
-
|
|
|
|
|
193 |
|
194 |
with gr.Row():
|
195 |
with gr.Column():
|
@@ -197,14 +212,29 @@ def create_demo():
|
|
197 |
ref_image1 = gr.Image(label="ref image 1", type="numpy", height=256)
|
198 |
ref_image2 = gr.Image(label="ref image 2", type="numpy", height=256)
|
199 |
with gr.Row():
|
200 |
-
|
201 |
-
|
|
|
|
|
202 |
prompt = gr.Textbox(label="Prompt", value="a person playing guitar in the street")
|
203 |
width = gr.Slider(768, 1024, 1024, step=16, label="Width")
|
204 |
height = gr.Slider(768, 1024, 1024, step=16, label="Height")
|
205 |
-
num_steps = gr.Slider(8, 30,
|
206 |
guidance = gr.Slider(1.0, 10.0, 3.5, step=0.1, label="Guidance")
|
207 |
seed = gr.Textbox(label="Seed (-1 for random)", value="-1")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
208 |
with gr.Accordion("Advanced Options", open=False, visible=False):
|
209 |
ref_res = gr.Slider(512, 1024, 512, step=16, label="resolution for ref image")
|
210 |
neg_prompt = gr.Textbox(label="Neg Prompt", value="")
|
@@ -230,8 +260,8 @@ def create_demo():
|
|
230 |
[
|
231 |
'example_inputs/woman1.png',
|
232 |
None,
|
233 |
-
'ip',
|
234 |
-
'ip',
|
235 |
'profile shot dark photo of a 25-year-old female with smoke escaping from her mouth, the backlit smoke gives the image an ephemeral quality, natural face, natural eyebrows, natural skin texture, award winning photo, highly detailed face, atmospheric lighting, film grain, monochrome', # noqa E501
|
236 |
9180879731249039735,
|
237 |
],
|
@@ -262,7 +292,7 @@ def create_demo():
|
|
262 |
[
|
263 |
'example_inputs/hinton.jpeg',
|
264 |
None,
|
265 |
-
'id',
|
266 |
'ip',
|
267 |
'portrait, Chibi',
|
268 |
5443415087540486371,
|
@@ -270,7 +300,7 @@ def create_demo():
|
|
270 |
[
|
271 |
'example_inputs/mickey.png',
|
272 |
None,
|
273 |
-
'style',
|
274 |
'ip',
|
275 |
'generate a same style image. A rooster wearing overalls.',
|
276 |
6245580464677124951,
|
@@ -294,7 +324,7 @@ def create_demo():
|
|
294 |
[
|
295 |
'example_inputs/woman2.png',
|
296 |
'example_inputs/dress.png',
|
297 |
-
'id',
|
298 |
'ip',
|
299 |
'the woman wearing a dress, In the banquet hall',
|
300 |
7698454872441022867,
|
@@ -362,4 +392,4 @@ def create_demo():
|
|
362 |
|
363 |
if __name__ == '__main__':
|
364 |
demo = create_demo()
|
365 |
-
demo.launch()
|
|
|
63 |
# load dreamo
|
64 |
model_root = 'black-forest-labs/FLUX.1-dev'
|
65 |
dreamo_pipeline = DreamOPipeline.from_pretrained(model_root, torch_dtype=torch.bfloat16)
|
66 |
+
dreamo_pipeline.load_dreamo_model(device, use_turbo=False) # MODIFIED: use_turbo=False
|
67 |
self.dreamo_pipeline = dreamo_pipeline.to(device)
|
68 |
|
69 |
@torch.no_grad()
|
|
|
107 |
width=1024,
|
108 |
height=1024,
|
109 |
ref_res=512,
|
110 |
+
num_steps=28, # MODIFIED: default num_steps to 28
|
111 |
guidance=3.5,
|
112 |
true_cfg=1,
|
113 |
cfg_start_step=0,
|
|
|
185 |
If you have any questions or feedbacks, feel free to open a discussion or contact <b>[email protected]</b> and <b>[email protected]</b>
|
186 |
""" # noqa E501
|
187 |
|
188 |
+
# MODIFIED: Function to update guidance based on task selection
|
189 |
+
def update_guidance_on_task_selection(task1_value, task2_value, current_guidance_value_from_slider):
|
190 |
+
# current_guidance_value_from_slider is a float from the slider state
|
191 |
+
is_identity_selected = (task1_value == "id" or task2_value == "id")
|
192 |
+
|
193 |
+
if is_identity_selected:
|
194 |
+
return gr.update(value=1.5)
|
195 |
+
else:
|
196 |
+
# If no identity task is selected, and current guidance is 1.5 (was likely set by previous identity task),
|
197 |
+
# revert to original default (3.5). Otherwise, keep user's manual setting.
|
198 |
+
if float(current_guidance_value_from_slider) == 1.5:
|
199 |
+
return gr.update(value=3.5) # Default slider value
|
200 |
+
return gr.update() # No change, keep current value
|
201 |
|
202 |
def create_demo():
|
203 |
|
204 |
with gr.Blocks() as demo:
|
205 |
+
# MODIFIED: User guide in a closed Accordion
|
206 |
+
with gr.Accordion("User Guide", open=False):
|
207 |
+
gr.Markdown(_HEADER_)
|
208 |
|
209 |
with gr.Row():
|
210 |
with gr.Column():
|
|
|
212 |
ref_image1 = gr.Image(label="ref image 1", type="numpy", height=256)
|
213 |
ref_image2 = gr.Image(label="ref image 2", type="numpy", height=256)
|
214 |
with gr.Row():
|
215 |
+
# MODIFIED: Task names and values
|
216 |
+
task_choices = [("Composition", "ip"), ("Identity", "id"), ("Style", "style")]
|
217 |
+
ref_task1 = gr.Dropdown(choices=task_choices, value="ip", label="task for ref image 1")
|
218 |
+
ref_task2 = gr.Dropdown(choices=task_choices, value="ip", label="task for ref image 2")
|
219 |
prompt = gr.Textbox(label="Prompt", value="a person playing guitar in the street")
|
220 |
width = gr.Slider(768, 1024, 1024, step=16, label="Width")
|
221 |
height = gr.Slider(768, 1024, 1024, step=16, label="Height")
|
222 |
+
num_steps = gr.Slider(8, 30, 28, step=1, label="Number of steps") # MODIFIED: default slider value to 28
|
223 |
guidance = gr.Slider(1.0, 10.0, 3.5, step=0.1, label="Guidance")
|
224 |
seed = gr.Textbox(label="Seed (-1 for random)", value="-1")
|
225 |
+
|
226 |
+
# MODIFIED: Event listeners for task dropdowns to update guidance
|
227 |
+
ref_task1.change(
|
228 |
+
fn=update_guidance_on_task_selection,
|
229 |
+
inputs=[ref_task1, ref_task2, guidance], # Pass current guidance value
|
230 |
+
outputs=[guidance]
|
231 |
+
)
|
232 |
+
ref_task2.change(
|
233 |
+
fn=update_guidance_on_task_selection,
|
234 |
+
inputs=[ref_task1, ref_task2, guidance], # Pass current guidance value
|
235 |
+
outputs=[guidance]
|
236 |
+
)
|
237 |
+
|
238 |
with gr.Accordion("Advanced Options", open=False, visible=False):
|
239 |
ref_res = gr.Slider(512, 1024, 512, step=16, label="resolution for ref image")
|
240 |
neg_prompt = gr.Textbox(label="Neg Prompt", value="")
|
|
|
260 |
[
|
261 |
'example_inputs/woman1.png',
|
262 |
None,
|
263 |
+
'ip', # Corresponds to "Composition"
|
264 |
+
'ip', # Corresponds to "Composition"
|
265 |
'profile shot dark photo of a 25-year-old female with smoke escaping from her mouth, the backlit smoke gives the image an ephemeral quality, natural face, natural eyebrows, natural skin texture, award winning photo, highly detailed face, atmospheric lighting, film grain, monochrome', # noqa E501
|
266 |
9180879731249039735,
|
267 |
],
|
|
|
292 |
[
|
293 |
'example_inputs/hinton.jpeg',
|
294 |
None,
|
295 |
+
'id', # Corresponds to "Identity"
|
296 |
'ip',
|
297 |
'portrait, Chibi',
|
298 |
5443415087540486371,
|
|
|
300 |
[
|
301 |
'example_inputs/mickey.png',
|
302 |
None,
|
303 |
+
'style', # Corresponds to "Style"
|
304 |
'ip',
|
305 |
'generate a same style image. A rooster wearing overalls.',
|
306 |
6245580464677124951,
|
|
|
324 |
[
|
325 |
'example_inputs/woman2.png',
|
326 |
'example_inputs/dress.png',
|
327 |
+
'id', # Corresponds to "Identity"
|
328 |
'ip',
|
329 |
'the woman wearing a dress, In the banquet hall',
|
330 |
7698454872441022867,
|
|
|
392 |
|
393 |
if __name__ == '__main__':
|
394 |
demo = create_demo()
|
395 |
+
demo.launch()
|