UI revamp suggestions

#1
by multimodalart HF staff - opened
Files changed (1) hide show
  1. app.py +30 -21
app.py CHANGED
@@ -22,7 +22,7 @@ pipeline.set_adapters(["hyper-sd"], adapter_weights=[0.125])
22
  # The function for our Gradio app #
23
  #####################################
24
  @spaces.GPU(duration=120)
25
- def generate(prompt, input_image):
26
  """
27
  Runs the Flux Control pipeline for editing the given `input_image`
28
  with the specified `prompt`. The pipeline is on CPU by default.
@@ -42,32 +42,32 @@ def generate(prompt, input_image):
42
 
43
 
44
  def launch_app():
45
- with gr.Blocks() as demo:
 
 
 
46
  gr.Markdown(
47
  """
48
  # Flux Control Editing 🖌️
49
 
50
- This demo uses the [FLUX.1-dev](https://huggingface.co/black-forest-labs/FLUX.1-dev)
51
- pipeline with an edit transformer from [Sayak Paul](https://huggingface.co/sayakpaul).
52
-
53
- **Acknowledgements**:
54
- - [Sayak Paul](https://huggingface.co/sayakpaul) for open-sourcing FLUX.1-dev-edit-v0
55
- - [black-forest-labs](https://huggingface.co/black-forest-labs) for FLUX.1-dev
56
  """
57
  )
58
-
59
  with gr.Row():
60
- prompt = gr.Textbox(
61
- label="Prompt",
62
- placeholder="e.g. 'Edit a certain thing in the image'"
63
- )
64
- input_image = gr.Image(
65
- label="Image",
66
- type="pil",
67
- )
68
-
69
- generate_button = gr.Button("Generate")
70
- output_image = gr.Image(label="Edited Image")
 
 
71
 
72
  # Connect button to function
73
  generate_button.click(
@@ -82,8 +82,17 @@ def launch_app():
82
  ["Make the mushroom polka-dotted", "mushroom.jpg"],
83
  ],
84
  inputs=[prompt, input_image],
 
 
 
 
 
 
 
 
 
 
85
  )
86
-
87
  return demo
88
 
89
 
 
22
  # The function for our Gradio app #
23
  #####################################
24
  @spaces.GPU(duration=120)
25
+ def generate(prompt, input_image, progress=gr.Progress(track_tqdm=True)):
26
  """
27
  Runs the Flux Control pipeline for editing the given `input_image`
28
  with the specified `prompt`. The pipeline is on CPU by default.
 
42
 
43
 
44
  def launch_app():
45
+ css = '''
46
+ .gradio-container{max-width: 1100px !important}
47
+ '''
48
+ with gr.Blocks(css=css) as demo:
49
  gr.Markdown(
50
  """
51
  # Flux Control Editing 🖌️
52
 
53
+ Edit any image with the [FLUX.1-dev](https://huggingface.co/black-forest-labs/FLUX.1-dev)
54
+ [Flux Control edit framework](https://github.com/sayakpaul/flux-image-editing) by [Sayak Paul](https://huggingface.co/sayakpaul).
 
 
 
 
55
  """
56
  )
 
57
  with gr.Row():
58
+ with gr.Column():
59
+ with gr.Group():
60
+ input_image = gr.Image(
61
+ label="Image you would like to edit",
62
+ type="pil",
63
+ )
64
+ prompt = gr.Textbox(
65
+ label="Your edit prompt",
66
+ placeholder="e.g. 'Turn the color of the mushroom to blue'"
67
+ )
68
+ generate_button = gr.Button("Generate")
69
+
70
+ output_image = gr.Image(label="Edited Image")
71
 
72
  # Connect button to function
73
  generate_button.click(
 
82
  ["Make the mushroom polka-dotted", "mushroom.jpg"],
83
  ],
84
  inputs=[prompt, input_image],
85
+ outputs=[output_image],
86
+ fn=generate,
87
+ cache_examples="lazy"
88
+ )
89
+ gr.Markdown(
90
+ """
91
+ **Acknowledgements**:
92
+ - [Sayak Paul](https://huggingface.co/sayakpaul) for open-sourcing FLUX.1-dev-edit-v0
93
+ - [black-forest-labs](https://huggingface.co/black-forest-labs) for FLUX.1-dev
94
+ """
95
  )
 
96
  return demo
97
 
98