fantos commited on
Commit
66f9e06
·
verified ·
1 Parent(s): 9edd5a6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +26 -25
app.py CHANGED
@@ -306,7 +306,9 @@ def text_to_image(text, size, position):
306
 
307
  return image
308
 
309
- # Modify the main Gradio interface
 
 
310
  with gr.Blocks(css=css) as Kolors:
311
  with gr.Row():
312
  with gr.Column(elem_id="col-left"):
@@ -318,7 +320,7 @@ with gr.Blocks(css=css) as Kolors:
318
  )
319
  with gr.Row():
320
  image_input_type = gr.Radio(["Upload Image", "Generate Text Image"], label="Input Type", value="Upload Image")
321
-
322
  with gr.Row():
323
  image = gr.Image(label="Image", type="pil", visible=True)
324
  with gr.Column(visible=False) as text_image_inputs:
@@ -330,26 +332,7 @@ with gr.Blocks(css=css) as Kolors:
330
  value="middle-center"
331
  )
332
  generate_text_image = gr.Button("Generate Text Image")
333
-
334
-
335
- def toggle_image_input(choice):
336
- return {
337
- image: gr.update(visible=choice == "Upload Image"),
338
- text_image_inputs: gr.update(visible=choice == "Generate Text Image")
339
- }
340
-
341
- image_input_type.change(toggle_image_input, image_input_type, [image, text_image_inputs])
342
 
343
- def generate_and_use_text_image(text, size, position):
344
- text_image = text_to_image(text, size, position)
345
- return text_image
346
-
347
- generate_text_image.click(
348
- generate_and_use_text_image,
349
- inputs=[text_input, font_size, text_position],
350
- outputs=image
351
- )
352
-
353
  with gr.Accordion("Advanced Settings", open=False):
354
  negative_prompt = gr.Textbox(
355
  label="Negative prompt",
@@ -407,11 +390,29 @@ with gr.Blocks(css=css) as Kolors:
407
  canny_button = gr.Button("Canny", elem_id="button")
408
  depth_button = gr.Button("Depth", elem_id="button")
409
  pose_button = gr.Button("Pose", elem_id="button")
410
-
411
  with gr.Column(elem_id="col-right"):
412
  result = gr.Gallery(label="Result", show_label=False, columns=2)
413
  seed_used = gr.Number(label="Seed Used")
414
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
415
  with gr.Row():
416
  gr.Examples(
417
  fn = infer_canny,
@@ -428,7 +429,7 @@ with gr.Blocks(css=css) as Kolors:
428
  outputs = [result, seed_used],
429
  label = "Depth"
430
  )
431
-
432
  with gr.Row():
433
  gr.Examples(
434
  fn = infer_pose,
@@ -456,4 +457,4 @@ with gr.Blocks(css=css) as Kolors:
456
  outputs = [result, seed_used]
457
  )
458
 
459
- Kolors.queue().launch(debug=True)
 
306
 
307
  return image
308
 
309
+
310
+ # ... (previous imports and setup remain the same)
311
+
312
  with gr.Blocks(css=css) as Kolors:
313
  with gr.Row():
314
  with gr.Column(elem_id="col-left"):
 
320
  )
321
  with gr.Row():
322
  image_input_type = gr.Radio(["Upload Image", "Generate Text Image"], label="Input Type", value="Upload Image")
323
+
324
  with gr.Row():
325
  image = gr.Image(label="Image", type="pil", visible=True)
326
  with gr.Column(visible=False) as text_image_inputs:
 
332
  value="middle-center"
333
  )
334
  generate_text_image = gr.Button("Generate Text Image")
 
 
 
 
 
 
 
 
 
335
 
 
 
 
 
 
 
 
 
 
 
336
  with gr.Accordion("Advanced Settings", open=False):
337
  negative_prompt = gr.Textbox(
338
  label="Negative prompt",
 
390
  canny_button = gr.Button("Canny", elem_id="button")
391
  depth_button = gr.Button("Depth", elem_id="button")
392
  pose_button = gr.Button("Pose", elem_id="button")
393
+
394
  with gr.Column(elem_id="col-right"):
395
  result = gr.Gallery(label="Result", show_label=False, columns=2)
396
  seed_used = gr.Number(label="Seed Used")
397
+
398
+ def toggle_image_input(choice):
399
+ return {
400
+ image: gr.update(visible=choice == "Upload Image"),
401
+ text_image_inputs: gr.update(visible=choice == "Generate Text Image")
402
+ }
403
+
404
+ image_input_type.change(toggle_image_input, image_input_type, [image, text_image_inputs])
405
+
406
+ def generate_and_use_text_image(text, size, position):
407
+ text_image = text_to_image(text, size, position)
408
+ return text_image
409
+
410
+ generate_text_image.click(
411
+ generate_and_use_text_image,
412
+ inputs=[text_input, font_size, text_position],
413
+ outputs=image
414
+ )
415
+
416
  with gr.Row():
417
  gr.Examples(
418
  fn = infer_canny,
 
429
  outputs = [result, seed_used],
430
  label = "Depth"
431
  )
432
+
433
  with gr.Row():
434
  gr.Examples(
435
  fn = infer_pose,
 
457
  outputs = [result, seed_used]
458
  )
459
 
460
+ Kolors.queue().launch(debug=True)