QHL067 commited on
Commit
9b01db5
·
1 Parent(s): c532653
Files changed (1) hide show
  1. app.py +74 -67
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.Markdown("This allows interpolation in the input text latent space, as demonstrated here.")
286
- 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.)")
287
- # gr.Markdown("CrossFlow directly transforms text representations into images for text-to-image generation, enabling interpolation in the input text latent space.")
288
-
289
- with gr.Row():
290
- prompt1 = gr.Text(
291
- label="Prompt_1",
292
- show_label=False,
293
- max_lines=1,
294
- placeholder="Enter your prompt for the first image",
295
- container=False,
296
- )
297
-
298
- with gr.Row():
299
- prompt2 = gr.Text(
300
- label="Prompt_2",
301
- show_label=False,
302
- max_lines=1,
303
- placeholder="Enter your prompt for the second image",
304
- container=False,
305
- )
306
-
307
- with gr.Row():
308
- run_button = gr.Button("Run", scale=0, variant="primary")
309
-
310
- # Create separate outputs for the first image, last image, and the animated GIF
311
- first_image_output = gr.Image(label="Image of the first prompt", show_label=True)
312
- last_image_output = gr.Image(label="Image of the second prompt", show_label=True)
313
- gif_output = gr.Image(label="Linear interpolation", show_label=True)
314
-
315
- with gr.Accordion("Advanced Settings", open=False):
316
- seed = gr.Slider(
317
- label="Seed",
318
- minimum=0,
319
- maximum=MAX_SEED,
320
- step=1,
321
- value=0,
322
- )
323
-
324
- randomize_seed = gr.Checkbox(label="Randomize seed", value=True)
325
-
326
- with gr.Row():
327
- guidance_scale = gr.Slider(
328
- label="Guidance scale",
329
- minimum=0.0,
330
- maximum=10.0,
331
- step=0.1,
332
- value=7.0, # Replace with defaults that work for your model
333
- )
334
- with gr.Row():
335
- num_inference_steps = gr.Slider(
336
- label="Number of inference steps - 50 inference steps are recommended; but you can reduce to 20 if the demo fails.",
337
- minimum=1,
338
- maximum=50,
339
- step=1,
340
- value=25, # Replace with defaults that work for your model
341
- )
342
- with gr.Row():
343
- num_of_interpolation = gr.Slider(
344
- label="Number of images for interpolation - More images yield smoother transitions but require more resources and may fail.",
345
- minimum=5,
346
- maximum=50,
347
- step=1,
348
- value=10, # Replace with defaults that work for your model
349
- )
350
-
351
- gr.Examples(examples=examples, inputs=[prompt1, prompt2])
 
 
 
 
 
 
 
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,