tabs
Browse files
app.py
CHANGED
@@ -282,73 +282,80 @@ with gr.Blocks(css=css) as demo:
|
|
282 |
with gr.Column(elem_id="col-container"):
|
283 |
gr.Markdown("# CrossFlow")
|
284 |
gr.Markdown("[CrossFlow](https://cross-flow.github.io/) directly transforms text representations into images for text-to-image generation, without the need for both the noise distribution and conditioning mechanism.")
|
285 |
-
gr.
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
352 |
gr.on(
|
353 |
triggers=[run_button.click, prompt1.submit, prompt2.submit],
|
354 |
fn=infer,
|
|
|
282 |
with gr.Column(elem_id="col-container"):
|
283 |
gr.Markdown("# CrossFlow")
|
284 |
gr.Markdown("[CrossFlow](https://cross-flow.github.io/) directly transforms text representations into images for text-to-image generation, without the need for both the noise distribution and conditioning mechanism.")
|
285 |
+
with gr.Tabs():
|
286 |
+
with gr.Tab("Linear interpolation"):
|
287 |
+
gr.Markdown("This allows interpolation in the input text latent space, as demonstrated here.")
|
288 |
+
gr.Markdown("This demo uses 256px images, 25 sampling steps (instead of 50), and 10 interpolations (instead of 50) to conserve GPU memory. For better results, see the original [code](https://github.com/qihao067/CrossFlow). (You may adjust them in Advanced Settings, but doing so may trigger OOM errors.)")
|
289 |
+
# gr.Markdown("CrossFlow directly transforms text representations into images for text-to-image generation, enabling interpolation in the input text latent space.")
|
290 |
+
|
291 |
+
with gr.Row():
|
292 |
+
prompt1 = gr.Text(
|
293 |
+
label="Prompt_1",
|
294 |
+
show_label=False,
|
295 |
+
max_lines=1,
|
296 |
+
placeholder="Enter your prompt for the first image",
|
297 |
+
container=False,
|
298 |
+
)
|
299 |
+
|
300 |
+
with gr.Row():
|
301 |
+
prompt2 = gr.Text(
|
302 |
+
label="Prompt_2",
|
303 |
+
show_label=False,
|
304 |
+
max_lines=1,
|
305 |
+
placeholder="Enter your prompt for the second image",
|
306 |
+
container=False,
|
307 |
+
)
|
308 |
+
|
309 |
+
with gr.Row():
|
310 |
+
run_button = gr.Button("Run", scale=0, variant="primary")
|
311 |
+
|
312 |
+
# Create separate outputs for the first image, last image, and the animated GIF
|
313 |
+
first_image_output = gr.Image(label="Image of the first prompt", show_label=True)
|
314 |
+
last_image_output = gr.Image(label="Image of the second prompt", show_label=True)
|
315 |
+
gif_output = gr.Image(label="Linear interpolation", show_label=True)
|
316 |
+
|
317 |
+
with gr.Accordion("Advanced Settings", open=False):
|
318 |
+
seed = gr.Slider(
|
319 |
+
label="Seed",
|
320 |
+
minimum=0,
|
321 |
+
maximum=MAX_SEED,
|
322 |
+
step=1,
|
323 |
+
value=0,
|
324 |
+
)
|
325 |
+
|
326 |
+
randomize_seed = gr.Checkbox(label="Randomize seed", value=True)
|
327 |
+
|
328 |
+
with gr.Row():
|
329 |
+
guidance_scale = gr.Slider(
|
330 |
+
label="Guidance scale",
|
331 |
+
minimum=0.0,
|
332 |
+
maximum=10.0,
|
333 |
+
step=0.1,
|
334 |
+
value=7.0, # Replace with defaults that work for your model
|
335 |
+
)
|
336 |
+
with gr.Row():
|
337 |
+
num_inference_steps = gr.Slider(
|
338 |
+
label="Number of inference steps - 50 inference steps are recommended; but you can reduce to 20 if the demo fails.",
|
339 |
+
minimum=1,
|
340 |
+
maximum=50,
|
341 |
+
step=1,
|
342 |
+
value=25, # Replace with defaults that work for your model
|
343 |
+
)
|
344 |
+
with gr.Row():
|
345 |
+
num_of_interpolation = gr.Slider(
|
346 |
+
label="Number of images for interpolation - More images yield smoother transitions but require more resources and may fail.",
|
347 |
+
minimum=5,
|
348 |
+
maximum=50,
|
349 |
+
step=1,
|
350 |
+
value=10, # Replace with defaults that work for your model
|
351 |
+
)
|
352 |
+
|
353 |
+
gr.Examples(examples=examples, inputs=[prompt1, prompt2])
|
354 |
+
|
355 |
+
with gr.Tab("Arithmetic Operations"):
|
356 |
+
# The second tab is currently empty. You can add more components later.
|
357 |
+
gr.Markdown("This tab is intentionally left empty.")
|
358 |
+
|
359 |
gr.on(
|
360 |
triggers=[run_button.click, prompt1.submit, prompt2.submit],
|
361 |
fn=infer,
|